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

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

Issue 486203004: Clean up WifiDataProvider(Manager) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't delete the DCHECK 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
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 // A wifi data provider provides wifi data from the device that is used by a 5 // A wifi data provider provides wifi data from the device that is used by a
6 // NetworkLocationProvider to obtain a position fix. We use a singleton 6 // NetworkLocationProvider to obtain a position fix. We use a singleton
7 // instance of the wifi data provider manager, which is used by multiple 7 // instance of the wifi data provider manager, which is used by multiple
8 // NetworkLocationProvider objects. 8 // NetworkLocationProvider objects.
9 // 9 //
10 // This file provides WifiDataProviderManager, which provides static methods to 10 // This file provides WifiDataProviderManager, which provides static methods to
(...skipping 20 matching lines...) Expand all
31 31
32 class WifiDataProvider; 32 class WifiDataProvider;
33 33
34 // A manager for wifi data providers. 34 // A manager for wifi data providers.
35 // 35 //
36 // We use a singleton instance of this class which is shared by multiple network 36 // We use a singleton instance of this class which is shared by multiple network
37 // location providers. These location providers access the instance through the 37 // location providers. These location providers access the instance through the
38 // Register and Unregister methods. 38 // Register and Unregister methods.
39 class CONTENT_EXPORT WifiDataProviderManager { 39 class CONTENT_EXPORT WifiDataProviderManager {
40 public: 40 public:
41 typedef WifiDataProvider* (*ImplFactoryFunction)(void);
42
41 // Sets the factory function which will be used by Register to create the 43 // Sets the factory function which will be used by Register to create the
42 // implementation used by the singleton instance. This factory approach is 44 // implementation used by the singleton instance. This factory approach is
43 // used both to abstract accross platform-specific implementations and to 45 // used both to abstract accross platform-specific implementations and to
44 // inject mock implementations for testing. 46 // inject mock implementations for testing.
45 typedef WifiDataProvider* (*ImplFactoryFunction)(void); 47 static void SetFactoryForTesting(ImplFactoryFunction factory_function_in);
46 static void SetFactory(ImplFactoryFunction factory_function_in);
47 48
48 // Resets the factory function to the default. 49 // Resets the factory function to the default.
49 static void ResetFactory(); 50 static void ResetFactoryForTesting();
50 51
51 typedef base::Callback<void(WifiDataProviderManager*)> WifiDataUpdateCallback; 52 typedef base::Closure WifiDataUpdateCallback;
52 53
53 // Registers a callback, which will be run whenever new data is available. 54 // Registers a callback, which will be run whenever new data is available.
54 // Instantiates the singleton if necessary, and always returns it. 55 // Instantiates the singleton if necessary, and always returns it.
55 static WifiDataProviderManager* Register(WifiDataUpdateCallback* callback); 56 static WifiDataProviderManager* Register(WifiDataUpdateCallback* callback);
56 57
57 // Removes a callback. If this is the last callback, deletes the singleton 58 // Removes a callback. If this is the last callback, deletes the singleton
58 // instance. Return value indicates success. 59 // instance. Return value indicates success.
59 static bool Unregister(WifiDataUpdateCallback* callback); 60 static bool Unregister(WifiDataUpdateCallback* callback);
60 61
61 // Provides whatever data the provider has, which may be nothing. Return 62 // Provides whatever data the provider has, which may be nothing. Return
(...skipping 26 matching lines...) Expand all
88 89
89 // The internal implementation. 90 // The internal implementation.
90 scoped_refptr<WifiDataProvider> impl_; 91 scoped_refptr<WifiDataProvider> impl_;
91 92
92 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderManager); 93 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderManager);
93 }; 94 };
94 95
95 } // namespace content 96 } // namespace content
96 97
97 #endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_MANAGER_H_ 98 #endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698