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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 if (m_hasClientForTest) | 89 if (m_hasClientForTest) |
90 m_client->controllerForTestRemoved(this); | 90 m_client->controllerForTestRemoved(this); |
91 } | 91 } |
92 | 92 |
93 void GeolocationController::willBeDestroyed() | 93 void GeolocationController::willBeDestroyed() |
94 { | 94 { |
95 if (m_client) | 95 if (m_client) |
96 m_client->geolocationDestroyed(); | 96 m_client->geolocationDestroyed(); |
97 } | 97 } |
98 | 98 |
99 PassOwnPtrWillBeRawPtr<GeolocationController> GeolocationController::create(Loca lFrame& frame, GeolocationClient* client) | 99 PassOwnPtr<GeolocationController> GeolocationController::create(LocalFrame& fram e, GeolocationClient* client) |
100 { | 100 { |
101 return adoptPtrWillBeNoop(new GeolocationController(frame, client)); | 101 return adoptPtr(new GeolocationController(frame, client)); |
102 } | 102 } |
103 | 103 |
104 void GeolocationController::addObserver(Geolocation* observer, bool enableHighAc curacy) | 104 void GeolocationController::addObserver(Geolocation* observer, bool enableHighAc curacy) |
105 { | 105 { |
106 // This may be called multiple times with the same observer, though removeOb server() | 106 // This may be called multiple times with the same observer, though removeOb server() |
107 // is called only once with each. | 107 // is called only once with each. |
108 bool wasEmpty = m_observers.isEmpty(); | 108 bool wasEmpty = m_observers.isEmpty(); |
109 m_observers.add(observer); | 109 m_observers.add(observer); |
110 if (enableHighAccuracy) | 110 if (enableHighAccuracy) |
111 m_highAccuracyObservers.add(observer); | 111 m_highAccuracyObservers.add(observer); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 } | 147 } |
148 | 148 |
149 void GeolocationController::positionChanged(GeolocationPosition* position) | 149 void GeolocationController::positionChanged(GeolocationPosition* position) |
150 { | 150 { |
151 position = m_inspectorAgent->overrideGeolocationPosition(position); | 151 position = m_inspectorAgent->overrideGeolocationPosition(position); |
152 if (!position) { | 152 if (!position) { |
153 errorOccurred(GeolocationError::create(GeolocationError::PositionUnavail able, "PositionUnavailable").get()); | 153 errorOccurred(GeolocationError::create(GeolocationError::PositionUnavail able, "PositionUnavailable").get()); |
154 return; | 154 return; |
155 } | 155 } |
156 m_lastPosition = position; | 156 m_lastPosition = position; |
157 WillBeHeapVector<RefPtrWillBeMember<Geolocation> > observersVector; | 157 WillBePersistentHeapVector<RefPtrWillBeMember<Geolocation> > observersVector ; |
Mads Ager (chromium)
2014/06/04 06:20:15
This is on the stack, so we should be able to stil
| |
158 copyToVector(m_observers, observersVector); | 158 copyToVector(m_observers, observersVector); |
159 for (size_t i = 0; i < observersVector.size(); ++i) | 159 for (size_t i = 0; i < observersVector.size(); ++i) |
160 observersVector[i]->positionChanged(); | 160 observersVector[i]->positionChanged(); |
161 } | 161 } |
162 | 162 |
163 void GeolocationController::errorOccurred(GeolocationError* error) | 163 void GeolocationController::errorOccurred(GeolocationError* error) |
164 { | 164 { |
165 WillBeHeapVector<RefPtrWillBeMember<Geolocation> > observersVector; | 165 WillBePersistentHeapVector<RefPtrWillBeMember<Geolocation> > observersVector ; |
Mads Ager (chromium)
2014/06/04 06:20:15
Ditto.
| |
166 copyToVector(m_observers, observersVector); | 166 copyToVector(m_observers, observersVector); |
167 for (size_t i = 0; i < observersVector.size(); ++i) | 167 for (size_t i = 0; i < observersVector.size(); ++i) |
168 observersVector[i]->setError(error); | 168 observersVector[i]->setError(error); |
169 } | 169 } |
170 | 170 |
171 GeolocationPosition* GeolocationController::lastPosition() | 171 GeolocationPosition* GeolocationController::lastPosition() |
172 { | 172 { |
173 if (m_lastPosition.get()) | 173 if (m_lastPosition.get()) |
174 return m_lastPosition.get(); | 174 return m_lastPosition.get(); |
175 | 175 |
(...skipping 20 matching lines...) Expand all Loading... | |
196 startUpdatingIfNeeded(); | 196 startUpdatingIfNeeded(); |
197 else | 197 else |
198 stopUpdatingIfNeeded(); | 198 stopUpdatingIfNeeded(); |
199 } | 199 } |
200 | 200 |
201 const char* GeolocationController::supplementName() | 201 const char* GeolocationController::supplementName() |
202 { | 202 { |
203 return "GeolocationController"; | 203 return "GeolocationController"; |
204 } | 204 } |
205 | 205 |
206 void GeolocationController::trace(Visitor* visitor) | |
207 { | |
208 visitor->trace(m_lastPosition); | |
209 visitor->trace(m_observers); | |
210 visitor->trace(m_highAccuracyObservers); | |
211 WillBeHeapSupplement<LocalFrame>::trace(visitor); | |
212 } | |
213 | |
214 void provideGeolocationTo(LocalFrame& frame, GeolocationClient* client) | 206 void provideGeolocationTo(LocalFrame& frame, GeolocationClient* client) |
215 { | 207 { |
216 WillBeHeapSupplement<LocalFrame>::provideTo(frame, GeolocationController::su pplementName(), GeolocationController::create(frame, client)); | 208 Supplement<LocalFrame>::provideTo(frame, GeolocationController::supplementNa me(), GeolocationController::create(frame, client)); |
217 } | 209 } |
218 | 210 |
219 } // namespace WebCore | 211 } // namespace WebCore |
OLD | NEW |