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

Side by Side Diff: content/browser/geolocation/wifi_data_provider_manager.cc

Issue 486203004: Clean up WifiDataProvider(Manager) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/geolocation/wifi_data_provider_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/browser/geolocation/wifi_data_provider_manager.h" 5 #include "content/browser/geolocation/wifi_data_provider_manager.h"
6 6
7 #include "content/browser/geolocation/wifi_data_provider.h" 7 #include "content/browser/geolocation/wifi_data_provider.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 // static 11 // static
12 WifiDataProviderManager* WifiDataProviderManager::instance_ = NULL; 12 WifiDataProviderManager* WifiDataProviderManager::instance_ = NULL;
13 13
14 // static 14 // static
15 WifiDataProviderManager::ImplFactoryFunction 15 WifiDataProviderManager::ImplFactoryFunction
16 WifiDataProviderManager::factory_function_ = DefaultFactoryFunction; 16 WifiDataProviderManager::factory_function_ = DefaultFactoryFunction;
17 17
18 // static 18 // static
19 void WifiDataProviderManager::SetFactory( 19 void WifiDataProviderManager::SetFactoryForTesting(
20 ImplFactoryFunction factory_function_in) { 20 ImplFactoryFunction factory_function_in) {
21 factory_function_ = factory_function_in; 21 factory_function_ = factory_function_in;
22 } 22 }
23 23
24 // static 24 // static
25 void WifiDataProviderManager::ResetFactory() { 25 void WifiDataProviderManager::ResetFactoryForTesting() {
26 factory_function_ = DefaultFactoryFunction; 26 factory_function_ = DefaultFactoryFunction;
27 } 27 }
28 28
29 // static 29 // static
30 WifiDataProviderManager* WifiDataProviderManager::Register( 30 WifiDataProviderManager* WifiDataProviderManager::Register(
31 WifiDataUpdateCallback* callback) { 31 WifiDataUpdateCallback* callback) {
32 bool need_to_start_data_provider = false; 32 bool need_to_start_data_provider = false;
33 if (!instance_) { 33 if (!instance_) {
34 instance_ = new WifiDataProviderManager(); 34 instance_ = new WifiDataProviderManager();
35 need_to_start_data_provider = true; 35 need_to_start_data_provider = true;
(...skipping 22 matching lines...) Expand all
58 delete instance_; 58 delete instance_;
59 instance_ = NULL; 59 instance_ = NULL;
60 } 60 }
61 return true; 61 return true;
62 } 62 }
63 63
64 WifiDataProviderManager::WifiDataProviderManager() { 64 WifiDataProviderManager::WifiDataProviderManager() {
65 DCHECK(factory_function_); 65 DCHECK(factory_function_);
66 impl_ = (*factory_function_)(); 66 impl_ = (*factory_function_)();
67 DCHECK(impl_.get()); 67 DCHECK(impl_.get());
68 impl_->SetContainer(this);
69 } 68 }
70 69
71 WifiDataProviderManager::~WifiDataProviderManager() { 70 WifiDataProviderManager::~WifiDataProviderManager() {
timvolodine 2014/08/20 16:05:40 does it still need a DCHECK(impl_)?
Michael van Ouwerkerk 2014/08/21 15:46:23 Yes, looks like I was overzealous with the delete
72 DCHECK(impl_.get());
73 impl_->SetContainer(NULL);
74 } 71 }
75 72
76 bool WifiDataProviderManager::GetData(WifiData* data) { 73 bool WifiDataProviderManager::GetData(WifiData* data) {
77 return impl_->GetData(data); 74 return impl_->GetData(data);
78 } 75 }
79 76
80 void WifiDataProviderManager::AddCallback(WifiDataUpdateCallback* callback) { 77 void WifiDataProviderManager::AddCallback(WifiDataUpdateCallback* callback) {
81 impl_->AddCallback(callback); 78 impl_->AddCallback(callback);
82 } 79 }
83 80
84 bool WifiDataProviderManager::RemoveCallback(WifiDataUpdateCallback* callback) { 81 bool WifiDataProviderManager::RemoveCallback(WifiDataUpdateCallback* callback) {
85 return impl_->RemoveCallback(callback); 82 return impl_->RemoveCallback(callback);
86 } 83 }
87 84
88 bool WifiDataProviderManager::has_callbacks() const { 85 bool WifiDataProviderManager::has_callbacks() const {
89 return impl_->has_callbacks(); 86 return impl_->has_callbacks();
90 } 87 }
91 88
92 void WifiDataProviderManager::StartDataProvider() { 89 void WifiDataProviderManager::StartDataProvider() {
93 impl_->StartDataProvider(); 90 impl_->StartDataProvider();
94 } 91 }
95 92
96 void WifiDataProviderManager::StopDataProvider() { 93 void WifiDataProviderManager::StopDataProvider() {
97 impl_->StopDataProvider(); 94 impl_->StopDataProvider();
98 } 95 }
99 96
100 } // namespace content 97 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/geolocation/wifi_data_provider_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698