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 "device/geolocation/network_location_provider.h" | 5 #include "device/geolocation/network_location_provider.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
13 #include "device/geolocation/access_token_store.h" | 15 #include "device/geolocation/access_token_store.h" |
14 | 16 |
15 namespace device { | 17 namespace device { |
16 namespace { | 18 namespace { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 url_context_getter, url, | 123 url_context_getter, url, |
122 base::Bind(&NetworkLocationProvider::OnLocationResponse, | 124 base::Bind(&NetworkLocationProvider::OnLocationResponse, |
123 base::Unretained(this)))); | 125 base::Unretained(this)))); |
124 } | 126 } |
125 | 127 |
126 NetworkLocationProvider::~NetworkLocationProvider() { | 128 NetworkLocationProvider::~NetworkLocationProvider() { |
127 StopProvider(); | 129 StopProvider(); |
128 } | 130 } |
129 | 131 |
130 // LocationProvider implementation | 132 // LocationProvider implementation |
131 void NetworkLocationProvider::GetPosition(Geoposition* position) { | 133 const Geoposition& NetworkLocationProvider::GetPosition() { |
132 DCHECK(position); | 134 return position_; |
133 *position = position_; | |
134 } | 135 } |
135 | 136 |
136 void NetworkLocationProvider::RequestRefresh() { | 137 void NetworkLocationProvider::RequestRefresh() { |
137 // TODO(joth): When called via the public (base class) interface, this should | 138 // TODO(joth): When called via the public (base class) interface, this should |
138 // poke each data provider to get them to expedite their next scan. | 139 // poke each data provider to get them to expedite their next scan. |
139 // Whilst in the delayed start, only send request if all data is ready. | 140 // Whilst in the delayed start, only send request if all data is ready. |
140 // TODO(mcasas): consider not using HasWeakPtrs() https://crbug.com/629158. | 141 // TODO(mcasas): consider not using HasWeakPtrs() https://crbug.com/629158. |
141 if (!weak_factory_.HasWeakPtrs() || is_wifi_data_complete_) { | 142 if (!weak_factory_.HasWeakPtrs() || is_wifi_data_complete_) { |
142 RequestPosition(); | 143 RequestPosition(); |
143 } | 144 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 << wifi_data_.access_point_data.size(); | 263 << wifi_data_.access_point_data.size(); |
263 } | 264 } |
264 request_->MakeRequest(access_token_, wifi_data_, wifi_timestamp_); | 265 request_->MakeRequest(access_token_, wifi_data_, wifi_timestamp_); |
265 } | 266 } |
266 | 267 |
267 bool NetworkLocationProvider::IsStarted() const { | 268 bool NetworkLocationProvider::IsStarted() const { |
268 return wifi_data_provider_manager_ != nullptr; | 269 return wifi_data_provider_manager_ != nullptr; |
269 } | 270 } |
270 | 271 |
271 } // namespace device | 272 } // namespace device |
OLD | NEW |