OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GeoNotifier_h |
| 6 #define GeoNotifier_h |
| 7 |
| 8 #include "platform/Timer.h" |
| 9 #include "platform/heap/Handle.h" |
| 10 |
| 11 namespace WebCore { |
| 12 |
| 13 class Geolocation; |
| 14 class Geoposition; |
| 15 class PositionCallback; |
| 16 class PositionError; |
| 17 class PositionErrorCallback; |
| 18 class PositionOptions; |
| 19 |
| 20 class GeoNotifier : public GarbageCollectedFinalized<GeoNotifier> { |
| 21 public: |
| 22 static GeoNotifier* create(Geolocation* geolocation, PassOwnPtr<PositionCall
back> positionCallback, PassOwnPtr<PositionErrorCallback> positionErrorCallback,
PositionOptions* options) |
| 23 { |
| 24 return new GeoNotifier(geolocation, positionCallback, positionErrorCallb
ack, options); |
| 25 } |
| 26 void trace(Visitor*); |
| 27 |
| 28 PositionOptions* options() const { return m_options.get(); }; |
| 29 |
| 30 // Sets the given error as the fatal error if there isn't one yet. |
| 31 // Starts the timer with an interval of 0. |
| 32 void setFatalError(PositionError*); |
| 33 |
| 34 bool useCachedPosition() const { return m_useCachedPosition; } |
| 35 |
| 36 // Tells the notifier to use a cached position and starts its timer with |
| 37 // an interval of 0. |
| 38 void setUseCachedPosition(); |
| 39 |
| 40 void runSuccessCallback(Geoposition*); |
| 41 void runErrorCallback(PositionError*); |
| 42 |
| 43 void startTimer(); |
| 44 void stopTimer(); |
| 45 |
| 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. |
| 48 // Otherwise, the notifier has expired, and its error callback is run. |
| 49 void timerFired(Timer<GeoNotifier>*); |
| 50 |
| 51 private: |
| 52 GeoNotifier(Geolocation*, PassOwnPtr<PositionCallback>, PassOwnPtr<PositionE
rrorCallback>, PositionOptions*); |
| 53 |
| 54 Member<Geolocation> m_geolocation; |
| 55 OwnPtr<PositionCallback> m_successCallback; |
| 56 OwnPtr<PositionErrorCallback> m_errorCallback; |
| 57 Member<PositionOptions> m_options; |
| 58 Timer<GeoNotifier> m_timer; |
| 59 Member<PositionError> m_fatalError; |
| 60 bool m_useCachedPosition; |
| 61 }; |
| 62 |
| 63 } // namespace WebCore |
| 64 |
| 65 #endif // GeoNotifier_h |
OLD | NEW |