Remove implicit conversions from scoped_refptr to T* in content/browser/service_worker
[chromium-blink-merge.git] / content / browser / geolocation / wifi_data_provider_common.h
blobb9a91e18b77b3806b37e2b005781440e3d50b58f
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_
6 #define CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_
8 #include <assert.h>
10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "content/browser/geolocation/wifi_data_provider.h"
15 #include "content/browser/geolocation/wifi_polling_policy.h"
16 #include "content/common/content_export.h"
18 namespace content {
20 // Converts a MAC address stored as an array of uint8 to a string.
21 base::string16 MacAddressAsString16(const uint8 mac_as_int[6]);
23 // Base class to promote code sharing between platform specific wifi data
24 // providers. It's optional for specific platforms to derive this, but if they
25 // do polling behavior is taken care of by this base class, and all the platform
26 // need do is provide the underlying WLAN access API and polling policy.
27 // Also designed this way for ease of testing the cross-platform behavior.
28 class CONTENT_EXPORT WifiDataProviderCommon : public WifiDataProvider {
29 public:
30 // Interface to abstract the low level data OS library call, and to allow
31 // mocking (hence public).
32 class WlanApiInterface {
33 public:
34 virtual ~WlanApiInterface() {}
35 // Gets wifi data for all visible access points.
36 virtual bool GetAccessPointData(WifiData::AccessPointDataSet* data) = 0;
39 WifiDataProviderCommon();
41 // WifiDataProvider implementation
42 virtual void StartDataProvider() OVERRIDE;
43 virtual void StopDataProvider() OVERRIDE;
44 virtual bool GetData(WifiData* data) OVERRIDE;
46 protected:
47 virtual ~WifiDataProviderCommon();
49 // Returns ownership.
50 virtual WlanApiInterface* NewWlanApi() = 0;
52 // Returns ownership.
53 virtual WifiPollingPolicy* NewPollingPolicy() = 0;
55 private:
56 // Runs a scan. Calls the callbacks if new data is found.
57 void DoWifiScanTask();
59 // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task.
60 void ScheduleNextScan(int interval);
62 WifiData wifi_data_;
64 // Whether we've successfully completed a scan for WiFi data.
65 bool is_first_scan_complete_;
67 // Underlying OS wifi API.
68 scoped_ptr<WlanApiInterface> wlan_api_;
70 // Controls the polling update interval.
71 scoped_ptr<WifiPollingPolicy> polling_policy_;
73 // Holder for delayed tasks; takes care of cleanup.
74 base::WeakPtrFactory<WifiDataProviderCommon> weak_factory_;
76 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderCommon);
79 } // namespace content
81 #endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_