| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 DCHECK(this->CalledOnValidThread()); | 246 DCHECK(this->CalledOnValidThread()); |
| 247 return impl_->GetData(data); | 247 return impl_->GetData(data); |
| 248 } | 248 } |
| 249 | 249 |
| 250 private: | 250 private: |
| 251 // Private constructor and destructor, callers access singleton through | 251 // Private constructor and destructor, callers access singleton through |
| 252 // Register and Unregister. | 252 // Register and Unregister. |
| 253 DeviceDataProvider() { | 253 DeviceDataProvider() { |
| 254 DCHECK(factory_function_); | 254 DCHECK(factory_function_); |
| 255 impl_ = (*factory_function_)(); | 255 impl_ = (*factory_function_)(); |
| 256 DCHECK(impl_); | 256 DCHECK(impl_.get()); |
| 257 impl_->SetContainer(this); | 257 impl_->SetContainer(this); |
| 258 } | 258 } |
| 259 virtual ~DeviceDataProvider() { | 259 virtual ~DeviceDataProvider() { |
| 260 DCHECK(impl_); | 260 DCHECK(impl_.get()); |
| 261 impl_->SetContainer(NULL); | 261 impl_->SetContainer(NULL); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void AddListener(ListenerInterface* listener) { | 264 void AddListener(ListenerInterface* listener) { |
| 265 impl_->AddListener(listener); | 265 impl_->AddListener(listener); |
| 266 } | 266 } |
| 267 | 267 |
| 268 bool RemoveListener(ListenerInterface* listener) { | 268 bool RemoveListener(ListenerInterface* listener) { |
| 269 return impl_->RemoveListener(listener); | 269 return impl_->RemoveListener(listener); |
| 270 } | 270 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 296 scoped_refptr<DeviceDataProviderImplBase<DataType> > impl_; | 296 scoped_refptr<DeviceDataProviderImplBase<DataType> > impl_; |
| 297 | 297 |
| 298 DISALLOW_COPY_AND_ASSIGN(DeviceDataProvider); | 298 DISALLOW_COPY_AND_ASSIGN(DeviceDataProvider); |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 typedef DeviceDataProvider<WifiData> WifiDataProvider; | 301 typedef DeviceDataProvider<WifiData> WifiDataProvider; |
| 302 | 302 |
| 303 } // namespace content | 303 } // namespace content |
| 304 | 304 |
| 305 #endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_ | 305 #endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_ |
| OLD | NEW |