Chromium Code Reviews| 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 // 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 return listeners_.erase(listener) == 1; | 119 return listeners_.erase(listener) == 1; |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool has_listeners() const { | 122 bool has_listeners() const { |
| 123 DCHECK(CalledOnClientThread()); | 123 DCHECK(CalledOnClientThread()); |
| 124 return !listeners_.empty(); | 124 return !listeners_.empty(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 protected: | 127 protected: |
| 128 virtual ~DeviceDataProviderImplBase() { | 128 virtual ~DeviceDataProviderImplBase() { |
| 129 DCHECK(CalledOnClientThread()); | |
|
jam
2013/01/04 19:01:18
this is needed because in some tests, there are ou
| |
| 130 } | 129 } |
| 131 | 130 |
| 132 // Calls DeviceDataUpdateAvailable() on all registered listeners. | 131 // Calls DeviceDataUpdateAvailable() on all registered listeners. |
| 133 typedef std::set<ListenerInterface*> ListenersSet; | 132 typedef std::set<ListenerInterface*> ListenersSet; |
| 134 void NotifyListeners() { | 133 void NotifyListeners() { |
| 135 // Always make the notify callback via a posted task, so we can unwind | 134 // Always make the notify callback via a posted task, so we can unwind |
| 136 // callstack here and make callback without causing client re-entrancy. | 135 // callstack here and make callback without causing client re-entrancy. |
| 137 client_loop_->PostTask(FROM_HERE, base::Bind( | 136 client_loop_->PostTask(FROM_HERE, base::Bind( |
| 138 &DeviceDataProviderImplBase<DataType>::NotifyListenersInClientLoop, | 137 &DeviceDataProviderImplBase<DataType>::NotifyListenersInClientLoop, |
| 139 this)); | 138 this)); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 scoped_refptr<DeviceDataProviderImplBase<DataType> > impl_; | 299 scoped_refptr<DeviceDataProviderImplBase<DataType> > impl_; |
| 301 | 300 |
| 302 DISALLOW_COPY_AND_ASSIGN(DeviceDataProvider); | 301 DISALLOW_COPY_AND_ASSIGN(DeviceDataProvider); |
| 303 }; | 302 }; |
| 304 | 303 |
| 305 typedef DeviceDataProvider<WifiData> WifiDataProvider; | 304 typedef DeviceDataProvider<WifiData> WifiDataProvider; |
| 306 | 305 |
| 307 } // namespace content | 306 } // namespace content |
| 308 | 307 |
| 309 #endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_ | 308 #endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_ |
| OLD | NEW |