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

Side by Side Diff: device/geolocation/wifi_data.cc

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.h ('k') | device/geolocation/wifi_data_provider.cc » ('j') | 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 #include "device/geolocation/wifi_data.h" 5 #include "device/geolocation/wifi_data.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 16 matching lines...) Expand all
27 27
28 WifiData::~WifiData() {} 28 WifiData::~WifiData() {}
29 29
30 bool WifiData::DiffersSignificantly(const WifiData& other) const { 30 bool WifiData::DiffersSignificantly(const WifiData& other) const {
31 // More than 4 or 50% of access points added or removed is significant. 31 // More than 4 or 50% of access points added or removed is significant.
32 static const size_t kMinChangedAccessPoints = 4; 32 static const size_t kMinChangedAccessPoints = 4;
33 const size_t min_ap_count = 33 const size_t min_ap_count =
34 std::min(access_point_data.size(), other.access_point_data.size()); 34 std::min(access_point_data.size(), other.access_point_data.size());
35 const size_t max_ap_count = 35 const size_t max_ap_count =
36 std::max(access_point_data.size(), other.access_point_data.size()); 36 std::max(access_point_data.size(), other.access_point_data.size());
37 const size_t difference_threadhold = std::min(kMinChangedAccessPoints, 37 const size_t difference_threadhold =
38 min_ap_count / 2); 38 std::min(kMinChangedAccessPoints, min_ap_count / 2);
39 if (max_ap_count > min_ap_count + difference_threadhold) 39 if (max_ap_count > min_ap_count + difference_threadhold)
40 return true; 40 return true;
41 // Compute size of intersection of old and new sets. 41 // Compute size of intersection of old and new sets.
42 size_t num_common = 0; 42 size_t num_common = 0;
43 for (AccessPointDataSet::const_iterator iter = access_point_data.begin(); 43 for (AccessPointDataSet::const_iterator iter = access_point_data.begin();
44 iter != access_point_data.end(); 44 iter != access_point_data.end(); iter++) {
45 iter++) { 45 if (other.access_point_data.find(*iter) != other.access_point_data.end()) {
46 if (other.access_point_data.find(*iter) !=
47 other.access_point_data.end()) {
48 ++num_common; 46 ++num_common;
49 } 47 }
50 } 48 }
51 DCHECK(num_common <= min_ap_count); 49 DCHECK(num_common <= min_ap_count);
52 50
53 // Test how many have changed. 51 // Test how many have changed.
54 return max_ap_count > num_common + difference_threadhold; 52 return max_ap_count > num_common + difference_threadhold;
55 } 53 }
56 54
57 } // namespace device 55 } // namespace device
OLDNEW
« no previous file with comments | « device/geolocation/wifi_data.h ('k') | device/geolocation/wifi_data_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698