OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "content/browser/geolocation/win7_location_provider_win.h" | 5 #include "content/browser/geolocation/win7_location_provider_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 | 13 |
14 namespace{ | 14 namespace{ |
15 const int kPollPeriodMovingMillis = 500; | 15 const int kPollPeriodMovingMillis = 500; |
16 // Poll less frequently whilst stationary. | 16 // Poll less frequently whilst stationary. |
17 const int kPollPeriodStationaryMillis = kPollPeriodMovingMillis * 3; | 17 const int kPollPeriodStationaryMillis = kPollPeriodMovingMillis * 3; |
18 // Reading must differ by more than this amount to be considered movement. | 18 // Reading must differ by more than this amount to be considered movement. |
19 const int kMovementThresholdMeters = 20; | 19 const int kMovementThresholdMeters = 20; |
20 | 20 |
21 // This algorithm is reused from the corresponding code in the gears project | 21 // This algorithm is reused from the corresponding code in the Gears project |
22 // and is also used in gps_location_provider_linux.cc | 22 // and is also used in gps_location_provider_linux.cc |
23 // The arbitrary delta is decreased (gears used 100 meters); if we need to | 23 // The arbitrary delta is decreased (Gears used 100 meters); if we need to |
24 // decrease it any further we'll likely want to do some smarter filtering to | 24 // decrease it any further we'll likely want to do some smarter filtering to |
25 // remove GPS location jitter noise. | 25 // remove GPS location jitter noise. |
26 bool PositionsDifferSiginificantly(const Geoposition& position_1, | 26 bool PositionsDifferSiginificantly(const Geoposition& position_1, |
27 const Geoposition& position_2) { | 27 const Geoposition& position_2) { |
28 const bool pos_1_valid = position_1.IsValidFix(); | 28 const bool pos_1_valid = position_1.IsValidFix(); |
29 if (pos_1_valid != position_2.IsValidFix()) | 29 if (pos_1_valid != position_2.IsValidFix()) |
30 return true; | 30 return true; |
31 if (!pos_1_valid) { | 31 if (!pos_1_valid) { |
32 DCHECK(!position_2.IsValidFix()); | 32 DCHECK(!position_2.IsValidFix()); |
33 return false; | 33 return false; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 task_factory_.NewRunnableMethod(&Win7LocationProvider::DoPollTask), | 97 task_factory_.NewRunnableMethod(&Win7LocationProvider::DoPollTask), |
98 interval); | 98 interval); |
99 } | 99 } |
100 | 100 |
101 LocationProviderBase* NewSystemLocationProvider() { | 101 LocationProviderBase* NewSystemLocationProvider() { |
102 Win7LocationApi* api = Win7LocationApi::Create(); | 102 Win7LocationApi* api = Win7LocationApi::Create(); |
103 if (api == NULL) | 103 if (api == NULL) |
104 return NULL; // API not supported on this machine. | 104 return NULL; // API not supported on this machine. |
105 return new Win7LocationProvider(api); | 105 return new Win7LocationProvider(api); |
106 } | 106 } |
OLD | NEW |