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

Side by Side Diff: device/geolocation/wifi_polling_policy.h

Issue 2200483002: Geolocation cleanup: run clang-format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « device/geolocation/wifi_data_provider_win.cc ('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 #ifndef DEVICE_GEOLOCATION_WIFI_POLLING_POLICY_H_ 5 #ifndef DEVICE_GEOLOCATION_WIFI_POLLING_POLICY_H_
6 #define DEVICE_GEOLOCATION_WIFI_POLLING_POLICY_H_ 6 #define DEVICE_GEOLOCATION_WIFI_POLLING_POLICY_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 9
10 namespace device { 10 namespace device {
11 11
12 // Allows sharing and mocking of the update polling policy function. 12 // Allows sharing and mocking of the update polling policy function.
13 class WifiPollingPolicy { 13 class WifiPollingPolicy {
14 public: 14 public:
15 WifiPollingPolicy() {} 15 WifiPollingPolicy() {}
16 virtual ~WifiPollingPolicy() {} 16 virtual ~WifiPollingPolicy() {}
17 // Calculates the new polling interval for wiFi scans, given the previous 17 // Calculates the new polling interval for wiFi scans, given the previous
18 // interval and whether the last scan produced new results. 18 // interval and whether the last scan produced new results.
19 virtual void UpdatePollingInterval(bool scan_results_differ) = 0; 19 virtual void UpdatePollingInterval(bool scan_results_differ) = 0;
20 virtual int PollingInterval() = 0; 20 virtual int PollingInterval() = 0;
21 virtual int NoWifiInterval() = 0; 21 virtual int NoWifiInterval() = 0;
22 22
23 private: 23 private:
24 DISALLOW_COPY_AND_ASSIGN(WifiPollingPolicy); 24 DISALLOW_COPY_AND_ASSIGN(WifiPollingPolicy);
25 }; 25 };
26 26
27 // Generic polling policy, constants are compile-time parameterized to allow 27 // Generic polling policy, constants are compile-time parameterized to allow
28 // tuning on a per-platform basis. 28 // tuning on a per-platform basis.
29 template<int DEFAULT_INTERVAL, 29 template <int DEFAULT_INTERVAL,
30 int NO_CHANGE_INTERVAL, 30 int NO_CHANGE_INTERVAL,
31 int TWO_NO_CHANGE_INTERVAL, 31 int TWO_NO_CHANGE_INTERVAL,
32 int NO_WIFI_INTERVAL> 32 int NO_WIFI_INTERVAL>
33 class GenericWifiPollingPolicy : public WifiPollingPolicy { 33 class GenericWifiPollingPolicy : public WifiPollingPolicy {
34 public: 34 public:
35 GenericWifiPollingPolicy() : polling_interval_(DEFAULT_INTERVAL) {} 35 GenericWifiPollingPolicy() : polling_interval_(DEFAULT_INTERVAL) {}
36 // WifiPollingPolicy 36 // WifiPollingPolicy
37 void UpdatePollingInterval(bool scan_results_differ) override { 37 void UpdatePollingInterval(bool scan_results_differ) override {
38 if (scan_results_differ) { 38 if (scan_results_differ) {
39 polling_interval_ = DEFAULT_INTERVAL; 39 polling_interval_ = DEFAULT_INTERVAL;
40 } else if (polling_interval_ == DEFAULT_INTERVAL) { 40 } else if (polling_interval_ == DEFAULT_INTERVAL) {
41 polling_interval_ = NO_CHANGE_INTERVAL; 41 polling_interval_ = NO_CHANGE_INTERVAL;
42 } else { 42 } else {
43 DCHECK(polling_interval_ == NO_CHANGE_INTERVAL || 43 DCHECK(polling_interval_ == NO_CHANGE_INTERVAL ||
44 polling_interval_ == TWO_NO_CHANGE_INTERVAL); 44 polling_interval_ == TWO_NO_CHANGE_INTERVAL);
45 polling_interval_ = TWO_NO_CHANGE_INTERVAL; 45 polling_interval_ = TWO_NO_CHANGE_INTERVAL;
46 } 46 }
47 } 47 }
48 int PollingInterval() override { return polling_interval_; } 48 int PollingInterval() override { return polling_interval_; }
49 int NoWifiInterval() override { return NO_WIFI_INTERVAL; } 49 int NoWifiInterval() override { return NO_WIFI_INTERVAL; }
50 50
51 private: 51 private:
52 int polling_interval_; 52 int polling_interval_;
53 }; 53 };
54 54
55 } // namespace device 55 } // namespace device
56 56
57 #endif // DEVICE_GEOLOCATION_WIFI_POLLING_POLICY_H_ 57 #endif // DEVICE_GEOLOCATION_WIFI_POLLING_POLICY_H_
OLDNEW
« no previous file with comments | « device/geolocation/wifi_data_provider_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698