| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/geolocation/location_arbitrator_impl.h" | 5 #include "content/browser/geolocation/location_arbitrator_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/browser/geolocation/network_location_provider.h" | 13 #include "content/browser/geolocation/network_location_provider.h" |
| 14 #include "content/public/browser/access_token_store.h" | 14 #include "content/public/browser/access_token_store.h" |
| 15 #include "content/public/browser/geolocation_delegate.h" |
| 15 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 const char* kDefaultNetworkProviderUrl = | 22 const char* kDefaultNetworkProviderUrl = |
| 22 "https://www.googleapis.com/geolocation/v1/geolocate"; | 23 "https://www.googleapis.com/geolocation/v1/geolocate"; |
| 23 } // namespace | 24 } // namespace |
| 24 | 25 |
| 25 // To avoid oscillations, set this to twice the expected update interval of a | 26 // To avoid oscillations, set this to twice the expected update interval of a |
| 26 // a GPS-type location provider (in case it misses a beat) plus a little. | 27 // a GPS-type location provider (in case it misses a beat) plus a little. |
| 27 const int64_t LocationArbitratorImpl::kFixStaleTimeoutMilliseconds = | 28 const int64_t LocationArbitratorImpl::kFixStaleTimeoutMilliseconds = |
| 28 11 * base::Time::kMillisecondsPerSecond; | 29 11 * base::Time::kMillisecondsPerSecond; |
| 29 | 30 |
| 30 LocationArbitratorImpl::LocationArbitratorImpl( | 31 LocationArbitratorImpl::LocationArbitratorImpl( |
| 31 const LocationUpdateCallback& callback, | 32 const LocationUpdateCallback& callback, |
| 32 GeolocationProvider::Delegate* delegate) | 33 GeolocationDelegate* delegate) |
| 33 : delegate_(delegate), | 34 : delegate_(delegate), |
| 34 arbitrator_update_callback_(callback), | 35 arbitrator_update_callback_(callback), |
| 35 provider_update_callback_( | 36 provider_update_callback_( |
| 36 base::Bind(&LocationArbitratorImpl::OnLocationUpdate, | 37 base::Bind(&LocationArbitratorImpl::OnLocationUpdate, |
| 37 base::Unretained(this))), | 38 base::Unretained(this))), |
| 38 position_provider_(NULL), | 39 position_provider_(NULL), |
| 39 is_permission_granted_(false), | 40 is_permission_granted_(false), |
| 40 is_running_(false) {} | 41 is_running_(false) {} |
| 41 | 42 |
| 42 LocationArbitratorImpl::~LocationArbitratorImpl() { | 43 LocationArbitratorImpl::~LocationArbitratorImpl() { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 203 } |
| 203 } | 204 } |
| 204 return false; | 205 return false; |
| 205 } | 206 } |
| 206 | 207 |
| 207 bool LocationArbitratorImpl::HasPermissionBeenGranted() const { | 208 bool LocationArbitratorImpl::HasPermissionBeenGranted() const { |
| 208 return is_permission_granted_; | 209 return is_permission_granted_; |
| 209 } | 210 } |
| 210 | 211 |
| 211 } // namespace content | 212 } // namespace content |
| OLD | NEW |