X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcontent%2Fbrowser%2Fgeolocation%2Fwifi_data_provider.h;h=98d22963e9f7a074e4a254ca3d7194abacd716b6;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=bfb06ec54446962381dfaea0818ce3edf6b07a69;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/content/browser/geolocation/wifi_data_provider.h b/src/content/browser/geolocation/wifi_data_provider.h index bfb06ec..98d2296 100644 --- a/src/content/browser/geolocation/wifi_data_provider.h +++ b/src/content/browser/geolocation/wifi_data_provider.h @@ -2,19 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// A wifi data provider provides wifi data from the device that is used by a -// NetworkLocationProvider to obtain a position fix. We use a singleton -// instance of the wifi data provider, which is used by multiple -// NetworkLocationProvider objects. -// -// This file provides WifiDataProvider, which provides static methods to -// access the singleton instance. The singleton instance uses a private -// implementation to abstract across platforms and also to allow mock providers -// to be used for testing. -// -// This file also provides WifiDataProviderImplBase, a base class which -// provides common functionality for the private implementations. - #ifndef CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_H_ #define CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_H_ @@ -32,16 +19,10 @@ namespace content { -class WifiDataProvider; - -// See class WifiDataProvider for the public client API. -// WifiDataProvider uses containment to hide platform-specific implementation -// details from common code. This class provides common functionality for these -// contained implementation classes. This is a modified pimpl pattern. -class CONTENT_EXPORT WifiDataProviderImplBase - : public base::RefCountedThreadSafe { +class CONTENT_EXPORT WifiDataProvider + : public base::RefCountedThreadSafe { public: - WifiDataProviderImplBase(); + WifiDataProvider(); // Tells the provider to start looking for data. Callbacks will start // receiving notifications after this call. @@ -56,11 +37,7 @@ class CONTENT_EXPORT WifiDataProviderImplBase // obtain. virtual bool GetData(WifiData* data) = 0; - // Sets the container of this class, which is of type WifiDataProvider. - // This is required to pass as a parameter when calling a callback. - void SetContainer(WifiDataProvider* container); - - typedef base::Callback WifiDataUpdateCallback; + typedef base::Closure WifiDataUpdateCallback; void AddCallback(WifiDataUpdateCallback* callback); @@ -69,8 +46,8 @@ class CONTENT_EXPORT WifiDataProviderImplBase bool has_callbacks() const; protected: - friend class base::RefCountedThreadSafe; - virtual ~WifiDataProviderImplBase(); + friend class base::RefCountedThreadSafe; + virtual ~WifiDataProvider(); typedef std::set CallbackSet; @@ -85,75 +62,12 @@ class CONTENT_EXPORT WifiDataProviderImplBase private: void DoRunCallbacks(); - WifiDataProvider* container_; - // Reference to the client's message loop. All callbacks should happen in this // context. base::MessageLoop* client_loop_; CallbackSet callbacks_; - DISALLOW_COPY_AND_ASSIGN(WifiDataProviderImplBase); -}; - -// A wifi data provider -// -// We use a singleton instance of this class which is shared by multiple network -// location providers. These location providers access the instance through the -// Register and Unregister methods. -class CONTENT_EXPORT WifiDataProvider { - public: - // Sets the factory function which will be used by Register to create the - // implementation used by the singleton instance. This factory approach is - // used both to abstract accross platform-specific implementations and to - // inject mock implementations for testing. - typedef WifiDataProviderImplBase* (*ImplFactoryFunction)(void); - static void SetFactory(ImplFactoryFunction factory_function_in); - - // Resets the factory function to the default. - static void ResetFactory(); - - typedef base::Callback WifiDataUpdateCallback; - - // Registers a callback, which will be run whenever new data is available. - // Instantiates the singleton if necessary, and always returns it. - static WifiDataProvider* Register(WifiDataUpdateCallback* callback); - - // Removes a callback. If this is the last callback, deletes the singleton - // instance. Return value indicates success. - static bool Unregister(WifiDataUpdateCallback* callback); - - // Provides whatever data the provider has, which may be nothing. Return - // value indicates whether this is all the data the provider could ever - // obtain. - bool GetData(WifiData* data); - - private: - // Private constructor and destructor, callers access singleton through - // Register and Unregister. - WifiDataProvider(); - virtual ~WifiDataProvider(); - - void AddCallback(WifiDataUpdateCallback* callback); - bool RemoveCallback(WifiDataUpdateCallback* callback); - bool has_callbacks() const; - - void StartDataProvider(); - void StopDataProvider(); - - static WifiDataProviderImplBase* DefaultFactoryFunction(); - - // The singleton-like instance of this class. (Not 'true' singleton, as it - // may go through multiple create/destroy/create cycles per process instance, - // e.g. when under test). - static WifiDataProvider* instance_; - - // The factory function used to create the singleton instance. - static ImplFactoryFunction factory_function_; - - // The internal implementation. - scoped_refptr impl_; - DISALLOW_COPY_AND_ASSIGN(WifiDataProvider); };