Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11197)

Unified Diff: content/browser/geolocation/wifi_data_provider.cc

Issue 23819030: Move WifiDataProvider implementation out of header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/geolocation/wifi_data_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/geolocation/wifi_data_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698