| Index: content/browser/geolocation/wifi_polling_policy.h
|
| diff --git a/content/browser/geolocation/wifi_data_provider_common.h b/content/browser/geolocation/wifi_polling_policy.h
|
| similarity index 33%
|
| copy from content/browser/geolocation/wifi_data_provider_common.h
|
| copy to content/browser/geolocation/wifi_polling_policy.h
|
| index 5f15e0919bf3e0c558ae970f965fc01ff68aee44..b83ff46b8fb5a05ed273f23dc77c5b8fc20793ee 100644
|
| --- a/content/browser/geolocation/wifi_data_provider_common.h
|
| +++ b/content/browser/geolocation/wifi_polling_policy.h
|
| @@ -1,33 +1,25 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_
|
| -#define CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_
|
| -
|
| -#include <assert.h>
|
| -
|
| -#include "base/logging.h"
|
| -#include "base/memory/scoped_ptr.h"
|
| -#include "base/memory/weak_ptr.h"
|
| -#include "base/strings/string16.h"
|
| -#include "content/browser/geolocation/wifi_data_provider.h"
|
| -#include "content/common/content_export.h"
|
| +#ifndef CONTENT_BROWSER_GEOLOCATION_WIFI_POLLING_POLICY_H_
|
| +#define CONTENT_BROWSER_GEOLOCATION_WIFI_POLLING_POLICY_H_
|
|
|
| namespace content {
|
|
|
| -// Converts a MAC address stored as an array of uint8 to a string.
|
| -string16 MacAddressAsString16(const uint8 mac_as_int[6]);
|
| -
|
| // Allows sharing and mocking of the update polling policy function.
|
| -class PollingPolicyInterface {
|
| +class WifiPollingPolicy {
|
| public:
|
| - virtual ~PollingPolicyInterface() {}
|
| + WifiPollingPolicy() {}
|
| + virtual ~WifiPollingPolicy() {}
|
| // Calculates the new polling interval for wiFi scans, given the previous
|
| // interval and whether the last scan produced new results.
|
| virtual void UpdatePollingInterval(bool scan_results_differ) = 0;
|
| virtual int PollingInterval() = 0;
|
| virtual int NoWifiInterval() = 0;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(WifiPollingPolicy);
|
| };
|
|
|
| // Generic polling policy, constants are compile-time parameterized to allow
|
| @@ -36,10 +28,10 @@ template<int DEFAULT_INTERVAL,
|
| int NO_CHANGE_INTERVAL,
|
| int TWO_NO_CHANGE_INTERVAL,
|
| int NO_WIFI_INTERVAL>
|
| -class GenericPollingPolicy : public PollingPolicyInterface {
|
| +class GenericWifiPollingPolicy : public WifiPollingPolicy {
|
| public:
|
| - GenericPollingPolicy() : polling_interval_(DEFAULT_INTERVAL) {}
|
| - // PollingPolicyInterface
|
| + GenericWifiPollingPolicy() : polling_interval_(DEFAULT_INTERVAL) {}
|
| + // WifiPollingPolicy
|
| virtual void UpdatePollingInterval(bool scan_results_differ) {
|
| if (scan_results_differ) {
|
| polling_interval_ = DEFAULT_INTERVAL;
|
| @@ -58,62 +50,6 @@ class GenericPollingPolicy : public PollingPolicyInterface {
|
| int polling_interval_;
|
| };
|
|
|
| -// Base class to promote code sharing between platform specific wifi data
|
| -// providers. It's optional for specific platforms to derive this, but if they
|
| -// do polling behavior is taken care of by this base class, and all the platform
|
| -// need do is provide the underlying WLAN access API and polling policy.
|
| -// Also designed this way for ease of testing the cross-platform behavior.
|
| -class CONTENT_EXPORT WifiDataProviderCommon : public WifiDataProviderImplBase {
|
| - public:
|
| - // Interface to abstract the low level data OS library call, and to allow
|
| - // mocking (hence public).
|
| - class WlanApiInterface {
|
| - public:
|
| - virtual ~WlanApiInterface() {}
|
| - // Gets wifi data for all visible access points.
|
| - virtual bool GetAccessPointData(WifiData::AccessPointDataSet* data) = 0;
|
| - };
|
| -
|
| - WifiDataProviderCommon();
|
| -
|
| - // WifiDataProviderImplBase implementation
|
| - virtual void StartDataProvider() OVERRIDE;
|
| - virtual void StopDataProvider() OVERRIDE;
|
| - virtual bool GetData(WifiData* data) OVERRIDE;
|
| -
|
| - protected:
|
| - virtual ~WifiDataProviderCommon();
|
| -
|
| - // Returns ownership.
|
| - virtual WlanApiInterface* NewWlanApi() = 0;
|
| -
|
| - // Returns ownership.
|
| - virtual PollingPolicyInterface* NewPollingPolicy() = 0;
|
| -
|
| - private:
|
| - // Runs a scan. Calls the callbacks if new data is found.
|
| - void DoWifiScanTask();
|
| -
|
| - // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task.
|
| - void ScheduleNextScan(int interval);
|
| -
|
| - WifiData wifi_data_;
|
| -
|
| - // Whether we've successfully completed a scan for WiFi data.
|
| - bool is_first_scan_complete_;
|
| -
|
| - // Underlying OS wifi API.
|
| - scoped_ptr<WlanApiInterface> wlan_api_;
|
| -
|
| - // Controls the polling update interval.
|
| - scoped_ptr<PollingPolicyInterface> polling_policy_;
|
| -
|
| - // Holder for delayed tasks; takes care of cleanup.
|
| - base::WeakPtrFactory<WifiDataProviderCommon> weak_factory_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(WifiDataProviderCommon);
|
| -};
|
| -
|
| } // namespace content
|
|
|
| -#endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_
|
| +#endif // CONTENT_BROWSER_GEOLOCATION_WIFI_POLLING_POLICY_H_
|
|
|