| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // A device data provider provides data from the device that is used by a | 5 // A device data provider provides data from the device that is used by a |
| 6 // NetworkLocationProvider to obtain a position fix. This data may be either | 6 // NetworkLocationProvider to obtain a position fix. This data may be either |
| 7 // cell radio data or wifi data. For a given type of data, we use a singleton | 7 // cell radio data or wifi data. For a given type of data, we use a singleton |
| 8 // instance of the device data provider, which is used by multiple | 8 // instance of the device data provider, which is used by multiple |
| 9 // NetworkLocationProvider objects. | 9 // NetworkLocationProvider objects. |
| 10 // | 10 // |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // Always make the nitofy callback via a posted task, se we can unwind | 223 // Always make the nitofy callback via a posted task, se we can unwind |
| 224 // callstack here and make callback without causing client re-entrancy. | 224 // callstack here and make callback without causing client re-entrancy. |
| 225 client_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 225 client_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, |
| 226 &DeviceDataProviderImplBase<DataType>::NotifyListenersInClientLoop)); | 226 &DeviceDataProviderImplBase<DataType>::NotifyListenersInClientLoop)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 bool CalledOnClientThread() const { | 229 bool CalledOnClientThread() const { |
| 230 return MessageLoop::current() == this->client_loop_; | 230 return MessageLoop::current() == this->client_loop_; |
| 231 } | 231 } |
| 232 | 232 |
| 233 MessageLoop* client_loop() const { |
| 234 return client_loop_; |
| 235 } |
| 236 |
| 233 private: | 237 private: |
| 234 void NotifyListenersInClientLoop() { | 238 void NotifyListenersInClientLoop() { |
| 235 DCHECK(CalledOnClientThread()); | 239 DCHECK(CalledOnClientThread()); |
| 236 // It's possible that all the listeners (and the container) went away | 240 // It's possible that all the listeners (and the container) went away |
| 237 // whilst this task was pending. This is fine; the loop will be a no-op. | 241 // whilst this task was pending. This is fine; the loop will be a no-op. |
| 238 typename ListenersSet::const_iterator iter = listeners_.begin(); | 242 typename ListenersSet::const_iterator iter = listeners_.begin(); |
| 239 while (iter != listeners_.end()) { | 243 while (iter != listeners_.end()) { |
| 240 ListenerInterface* listener = *iter; | 244 ListenerInterface* listener = *iter; |
| 241 ++iter; // Advance iter before callback, in case listener unregisters. | 245 ++iter; // Advance iter before callback, in case listener unregisters. |
| 242 listener->DeviceDataUpdateAvailable(container_); | 246 listener->DeviceDataUpdateAvailable(container_); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 // static | 397 // static |
| 394 template<typename DataType> | 398 template<typename DataType> |
| 395 typename DeviceDataProvider<DataType>::ImplFactoryFunction | 399 typename DeviceDataProvider<DataType>::ImplFactoryFunction |
| 396 DeviceDataProvider<DataType>::factory_function_ = DefaultFactoryFunction; | 400 DeviceDataProvider<DataType>::factory_function_ = DefaultFactoryFunction; |
| 397 | 401 |
| 398 typedef DeviceDataProvider<GatewayData> GatewayDataProvider; | 402 typedef DeviceDataProvider<GatewayData> GatewayDataProvider; |
| 399 typedef DeviceDataProvider<RadioData> RadioDataProvider; | 403 typedef DeviceDataProvider<RadioData> RadioDataProvider; |
| 400 typedef DeviceDataProvider<WifiData> WifiDataProvider; | 404 typedef DeviceDataProvider<WifiData> WifiDataProvider; |
| 401 | 405 |
| 402 #endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_ | 406 #endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_ |
| OLD | NEW |