Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: Source/modules/geolocation/Geolocation.cpp

Issue 22572005: Remove all uses of the ASCIILiteral class. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rm it from wtf Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/crypto/Key.cpp ('k') | Source/modules/geolocation/GeolocationController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 if (m_useCachedPosition) { 159 if (m_useCachedPosition) {
160 // Clear the cached position flag in case this is a watch request, which 160 // Clear the cached position flag in case this is a watch request, which
161 // will continue to run. 161 // will continue to run.
162 m_useCachedPosition = false; 162 m_useCachedPosition = false;
163 m_geolocation->requestUsesCachedPosition(this); 163 m_geolocation->requestUsesCachedPosition(this);
164 return; 164 return;
165 } 165 }
166 166
167 if (m_errorCallback) { 167 if (m_errorCallback) {
168 RefPtr<PositionError> error = PositionError::create(PositionError::TIMEO UT, ASCIILiteral("Timeout expired")); 168 RefPtr<PositionError> error = PositionError::create(PositionError::TIMEO UT, "Timeout expired");
169 m_errorCallback->handleEvent(error.get()); 169 m_errorCallback->handleEvent(error.get());
170 } 170 }
171 m_geolocation->requestTimedOut(this); 171 m_geolocation->requestTimedOut(this);
172 } 172 }
173 173
174 bool Geolocation::Watchers::add(int id, PassRefPtr<GeoNotifier> prpNotifier) 174 bool Geolocation::Watchers::add(int id, PassRefPtr<GeoNotifier> prpNotifier)
175 { 175 {
176 ASSERT(id > 0); 176 ASSERT(id > 0);
177 RefPtr<GeoNotifier> notifier = prpNotifier; 177 RefPtr<GeoNotifier> notifier = prpNotifier;
178 178
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 watchID = m_scriptExecutionContext->circularSequentialID(); 313 watchID = m_scriptExecutionContext->circularSequentialID();
314 } while (!m_watchers.add(watchID, notifier)); 314 } while (!m_watchers.add(watchID, notifier));
315 return watchID; 315 return watchID;
316 } 316 }
317 317
318 void Geolocation::startRequest(GeoNotifier *notifier) 318 void Geolocation::startRequest(GeoNotifier *notifier)
319 { 319 {
320 // Check whether permissions have already been denied. Note that if this is the case, 320 // Check whether permissions have already been denied. Note that if this is the case,
321 // the permission state can not change again in the lifetime of this page. 321 // the permission state can not change again in the lifetime of this page.
322 if (isDenied()) 322 if (isDenied())
323 notifier->setFatalError(PositionError::create(PositionError::PERMISSION_ DENIED, ASCIILiteral(permissionDeniedErrorMessage))); 323 notifier->setFatalError(PositionError::create(PositionError::PERMISSION_ DENIED, permissionDeniedErrorMessage));
324 else if (haveSuitableCachedPosition(notifier->options())) 324 else if (haveSuitableCachedPosition(notifier->options()))
325 notifier->setUseCachedPosition(); 325 notifier->setUseCachedPosition();
326 else if (notifier->hasZeroTimeout()) 326 else if (notifier->hasZeroTimeout())
327 notifier->startTimerIfNeeded(); 327 notifier->startTimerIfNeeded();
328 else if (!isAllowed()) { 328 else if (!isAllowed()) {
329 // if we don't yet have permission, request for permission before callin g startUpdating() 329 // if we don't yet have permission, request for permission before callin g startUpdating()
330 m_pendingForPermissionNotifiers.add(notifier); 330 m_pendingForPermissionNotifiers.add(notifier);
331 requestPermission(); 331 requestPermission();
332 } else if (startUpdating(notifier)) 332 } else if (startUpdating(notifier))
333 notifier->startTimerIfNeeded(); 333 notifier->startTimerIfNeeded();
334 else 334 else
335 notifier->setFatalError(PositionError::create(PositionError::POSITION_UN AVAILABLE, ASCIILiteral(failedToStartServiceErrorMessage))); 335 notifier->setFatalError(PositionError::create(PositionError::POSITION_UN AVAILABLE, failedToStartServiceErrorMessage));
336 } 336 }
337 337
338 void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier) 338 void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier)
339 { 339 {
340 // This request has failed fatally. Remove it from our lists. 340 // This request has failed fatally. Remove it from our lists.
341 m_oneShots.remove(notifier); 341 m_oneShots.remove(notifier);
342 m_watchers.remove(notifier); 342 m_watchers.remove(notifier);
343 343
344 if (!hasListeners()) 344 if (!hasListeners())
345 stopUpdating(); 345 stopUpdating();
346 } 346 }
347 347
348 void Geolocation::requestUsesCachedPosition(GeoNotifier* notifier) 348 void Geolocation::requestUsesCachedPosition(GeoNotifier* notifier)
349 { 349 {
350 // This is called asynchronously, so the permissions could have been denied 350 // This is called asynchronously, so the permissions could have been denied
351 // since we last checked in startRequest. 351 // since we last checked in startRequest.
352 if (isDenied()) { 352 if (isDenied()) {
353 notifier->setFatalError(PositionError::create(PositionError::PERMISSION_ DENIED, ASCIILiteral(permissionDeniedErrorMessage))); 353 notifier->setFatalError(PositionError::create(PositionError::PERMISSION_ DENIED, permissionDeniedErrorMessage));
354 return; 354 return;
355 } 355 }
356 356
357 m_requestsAwaitingCachedPosition.add(notifier); 357 m_requestsAwaitingCachedPosition.add(notifier);
358 358
359 // If permissions are allowed, make the callback 359 // If permissions are allowed, make the callback
360 if (isAllowed()) { 360 if (isAllowed()) {
361 makeCachedPositionCallbacks(); 361 makeCachedPositionCallbacks();
362 return; 362 return;
363 } 363 }
(...skipping 13 matching lines...) Expand all
377 notifier->runSuccessCallback(lastPosition()); 377 notifier->runSuccessCallback(lastPosition());
378 378
379 // If this is a one-shot request, stop it. Otherwise, if the watch still 379 // If this is a one-shot request, stop it. Otherwise, if the watch still
380 // exists, start the service to get updates. 380 // exists, start the service to get updates.
381 if (m_oneShots.contains(notifier)) 381 if (m_oneShots.contains(notifier))
382 m_oneShots.remove(notifier); 382 m_oneShots.remove(notifier);
383 else if (m_watchers.contains(notifier)) { 383 else if (m_watchers.contains(notifier)) {
384 if (notifier->hasZeroTimeout() || startUpdating(notifier)) 384 if (notifier->hasZeroTimeout() || startUpdating(notifier))
385 notifier->startTimerIfNeeded(); 385 notifier->startTimerIfNeeded();
386 else 386 else
387 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, ASCIILiteral(failedToStartServiceErrorMessage))); 387 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, failedToStartServiceErrorMessage));
388 } 388 }
389 } 389 }
390 390
391 m_requestsAwaitingCachedPosition.clear(); 391 m_requestsAwaitingCachedPosition.clear();
392 392
393 if (!hasListeners()) 393 if (!hasListeners())
394 stopUpdating(); 394 stopUpdating();
395 } 395 }
396 396
397 void Geolocation::requestTimedOut(GeoNotifier* notifier) 397 void Geolocation::requestTimedOut(GeoNotifier* notifier)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 m_allowGeolocation = allowed ? Yes : No; 439 m_allowGeolocation = allowed ? Yes : No;
440 440
441 // Permission request was made during the startRequest process 441 // Permission request was made during the startRequest process
442 if (!m_pendingForPermissionNotifiers.isEmpty()) { 442 if (!m_pendingForPermissionNotifiers.isEmpty()) {
443 handlePendingPermissionNotifiers(); 443 handlePendingPermissionNotifiers();
444 m_pendingForPermissionNotifiers.clear(); 444 m_pendingForPermissionNotifiers.clear();
445 return; 445 return;
446 } 446 }
447 447
448 if (!isAllowed()) { 448 if (!isAllowed()) {
449 RefPtr<PositionError> error = PositionError::create(PositionError::PERMI SSION_DENIED, ASCIILiteral(permissionDeniedErrorMessage)); 449 RefPtr<PositionError> error = PositionError::create(PositionError::PERMI SSION_DENIED, permissionDeniedErrorMessage);
450 error->setIsFatal(true); 450 error->setIsFatal(true);
451 handleError(error.get()); 451 handleError(error.get());
452 m_requestsAwaitingCachedPosition.clear(); 452 m_requestsAwaitingCachedPosition.clear();
453 return; 453 return;
454 } 454 }
455 455
456 // If the service has a last position, use it to call back for all requests. 456 // If the service has a last position, use it to call back for all requests.
457 // If any of the requests are waiting for permission for a cached position, 457 // If any of the requests are waiting for permission for a cached position,
458 // the position from the service will be at least as fresh. 458 // the position from the service will be at least as fresh.
459 if (lastPosition()) 459 if (lastPosition())
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 void Geolocation::stopTimers() 505 void Geolocation::stopTimers()
506 { 506 {
507 stopTimersForOneShots(); 507 stopTimersForOneShots();
508 stopTimersForWatchers(); 508 stopTimersForWatchers();
509 } 509 }
510 510
511 void Geolocation::cancelRequests(GeoNotifierVector& notifiers) 511 void Geolocation::cancelRequests(GeoNotifierVector& notifiers)
512 { 512 {
513 GeoNotifierVector::const_iterator end = notifiers.end(); 513 GeoNotifierVector::const_iterator end = notifiers.end();
514 for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++ it) 514 for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++ it)
515 (*it)->setFatalError(PositionError::create(PositionError::POSITION_UNAVA ILABLE, ASCIILiteral(framelessDocumentErrorMessage))); 515 (*it)->setFatalError(PositionError::create(PositionError::POSITION_UNAVA ILABLE, framelessDocumentErrorMessage));
516 } 516 }
517 517
518 void Geolocation::cancelAllRequests() 518 void Geolocation::cancelAllRequests()
519 { 519 {
520 GeoNotifierVector copy; 520 GeoNotifierVector copy;
521 copyToVector(m_oneShots, copy); 521 copyToVector(m_oneShots, copy);
522 cancelRequests(copy); 522 cancelRequests(copy);
523 m_watchers.getNotifiersVector(copy); 523 m_watchers.getNotifiersVector(copy);
524 cancelRequests(copy); 524 cancelRequests(copy);
525 } 525 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 GeoNotifierSet::const_iterator end = m_pendingForPermissionNotifiers.end(); 664 GeoNotifierSet::const_iterator end = m_pendingForPermissionNotifiers.end();
665 for (GeoNotifierSet::const_iterator iter = m_pendingForPermissionNotifiers.b egin(); iter != end; ++iter) { 665 for (GeoNotifierSet::const_iterator iter = m_pendingForPermissionNotifiers.b egin(); iter != end; ++iter) {
666 GeoNotifier* notifier = iter->get(); 666 GeoNotifier* notifier = iter->get();
667 667
668 if (isAllowed()) { 668 if (isAllowed()) {
669 // start all pending notification requests as permission granted. 669 // start all pending notification requests as permission granted.
670 // The notifier is always ref'ed by m_oneShots or m_watchers. 670 // The notifier is always ref'ed by m_oneShots or m_watchers.
671 if (startUpdating(notifier)) 671 if (startUpdating(notifier))
672 notifier->startTimerIfNeeded(); 672 notifier->startTimerIfNeeded();
673 else 673 else
674 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, ASCIILiteral(failedToStartServiceErrorMessage))); 674 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, failedToStartServiceErrorMessage));
675 } else 675 } else {
676 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, ASCIILiteral(permissionDeniedErrorMessage))); 676 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, permissionDeniedErrorMessage));
677 }
677 } 678 }
678 } 679 }
679 680
680 } // namespace WebCore 681 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/crypto/Key.cpp ('k') | Source/modules/geolocation/GeolocationController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698