Index: content/browser/geolocation/wifi_data_provider.cc |
diff --git a/content/browser/geolocation/wifi_data_provider.cc b/content/browser/geolocation/wifi_data_provider.cc |
index 416ecb8e52f1cea08ba091cdd9cb43769a2ba8da..85595f927ab8b43b507eb628df471f7fff94624f 100644 |
--- a/content/browser/geolocation/wifi_data_provider.cc |
+++ b/content/browser/geolocation/wifi_data_provider.cc |
@@ -14,6 +14,16 @@ WifiDataProvider::ImplFactoryFunction WifiDataProvider::factory_function_ = |
DefaultFactoryFunction; |
// static |
+void WifiDataProvider::SetFactory(ImplFactoryFunction factory_function_in) { |
+ factory_function_ = factory_function_in; |
+} |
+ |
+// static |
+void WifiDataProvider::ResetFactory() { |
+ factory_function_ = DefaultFactoryFunction; |
+} |
+ |
+// static |
WifiDataProvider* WifiDataProvider::Register(WifiDataUpdateCallback* callback) { |
bool need_to_start_data_provider = false; |
if (!instance_) { |
@@ -29,6 +39,24 @@ WifiDataProvider* WifiDataProvider::Register(WifiDataUpdateCallback* callback) { |
return instance_; |
} |
+// static |
+bool WifiDataProvider::Unregister(WifiDataUpdateCallback* callback) { |
+ DCHECK(instance_); |
+ DCHECK(instance_->has_callbacks()); |
+ if (!instance_->RemoveCallback(callback)) { |
+ return false; |
+ } |
+ if (!instance_->has_callbacks()) { |
+ // Must stop the data provider (and any implementation threads) before |
+ // destroying to avoid any race conditions in access to the provider in |
+ // the destructor chain. |
+ instance_->StopDataProvider(); |
+ delete instance_; |
+ instance_ = NULL; |
+ } |
+ return true; |
+} |
+ |
WifiDataProviderImplBase::WifiDataProviderImplBase() |
: container_(NULL), |
client_loop_(base::MessageLoop::current()) { |
@@ -92,4 +120,28 @@ WifiDataProvider::~WifiDataProvider() { |
impl_->SetContainer(NULL); |
} |
+bool WifiDataProvider::GetData(WifiData* data) { |
+ return impl_->GetData(data); |
+} |
+ |
+void WifiDataProvider::AddCallback(WifiDataUpdateCallback* callback) { |
+ impl_->AddCallback(callback); |
+} |
+ |
+bool WifiDataProvider::RemoveCallback(WifiDataUpdateCallback* callback) { |
+ return impl_->RemoveCallback(callback); |
+} |
+ |
+bool WifiDataProvider::has_callbacks() const { |
+ return impl_->has_callbacks(); |
+} |
+ |
+void WifiDataProvider::StartDataProvider() { |
+ impl_->StartDataProvider(); |
+} |
+ |
+void WifiDataProvider::StopDataProvider() { |
+ impl_->StopDataProvider(); |
+} |
+ |
} // namespace content |