| 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_RESOLVER_H_ | 5 #ifndef CHROMEOS_TIMEZONE_TIMEZONE_RESOLVER_H_ |
| 6 #define CHROMEOS_TIMEZONE_TIMEZONE_RESOLVER_H_ | 6 #define CHROMEOS_TIMEZONE_TIMEZONE_RESOLVER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 using DelayNetworkCallClosure = base::Callback<void(const base::Closure&)>; | 35 using DelayNetworkCallClosure = base::Callback<void(const base::Closure&)>; |
| 36 | 36 |
| 37 class Delegate { | 37 class Delegate { |
| 38 public: | 38 public: |
| 39 Delegate(); | 39 Delegate(); |
| 40 virtual ~Delegate(); | 40 virtual ~Delegate(); |
| 41 | 41 |
| 42 // Returns true if TimeZoneResolver should include WiFi data in request. | 42 // Returns true if TimeZoneResolver should include WiFi data in request. |
| 43 virtual bool ShouldSendWiFiGeolocationData() = 0; | 43 virtual bool ShouldSendWiFiGeolocationData() = 0; |
| 44 | 44 |
| 45 // Returns true if TimeZoneResolver should include Cellular data in request. |
| 46 virtual bool ShouldSendCellularGeolocationData() = 0; |
| 47 |
| 45 private: | 48 private: |
| 46 DISALLOW_COPY_AND_ASSIGN(Delegate); | 49 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 47 }; | 50 }; |
| 48 | 51 |
| 49 // This is a LocalState preference to store base::Time value of the last | 52 // This is a LocalState preference to store base::Time value of the last |
| 50 // request. It is used to limit request rate on browser restart. | 53 // request. It is used to limit request rate on browser restart. |
| 51 static const char kLastTimeZoneRefreshTime[]; | 54 static const char kLastTimeZoneRefreshTime[]; |
| 52 | 55 |
| 53 TimeZoneResolver(Delegate* delegate, | 56 TimeZoneResolver(Delegate* delegate, |
| 54 scoped_refptr<net::URLRequestContextGetter> context, | 57 scoped_refptr<net::URLRequestContextGetter> context, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 return delay_network_call_; | 78 return delay_network_call_; |
| 76 } | 79 } |
| 77 | 80 |
| 78 ApplyTimeZoneCallback apply_timezone() const { return apply_timezone_; } | 81 ApplyTimeZoneCallback apply_timezone() const { return apply_timezone_; } |
| 79 | 82 |
| 80 PrefService* local_state() const { return local_state_; } | 83 PrefService* local_state() const { return local_state_; } |
| 81 | 84 |
| 82 // Proxy call to Delegate::ShouldSendWiFiGeolocationData(). | 85 // Proxy call to Delegate::ShouldSendWiFiGeolocationData(). |
| 83 bool ShouldSendWiFiGeolocationData() const; | 86 bool ShouldSendWiFiGeolocationData() const; |
| 84 | 87 |
| 88 // Proxy call to Delegate::ShouldSendCellularGeolocationData(). |
| 89 bool ShouldSendCellularGeolocationData() const; |
| 90 |
| 85 // Expose internal fuctions for testing. | 91 // Expose internal fuctions for testing. |
| 86 static int MaxRequestsCountForIntervalForTesting( | 92 static int MaxRequestsCountForIntervalForTesting( |
| 87 const double interval_seconds); | 93 const double interval_seconds); |
| 88 static int IntervalForNextRequestForTesting(const int requests); | 94 static int IntervalForNextRequestForTesting(const int requests); |
| 89 | 95 |
| 90 private: | 96 private: |
| 91 Delegate* delegate_; | 97 Delegate* delegate_; |
| 92 | 98 |
| 93 scoped_refptr<net::URLRequestContextGetter> context_; | 99 scoped_refptr<net::URLRequestContextGetter> context_; |
| 94 const GURL url_; | 100 const GURL url_; |
| 95 | 101 |
| 96 const ApplyTimeZoneCallback apply_timezone_; | 102 const ApplyTimeZoneCallback apply_timezone_; |
| 97 const DelayNetworkCallClosure delay_network_call_; | 103 const DelayNetworkCallClosure delay_network_call_; |
| 98 PrefService* local_state_; | 104 PrefService* local_state_; |
| 99 | 105 |
| 100 std::unique_ptr<TimeZoneResolverImpl> implementation_; | 106 std::unique_ptr<TimeZoneResolverImpl> implementation_; |
| 101 | 107 |
| 102 base::ThreadChecker thread_checker_; | 108 base::ThreadChecker thread_checker_; |
| 103 | 109 |
| 104 DISALLOW_COPY_AND_ASSIGN(TimeZoneResolver); | 110 DISALLOW_COPY_AND_ASSIGN(TimeZoneResolver); |
| 105 }; | 111 }; |
| 106 | 112 |
| 107 } // namespace chromeos | 113 } // namespace chromeos |
| 108 | 114 |
| 109 #endif // CHROMEOS_TIMEZONE_TIMEZONE_RESOLVER_H_ | 115 #endif // CHROMEOS_TIMEZONE_TIMEZONE_RESOLVER_H_ |
| OLD | NEW |