OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_ | 5 #ifndef CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_ |
6 #define CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_ | 6 #define CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // Note: this should probably be a singleton to monitor requests rate. | 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. | 29 // But as it is used only from WizardController, it can be owned by it for now. |
30 class CHROMEOS_EXPORT TimeZoneProvider { | 30 class CHROMEOS_EXPORT TimeZoneProvider { |
31 public: | 31 public: |
32 TimeZoneProvider(net::URLRequestContextGetter* url_context_getter, | 32 TimeZoneProvider(net::URLRequestContextGetter* url_context_getter, |
33 const GURL& url); | 33 const GURL& url); |
34 virtual ~TimeZoneProvider(); | 34 virtual ~TimeZoneProvider(); |
35 | 35 |
36 // Initiates new request (See TimeZoneRequest for parameters description.) | 36 // Initiates new request (See TimeZoneRequest for parameters description.) |
37 void RequestTimezone(const Geoposition& position, | 37 void RequestTimezone(const Geoposition& position, |
38 bool sensor, | |
39 base::TimeDelta timeout, | 38 base::TimeDelta timeout, |
40 TimeZoneRequest::TimeZoneResponseCallback callback); | 39 TimeZoneRequest::TimeZoneResponseCallback callback); |
41 | 40 |
42 private: | 41 private: |
43 friend class TestTimeZoneAPIURLFetcherCallback; | 42 friend class TestTimeZoneAPIURLFetcherCallback; |
44 | 43 |
45 // Deletes request from requests_. | 44 // Deletes request from requests_. |
46 void OnTimezoneResponse(TimeZoneRequest* request, | 45 void OnTimezoneResponse(TimeZoneRequest* request, |
47 TimeZoneRequest::TimeZoneResponseCallback callback, | 46 TimeZoneRequest::TimeZoneResponseCallback callback, |
48 scoped_ptr<TimeZoneResponseData> timezone, | 47 scoped_ptr<TimeZoneResponseData> timezone, |
49 bool server_error); | 48 bool server_error); |
50 | 49 |
51 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; | 50 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; |
52 const GURL url_; | 51 const GURL url_; |
53 | 52 |
54 // Requests in progress. | 53 // Requests in progress. |
55 // TimeZoneProvider owns all requests, so this vector is deleted on destroy. | 54 // TimeZoneProvider owns all requests, so this vector is deleted on destroy. |
56 ScopedVector<TimeZoneRequest> requests_; | 55 ScopedVector<TimeZoneRequest> requests_; |
57 | 56 |
58 // Creation and destruction should happen on the same thread. | 57 // Creation and destruction should happen on the same thread. |
59 base::ThreadChecker thread_checker_; | 58 base::ThreadChecker thread_checker_; |
60 | 59 |
61 DISALLOW_COPY_AND_ASSIGN(TimeZoneProvider); | 60 DISALLOW_COPY_AND_ASSIGN(TimeZoneProvider); |
62 }; | 61 }; |
63 | 62 |
64 } // namespace chromeos | 63 } // namespace chromeos |
65 | 64 |
66 #endif // CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_ | 65 #endif // CHROMEOS_TIMEZONE_TIMEZONE_PROVIDER_H_ |
OLD | NEW |