OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 24 matching lines...) Expand all Loading... | |
35 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 class GeolocationInspectorAgent; | 39 class GeolocationInspectorAgent; |
40 class GeolocationClient; | 40 class GeolocationClient; |
41 class GeolocationError; | 41 class GeolocationError; |
42 class GeolocationPosition; | 42 class GeolocationPosition; |
43 class Page; | 43 class Page; |
44 | 44 |
45 class GeolocationController FINAL : public Supplement<Page>, public PageLifecycl eObserver { | 45 class GeolocationController FINAL : public NoBaseWillBeGarbageCollectedFinalized <GeolocationController>, public WillBeHeapSupplement<Page>, public PageLifecycle Observer { |
46 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(GeolocationController); | |
46 WTF_MAKE_NONCOPYABLE(GeolocationController); | 47 WTF_MAKE_NONCOPYABLE(GeolocationController); |
47 public: | 48 public: |
48 virtual ~GeolocationController(); | 49 virtual ~GeolocationController(); |
49 | 50 |
50 static PassOwnPtr<GeolocationController> create(Page&, GeolocationClient*); | 51 static PassOwnPtrWillBeRawPtr<GeolocationController> create(Page&, Geolocati onClient*); |
51 | 52 |
52 void addObserver(Geolocation*, bool enableHighAccuracy); | 53 void addObserver(Geolocation*, bool enableHighAccuracy); |
53 void removeObserver(Geolocation*); | 54 void removeObserver(Geolocation*); |
54 | 55 |
55 void requestPermission(Geolocation*); | 56 void requestPermission(Geolocation*); |
56 void cancelPermissionRequest(Geolocation*); | 57 void cancelPermissionRequest(Geolocation*); |
57 | 58 |
58 void positionChanged(GeolocationPosition*); | 59 void positionChanged(GeolocationPosition*); |
59 void errorOccurred(GeolocationError*); | 60 void errorOccurred(GeolocationError*); |
60 | 61 |
61 GeolocationPosition* lastPosition(); | 62 GeolocationPosition* lastPosition(); |
62 | 63 |
63 void setClientForTest(GeolocationClient*); | 64 void setClientForTest(GeolocationClient*); |
64 bool hasClientForTest() { return m_hasClientForTest; } | 65 bool hasClientForTest() { return m_hasClientForTest; } |
65 GeolocationClient* client() { return m_client; } | 66 GeolocationClient* client() { return m_client; } |
66 | 67 |
67 // Inherited from PageLifecycleObserver. | 68 // Inherited from PageLifecycleObserver. |
68 virtual void pageVisibilityChanged() OVERRIDE; | 69 virtual void pageVisibilityChanged() OVERRIDE; |
69 | 70 |
70 static const char* supplementName(); | 71 static const char* supplementName(); |
71 static GeolocationController* from(Page* page) { return static_cast<Geolocat ionController*>(Supplement<Page>::from(page, supplementName())); } | 72 static GeolocationController* from(Page* page) { return static_cast<Geolocat ionController*>(WillBeHeapSupplement<Page>::from(page, supplementName())); } |
72 | 73 |
73 virtual void trace(Visitor*) OVERRIDE { }; | 74 virtual void trace(Visitor*) OVERRIDE; |
74 | 75 |
75 virtual void willBeDestroyed() OVERRIDE; | 76 virtual void willBeDestroyed() OVERRIDE; |
76 | 77 |
77 private: | 78 private: |
78 GeolocationController(Page&, GeolocationClient*); | 79 GeolocationController(Page&, GeolocationClient*); |
79 | 80 |
80 void startUpdatingIfNeeded(); | 81 void startUpdatingIfNeeded(); |
81 void stopUpdatingIfNeeded(); | 82 void stopUpdatingIfNeeded(); |
82 | 83 |
83 GeolocationClient* m_client; | 84 GeolocationClient* m_client; |
haraken
2014/04/30 02:41:22
Ditto. I wonder how it's guaranteed that the clien
zerny-chromium
2014/04/30 08:29:34
The opposite needs to hold. The client should alwa
haraken
2014/04/30 11:18:08
This raw pointer happens to be safe because WebVie
haraken
2014/04/30 11:19:58
Note: I haven't yet checked if other m_client poin
zerny-chromium
2014/04/30 11:46:53
Page is already moved. This CL does not change its
haraken
2014/04/30 12:02:08
Sorry, I was misunderstanding! The supplementable
| |
84 bool m_hasClientForTest; | 85 bool m_hasClientForTest; |
85 | 86 |
86 RefPtrWillBePersistent<GeolocationPosition> m_lastPosition; | 87 RefPtrWillBeMember<GeolocationPosition> m_lastPosition; |
87 typedef WillBePersistentHeapHashSet<RefPtrWillBeMember<Geolocation> > Observ ersSet; | 88 typedef WillBeHeapHashSet<RefPtrWillBeMember<Geolocation> > ObserversSet; |
88 // All observers; both those requesting high accuracy and those not. | 89 // All observers; both those requesting high accuracy and those not. |
89 ObserversSet m_observers; | 90 ObserversSet m_observers; |
90 ObserversSet m_highAccuracyObservers; | 91 ObserversSet m_highAccuracyObservers; |
91 bool m_isClientUpdating; | 92 bool m_isClientUpdating; |
92 GeolocationInspectorAgent* m_inspectorAgent; | 93 GeolocationInspectorAgent* m_inspectorAgent; |
haraken
2014/04/30 02:41:22
This raw pointer looks safe since Page owns the In
| |
93 }; | 94 }; |
94 | 95 |
95 } // namespace WebCore | 96 } // namespace WebCore |
96 | 97 |
97 #endif // GeolocationController_h | 98 #endif // GeolocationController_h |
OLD | NEW |