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 "config.h" | 5 #include "config.h" |
6 #include "modules/geolocation/GeoNotifier.h" | 6 #include "modules/geolocation/GeoNotifier.h" |
7 | 7 |
8 #include "modules/geolocation/Geolocation.h" | 8 #include "modules/geolocation/Geolocation.h" |
9 #include "modules/geolocation/PositionError.h" | 9 #include "modules/geolocation/PositionError.h" |
10 #include "modules/geolocation/PositionOptions.h" | 10 #include "modules/geolocation/PositionOptions.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 GeoNotifier::GeoNotifier(Geolocation* geolocation, PositionCallback* successCall
back, PositionErrorCallback* errorCallback, PositionOptions* options) | 14 GeoNotifier::GeoNotifier(Geolocation* geolocation, PositionCallback* successCall
back, PositionErrorCallback* errorCallback, const PositionOptions& options) |
15 // FIXME : m_geolocation should be removed, it makes circular dependancy. | 15 // FIXME : m_geolocation should be removed, it makes circular dependancy. |
16 : m_geolocation(geolocation) | 16 : m_geolocation(geolocation) |
17 , m_successCallback(successCallback) | 17 , m_successCallback(successCallback) |
18 , m_errorCallback(errorCallback) | 18 , m_errorCallback(errorCallback) |
19 , m_options(options) | 19 , m_options(options) |
20 , m_timer(this, &GeoNotifier::timerFired) | 20 , m_timer(this, &GeoNotifier::timerFired) |
21 , m_useCachedPosition(false) | 21 , m_useCachedPosition(false) |
22 { | 22 { |
23 ASSERT(m_geolocation); | 23 ASSERT(m_geolocation); |
24 ASSERT(m_successCallback); | 24 ASSERT(m_successCallback); |
25 ASSERT(m_options); | |
26 } | 25 } |
27 | 26 |
28 void GeoNotifier::trace(Visitor* visitor) | 27 void GeoNotifier::trace(Visitor* visitor) |
29 { | 28 { |
30 visitor->trace(m_geolocation); | 29 visitor->trace(m_geolocation); |
31 visitor->trace(m_successCallback); | 30 visitor->trace(m_successCallback); |
32 visitor->trace(m_errorCallback); | 31 visitor->trace(m_errorCallback); |
33 visitor->trace(m_options); | |
34 visitor->trace(m_fatalError); | 32 visitor->trace(m_fatalError); |
35 } | 33 } |
36 | 34 |
37 void GeoNotifier::setFatalError(PositionError* error) | 35 void GeoNotifier::setFatalError(PositionError* error) |
38 { | 36 { |
39 // If a fatal error has already been set, stick with it. This makes sure tha
t | 37 // If a fatal error has already been set, stick with it. This makes sure tha
t |
40 // when permission is denied, this is the error reported, as required by the | 38 // when permission is denied, this is the error reported, as required by the |
41 // spec. | 39 // spec. |
42 if (m_fatalError) | 40 if (m_fatalError) |
43 return; | 41 return; |
(...skipping 16 matching lines...) Expand all Loading... |
60 } | 58 } |
61 | 59 |
62 void GeoNotifier::runErrorCallback(PositionError* error) | 60 void GeoNotifier::runErrorCallback(PositionError* error) |
63 { | 61 { |
64 if (m_errorCallback) | 62 if (m_errorCallback) |
65 m_errorCallback->handleEvent(error); | 63 m_errorCallback->handleEvent(error); |
66 } | 64 } |
67 | 65 |
68 void GeoNotifier::startTimer() | 66 void GeoNotifier::startTimer() |
69 { | 67 { |
70 m_timer.startOneShot(m_options->timeout() / 1000.0, FROM_HERE); | 68 m_timer.startOneShot(m_options.timeout() / 1000.0, FROM_HERE); |
71 } | 69 } |
72 | 70 |
73 void GeoNotifier::stopTimer() | 71 void GeoNotifier::stopTimer() |
74 { | 72 { |
75 m_timer.stop(); | 73 m_timer.stop(); |
76 } | 74 } |
77 | 75 |
78 void GeoNotifier::timerFired(Timer<GeoNotifier>*) | 76 void GeoNotifier::timerFired(Timer<GeoNotifier>*) |
79 { | 77 { |
80 m_timer.stop(); | 78 m_timer.stop(); |
(...skipping 14 matching lines...) Expand all Loading... |
95 m_geolocation->requestUsesCachedPosition(this); | 93 m_geolocation->requestUsesCachedPosition(this); |
96 return; | 94 return; |
97 } | 95 } |
98 | 96 |
99 if (m_errorCallback) | 97 if (m_errorCallback) |
100 m_errorCallback->handleEvent(PositionError::create(PositionError::TIMEOU
T, "Timeout expired")); | 98 m_errorCallback->handleEvent(PositionError::create(PositionError::TIMEOU
T, "Timeout expired")); |
101 m_geolocation->requestTimedOut(this); | 99 m_geolocation->requestTimedOut(this); |
102 } | 100 } |
103 | 101 |
104 } // namespace blink | 102 } // namespace blink |
OLD | NEW |