| 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 #include "chromeos/timezone/timezone_resolver.h" | 5 #include "chromeos/timezone/timezone_resolver.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 DISALLOW_COPY_AND_ASSIGN(TZRequest); | 176 DISALLOW_COPY_AND_ASSIGN(TZRequest); |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 TZRequest::~TZRequest() { | 179 TZRequest::~TZRequest() { |
| 180 } | 180 } |
| 181 | 181 |
| 182 void TZRequest::StartRequestOnNetworkAvailable() { | 182 void TZRequest::StartRequestOnNetworkAvailable() { |
| 183 resolver_->RecordAttempt(); | 183 resolver_->RecordAttempt(); |
| 184 resolver_->geolocation_provider()->RequestGeolocation( | 184 resolver_->geolocation_provider()->RequestGeolocation( |
| 185 base::TimeDelta::FromSeconds(kRefreshTimeZoneTimeoutSeconds), | 185 base::TimeDelta::FromSeconds(kRefreshTimeZoneTimeoutSeconds), |
| 186 false /* send_wifi_geolocation_data */, |
| 186 base::Bind(&TZRequest::OnLocationResolved, AsWeakPtr())); | 187 base::Bind(&TZRequest::OnLocationResolved, AsWeakPtr())); |
| 187 } | 188 } |
| 188 | 189 |
| 189 void TZRequest::Start() { | 190 void TZRequest::Start() { |
| 190 // call to chromeos::DelayNetworkCall | 191 // call to chromeos::DelayNetworkCall |
| 191 resolver_->delay_network_call().Run( | 192 resolver_->delay_network_call().Run( |
| 192 base::Bind(&TZRequest::StartRequestOnNetworkAvailable, AsWeakPtr())); | 193 base::Bind(&TZRequest::StartRequestOnNetworkAvailable, AsWeakPtr())); |
| 193 } | 194 } |
| 194 | 195 |
| 195 void TZRequest::OnLocationResolved(const Geoposition& position, | 196 void TZRequest::OnLocationResolved(const Geoposition& position, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 TimeZoneResolver::TimeZoneResolver( | 377 TimeZoneResolver::TimeZoneResolver( |
| 377 scoped_refptr<net::URLRequestContextGetter> context, | 378 scoped_refptr<net::URLRequestContextGetter> context, |
| 378 const GURL& url, | 379 const GURL& url, |
| 379 const ApplyTimeZoneCallback& apply_timezone, | 380 const ApplyTimeZoneCallback& apply_timezone, |
| 380 const DelayNetworkCallClosure& delay_network_call, | 381 const DelayNetworkCallClosure& delay_network_call, |
| 381 PrefService* local_state) | 382 PrefService* local_state) |
| 382 : context_(context), | 383 : context_(context), |
| 383 url_(url), | 384 url_(url), |
| 384 apply_timezone_(apply_timezone), | 385 apply_timezone_(apply_timezone), |
| 385 delay_network_call_(delay_network_call), | 386 delay_network_call_(delay_network_call), |
| 386 local_state_(local_state) { | 387 local_state_(local_state), |
| 388 send_wifi_data_to_geolocation_api_(false) { |
| 387 DCHECK(!apply_timezone.is_null()); | 389 DCHECK(!apply_timezone.is_null()); |
| 388 } | 390 } |
| 389 | 391 |
| 390 TimeZoneResolver::~TimeZoneResolver() { | 392 TimeZoneResolver::~TimeZoneResolver() { |
| 391 Stop(); | 393 Stop(); |
| 392 } | 394 } |
| 393 | 395 |
| 394 void TimeZoneResolver::Start() { | 396 void TimeZoneResolver::Start() { |
| 395 DCHECK(thread_checker_.CalledOnValidThread()); | 397 DCHECK(thread_checker_.CalledOnValidThread()); |
| 396 if (!implementation_) { | 398 if (!implementation_) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 414 int TimeZoneResolver::IntervalForNextRequestForTesting(const int requests) { | 416 int TimeZoneResolver::IntervalForNextRequestForTesting(const int requests) { |
| 415 return IntervalForNextRequest(requests); | 417 return IntervalForNextRequest(requests); |
| 416 } | 418 } |
| 417 | 419 |
| 418 // static | 420 // static |
| 419 void TimeZoneResolver::RegisterPrefs(PrefRegistrySimple* registry) { | 421 void TimeZoneResolver::RegisterPrefs(PrefRegistrySimple* registry) { |
| 420 registry->RegisterInt64Pref(kLastTimeZoneRefreshTime, 0); | 422 registry->RegisterInt64Pref(kLastTimeZoneRefreshTime, 0); |
| 421 } | 423 } |
| 422 | 424 |
| 423 } // namespace chromeos | 425 } // namespace chromeos |
| OLD | NEW |