OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "modules/geolocation/GeoNotifier.h" | 5 #include "modules/geolocation/GeoNotifier.h" |
6 | 6 |
7 #include "modules/geolocation/Geolocation.h" | 7 #include "modules/geolocation/Geolocation.h" |
8 #include "modules/geolocation/PositionError.h" | 8 #include "modules/geolocation/PositionError.h" |
9 #include "modules/geolocation/PositionOptions.h" | 9 #include "modules/geolocation/PositionOptions.h" |
| 10 #include "platform/Histogram.h" |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 GeoNotifier::GeoNotifier(Geolocation* geolocation, PositionCallback* successCall
back, PositionErrorCallback* errorCallback, const PositionOptions& options) | 14 GeoNotifier::GeoNotifier(Geolocation* geolocation, PositionCallback* successCall
back, PositionErrorCallback* errorCallback, const PositionOptions& options) |
14 : m_geolocation(geolocation) | 15 : m_geolocation(geolocation) |
15 , m_successCallback(successCallback) | 16 , m_successCallback(successCallback) |
16 , m_errorCallback(errorCallback) | 17 , m_errorCallback(errorCallback) |
17 , m_options(options) | 18 , m_options(options) |
18 , m_timer(this, &GeoNotifier::timerFired) | 19 , m_timer(this, &GeoNotifier::timerFired) |
19 , m_useCachedPosition(false) | 20 , m_useCachedPosition(false) |
20 { | 21 { |
21 ASSERT(m_geolocation); | 22 ASSERT(m_geolocation); |
22 ASSERT(m_successCallback); | 23 ASSERT(m_successCallback); |
| 24 |
| 25 DEFINE_STATIC_LOCAL(CustomCountHistogram, timeoutHistogram, ("Geolocation.Ti
meout", 0, 1000 * 60 * 10 /* 10 minute max */, 20 /* buckets */)); |
| 26 timeoutHistogram.count(m_options.timeout()); |
23 } | 27 } |
24 | 28 |
25 DEFINE_TRACE(GeoNotifier) | 29 DEFINE_TRACE(GeoNotifier) |
26 { | 30 { |
27 visitor->trace(m_geolocation); | 31 visitor->trace(m_geolocation); |
28 visitor->trace(m_successCallback); | 32 visitor->trace(m_successCallback); |
29 visitor->trace(m_errorCallback); | 33 visitor->trace(m_errorCallback); |
30 visitor->trace(m_fatalError); | 34 visitor->trace(m_fatalError); |
31 } | 35 } |
32 | 36 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (m_useCachedPosition) { | 91 if (m_useCachedPosition) { |
88 // Clear the cached position flag in case this is a watch request, which | 92 // Clear the cached position flag in case this is a watch request, which |
89 // will continue to run. | 93 // will continue to run. |
90 m_useCachedPosition = false; | 94 m_useCachedPosition = false; |
91 m_geolocation->requestUsesCachedPosition(this); | 95 m_geolocation->requestUsesCachedPosition(this); |
92 return; | 96 return; |
93 } | 97 } |
94 | 98 |
95 if (m_errorCallback) | 99 if (m_errorCallback) |
96 m_errorCallback->handleEvent(PositionError::create(PositionError::TIMEOU
T, "Timeout expired")); | 100 m_errorCallback->handleEvent(PositionError::create(PositionError::TIMEOU
T, "Timeout expired")); |
| 101 |
| 102 DEFINE_STATIC_LOCAL(CustomCountHistogram, timeoutExpiredHistogram, ("Geoloca
tion.TimeoutExpired", 0, 1000 * 60 * 10 /* 10 minute max */, 20 /* buckets */)); |
| 103 timeoutExpiredHistogram.count(m_options.timeout()); |
| 104 |
97 m_geolocation->requestTimedOut(this); | 105 m_geolocation->requestTimedOut(this); |
98 } | 106 } |
99 | 107 |
100 } // namespace blink | 108 } // namespace blink |
OLD | NEW |