Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / content / browser / geolocation / wifi_data.cc
blobbcfb9811bb784e292e8e16f2efc60b2842c8ea71
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
3 // found in the LICENSE file.
5 #include "content/browser/geolocation/wifi_data.h"
7 #include <algorithm>
9 #include "base/logging.h"
11 namespace content {
13 AccessPointData::AccessPointData()
14 : radio_signal_strength(kint32min),
15 channel(kint32min),
16 signal_to_noise(kint32min) {
19 AccessPointData::~AccessPointData() {}
21 WifiData::WifiData() {}
23 WifiData::~WifiData() {}
25 bool WifiData::DiffersSignificantly(const WifiData& other) const {
26 // More than 4 or 50% of access points added or removed is significant.
27 static const size_t kMinChangedAccessPoints = 4;
28 const size_t min_ap_count =
29 std::min(access_point_data.size(), other.access_point_data.size());
30 const size_t max_ap_count =
31 std::max(access_point_data.size(), other.access_point_data.size());
32 const size_t difference_threadhold = std::min(kMinChangedAccessPoints,
33 min_ap_count / 2);
34 if (max_ap_count > min_ap_count + difference_threadhold)
35 return true;
36 // Compute size of intersection of old and new sets.
37 size_t num_common = 0;
38 for (AccessPointDataSet::const_iterator iter = access_point_data.begin();
39 iter != access_point_data.end();
40 iter++) {
41 if (other.access_point_data.find(*iter) !=
42 other.access_point_data.end()) {
43 ++num_common;
46 DCHECK(num_common <= min_ap_count);
48 // Test how many have changed.
49 return max_ap_count > num_common + difference_threadhold;
52 } // namespace content