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 #ifndef GeoNotifier_h | 5 #ifndef GeoNotifier_h |
6 #define GeoNotifier_h | 6 #define GeoNotifier_h |
7 | 7 |
8 #include "modules/geolocation/PositionCallback.h" | 8 #include "modules/geolocation/PositionCallback.h" |
9 #include "modules/geolocation/PositionErrorCallback.h" | 9 #include "modules/geolocation/PositionErrorCallback.h" |
10 #include "modules/geolocation/PositionOptions.h" | |
10 #include "platform/Timer.h" | 11 #include "platform/Timer.h" |
11 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 class Geolocation; | 16 class Geolocation; |
16 class Geoposition; | 17 class Geoposition; |
17 class PositionError; | 18 class PositionError; |
18 class PositionOptions; | |
19 | 19 |
20 class GeoNotifier : public GarbageCollectedFinalized<GeoNotifier> { | 20 class GeoNotifier : public GarbageCollectedFinalized<GeoNotifier> { |
21 public: | 21 public: |
22 static GeoNotifier* create(Geolocation* geolocation, PositionCallback* posit ionCallback, PositionErrorCallback* positionErrorCallback, PositionOptions* opti ons) | 22 static GeoNotifier* create(Geolocation* geolocation, PositionCallback* posit ionCallback, PositionErrorCallback* positionErrorCallback, const PositionOptions & options) |
23 { | 23 { |
24 return new GeoNotifier(geolocation, positionCallback, positionErrorCallb ack, options); | 24 return new GeoNotifier(geolocation, positionCallback, positionErrorCallb ack, options); |
25 } | 25 } |
26 void trace(Visitor*); | 26 void trace(Visitor*); |
27 | 27 |
28 PositionOptions* options() const { return m_options.get(); }; | 28 const PositionOptions& options() const { return m_options; } |
29 | 29 |
30 // Sets the given error as the fatal error if there isn't one yet. | 30 // Sets the given error as the fatal error if there isn't one yet. |
31 // Starts the timer with an interval of 0. | 31 // Starts the timer with an interval of 0. |
32 void setFatalError(PositionError*); | 32 void setFatalError(PositionError*); |
33 | 33 |
34 bool useCachedPosition() const { return m_useCachedPosition; } | 34 bool useCachedPosition() const { return m_useCachedPosition; } |
35 | 35 |
36 // Tells the notifier to use a cached position and starts its timer with | 36 // Tells the notifier to use a cached position and starts its timer with |
37 // an interval of 0. | 37 // an interval of 0. |
38 void setUseCachedPosition(); | 38 void setUseCachedPosition(); |
39 | 39 |
40 void runSuccessCallback(Geoposition*); | 40 void runSuccessCallback(Geoposition*); |
41 void runErrorCallback(PositionError*); | 41 void runErrorCallback(PositionError*); |
42 | 42 |
43 void startTimer(); | 43 void startTimer(); |
44 void stopTimer(); | 44 void stopTimer(); |
45 | 45 |
46 // Runs the error callback if there is a fatal error. Otherwise, if a | 46 // Runs the error callback if there is a fatal error. Otherwise, if a |
47 // cached position must be used, registers itself for receiving one. | 47 // cached position must be used, registers itself for receiving one. |
48 // Otherwise, the notifier has expired, and its error callback is run. | 48 // Otherwise, the notifier has expired, and its error callback is run. |
49 void timerFired(Timer<GeoNotifier>*); | 49 void timerFired(Timer<GeoNotifier>*); |
50 | 50 |
51 private: | 51 private: |
52 GeoNotifier(Geolocation*, PositionCallback*, PositionErrorCallback*, Positio nOptions*); | 52 GeoNotifier(Geolocation*, PositionCallback*, PositionErrorCallback*, const P ositionOptions&); |
53 | 53 |
54 Member<Geolocation> m_geolocation; | 54 Member<Geolocation> m_geolocation; |
55 Member<PositionCallback> m_successCallback; | 55 Member<PositionCallback> m_successCallback; |
56 Member<PositionErrorCallback> m_errorCallback; | 56 Member<PositionErrorCallback> m_errorCallback; |
57 Member<PositionOptions> m_options; | 57 const PositionOptions m_options; |
haraken
2014/11/20 16:02:07
bashi-san: Just to confirm, is it safe to keep a d
bashi
2014/11/20 23:10:05
Yes, for now. But we might want to make dictionari
| |
58 Timer<GeoNotifier> m_timer; | 58 Timer<GeoNotifier> m_timer; |
59 Member<PositionError> m_fatalError; | 59 Member<PositionError> m_fatalError; |
60 bool m_useCachedPosition; | 60 bool m_useCachedPosition; |
61 }; | 61 }; |
62 | 62 |
63 } // namespace blink | 63 } // namespace blink |
64 | 64 |
65 #endif // GeoNotifier_h | 65 #endif // GeoNotifier_h |
OLD | NEW |