| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009 Torch Mobile, Inc. | 3 * Copyright (C) 2009 Torch Mobile, Inc. |
| 4 * Copyright 2010, The Android Open Source Project | 4 * Copyright 2010, The Android Open Source Project |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 m_pendingForPermissionNotifiers.insert(notifier); | 226 m_pendingForPermissionNotifiers.insert(notifier); |
| 227 requestPermission(); | 227 requestPermission(); |
| 228 } else { | 228 } else { |
| 229 startUpdating(notifier); | 229 startUpdating(notifier); |
| 230 notifier->startTimer(); | 230 notifier->startTimer(); |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 void Geolocation::fatalErrorOccurred(GeoNotifier* notifier) { | 234 void Geolocation::fatalErrorOccurred(GeoNotifier* notifier) { |
| 235 // This request has failed fatally. Remove it from our lists. | 235 // This request has failed fatally. Remove it from our lists. |
| 236 m_oneShots.remove(notifier); | 236 m_oneShots.erase(notifier); |
| 237 m_watchers.remove(notifier); | 237 m_watchers.remove(notifier); |
| 238 | 238 |
| 239 if (!hasListeners()) | 239 if (!hasListeners()) |
| 240 stopUpdating(); | 240 stopUpdating(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void Geolocation::requestUsesCachedPosition(GeoNotifier* notifier) { | 243 void Geolocation::requestUsesCachedPosition(GeoNotifier* notifier) { |
| 244 DCHECK(isAllowed()); | 244 DCHECK(isAllowed()); |
| 245 | 245 |
| 246 notifier->runSuccessCallback(m_lastPosition); | 246 notifier->runSuccessCallback(m_lastPosition); |
| 247 | 247 |
| 248 // If this is a one-shot request, stop it. Otherwise, if the watch still | 248 // If this is a one-shot request, stop it. Otherwise, if the watch still |
| 249 // exists, start the service to get updates. | 249 // exists, start the service to get updates. |
| 250 if (m_oneShots.contains(notifier)) { | 250 if (m_oneShots.contains(notifier)) { |
| 251 m_oneShots.remove(notifier); | 251 m_oneShots.erase(notifier); |
| 252 } else if (m_watchers.contains(notifier)) { | 252 } else if (m_watchers.contains(notifier)) { |
| 253 if (notifier->options().timeout()) | 253 if (notifier->options().timeout()) |
| 254 startUpdating(notifier); | 254 startUpdating(notifier); |
| 255 notifier->startTimer(); | 255 notifier->startTimer(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 if (!hasListeners()) | 258 if (!hasListeners()) |
| 259 stopUpdating(); | 259 stopUpdating(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void Geolocation::requestTimedOut(GeoNotifier* notifier) { | 262 void Geolocation::requestTimedOut(GeoNotifier* notifier) { |
| 263 // If this is a one-shot request, stop it. | 263 // If this is a one-shot request, stop it. |
| 264 m_oneShots.remove(notifier); | 264 m_oneShots.erase(notifier); |
| 265 | 265 |
| 266 if (!hasListeners()) | 266 if (!hasListeners()) |
| 267 stopUpdating(); | 267 stopUpdating(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 bool Geolocation::haveSuitableCachedPosition(const PositionOptions& options) { | 270 bool Geolocation::haveSuitableCachedPosition(const PositionOptions& options) { |
| 271 if (!m_lastPosition) | 271 if (!m_lastPosition) |
| 272 return false; | 272 return false; |
| 273 DCHECK(isAllowed()); | 273 DCHECK(isAllowed()); |
| 274 if (!options.maximumAge()) | 274 if (!options.maximumAge()) |
| 275 return false; | 275 return false; |
| 276 DOMTimeStamp currentTimeMillis = convertSecondsToDOMTimeStamp(currentTime()); | 276 DOMTimeStamp currentTimeMillis = convertSecondsToDOMTimeStamp(currentTime()); |
| 277 return m_lastPosition->timestamp() > currentTimeMillis - options.maximumAge(); | 277 return m_lastPosition->timestamp() > currentTimeMillis - options.maximumAge(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void Geolocation::clearWatch(int watchID) { | 280 void Geolocation::clearWatch(int watchID) { |
| 281 if (watchID <= 0) | 281 if (watchID <= 0) |
| 282 return; | 282 return; |
| 283 | 283 |
| 284 if (GeoNotifier* notifier = m_watchers.find(watchID)) | 284 if (GeoNotifier* notifier = m_watchers.find(watchID)) |
| 285 m_pendingForPermissionNotifiers.remove(notifier); | 285 m_pendingForPermissionNotifiers.erase(notifier); |
| 286 m_watchers.remove(watchID); | 286 m_watchers.remove(watchID); |
| 287 | 287 |
| 288 if (!hasListeners()) | 288 if (!hasListeners()) |
| 289 stopUpdating(); | 289 stopUpdating(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 void Geolocation::onGeolocationPermissionUpdated( | 292 void Geolocation::onGeolocationPermissionUpdated( |
| 293 mojom::blink::PermissionStatus status) { | 293 mojom::blink::PermissionStatus status) { |
| 294 // This may be due to either a new position from the service, or a cached | 294 // This may be due to either a new position from the service, or a cached |
| 295 // position. | 295 // position. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 PositionError::kPositionUnavailable, failedToStartServiceErrorMessage); | 541 PositionError::kPositionUnavailable, failedToStartServiceErrorMessage); |
| 542 error->setIsFatal(true); | 542 error->setIsFatal(true); |
| 543 handleError(error); | 543 handleError(error); |
| 544 } | 544 } |
| 545 | 545 |
| 546 void Geolocation::onPermissionConnectionError() { | 546 void Geolocation::onPermissionConnectionError() { |
| 547 onGeolocationPermissionUpdated(mojom::blink::PermissionStatus::DENIED); | 547 onGeolocationPermissionUpdated(mojom::blink::PermissionStatus::DENIED); |
| 548 } | 548 } |
| 549 | 549 |
| 550 } // namespace blink | 550 } // namespace blink |
| OLD | NEW |