Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / chromeos / timezone / timezone_provider.h
blob0b5741b0a7848b4cbddd6168ada5968df1eddc63
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/thread_checker.h"
14 #include "base/time/time.h"
15 #include "chrome/browser/chromeos/timezone/timezone_request.h"
16 #include "url/gurl.h"
18 namespace net {
19 class URLRequestContextGetter;
22 namespace chromeos {
24 struct Geoposition;
26 // This class implements Google TimeZone API.
28 // Note: this should probably be a singleton to monitor requests rate.
29 // But as it is used only from WizardController, it can be owned by it for now.
30 class TimeZoneProvider {
31 public:
32 TimeZoneProvider(net::URLRequestContextGetter* url_context_getter,
33 const GURL& url);
34 virtual ~TimeZoneProvider();
36 // Initiates new request (See TimeZoneRequest for parameters description.)
37 void RequestTimezone(const Geoposition& position,
38 bool sensor,
39 base::TimeDelta timeout,
40 TimeZoneRequest::TimeZoneResponseCallback callback);
42 private:
43 // Deletes request from requests_.
44 void OnTimezoneResponse(TimeZoneRequest* request,
45 TimeZoneRequest::TimeZoneResponseCallback callback,
46 scoped_ptr<TimeZoneResponseData> timezone,
47 bool server_error);
49 scoped_refptr<net::URLRequestContextGetter> url_context_getter_;
50 const GURL url_;
52 // Requests in progress.
53 // TimeZoneProvider owns all requests, so this vector is deleted on destroy.
54 ScopedVector<TimeZoneRequest> requests_;
56 // Creation and destruction should happen on the same thread.
57 base::ThreadChecker thread_checker_;
59 DISALLOW_COPY_AND_ASSIGN(TimeZoneProvider);
62 } // namespace chromeos
64 #endif // CHROME_BROWSER_CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_