OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 186 } |
187 | 187 |
188 protected: | 188 protected: |
189 virtual ~DeviceDataProviderImplBase() { | 189 virtual ~DeviceDataProviderImplBase() { |
190 DCHECK(CalledOnClientThread()); | 190 DCHECK(CalledOnClientThread()); |
191 } | 191 } |
192 | 192 |
193 // Calls DeviceDataUpdateAvailable() on all registered listeners. | 193 // Calls DeviceDataUpdateAvailable() on all registered listeners. |
194 typedef std::set<ListenerInterface*> ListenersSet; | 194 typedef std::set<ListenerInterface*> ListenersSet; |
195 void NotifyListeners() { | 195 void NotifyListeners() { |
196 // Always make the nitofy callback via a posted task, se we can unwind | 196 // Always make the notify callback via a posted task, so we can unwind |
197 // callstack here and make callback without causing client re-entrancy. | 197 // callstack here and make callback without causing client re-entrancy. |
198 client_loop_->PostTask(FROM_HERE, base::Bind( | 198 client_loop_->PostTask(FROM_HERE, base::Bind( |
199 &DeviceDataProviderImplBase<DataType>::NotifyListenersInClientLoop, | 199 &DeviceDataProviderImplBase<DataType>::NotifyListenersInClientLoop, |
200 this)); | 200 this)); |
201 } | 201 } |
202 | 202 |
203 bool CalledOnClientThread() const { | 203 bool CalledOnClientThread() const { |
204 return MessageLoop::current() == this->client_loop_; | 204 return MessageLoop::current() == this->client_loop_; |
205 } | 205 } |
206 | 206 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // The internal implementation. | 361 // The internal implementation. |
362 scoped_refptr<DeviceDataProviderImplBase<DataType> > impl_; | 362 scoped_refptr<DeviceDataProviderImplBase<DataType> > impl_; |
363 | 363 |
364 DISALLOW_COPY_AND_ASSIGN(DeviceDataProvider); | 364 DISALLOW_COPY_AND_ASSIGN(DeviceDataProvider); |
365 }; | 365 }; |
366 | 366 |
367 typedef DeviceDataProvider<RadioData> RadioDataProvider; | 367 typedef DeviceDataProvider<RadioData> RadioDataProvider; |
368 typedef DeviceDataProvider<WifiData> WifiDataProvider; | 368 typedef DeviceDataProvider<WifiData> WifiDataProvider; |
369 | 369 |
370 #endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_ | 370 #endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_ |
OLD | NEW |