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

Unified Diff: Source/modules/geolocation/testing/GeolocationClientMock.cpp

Issue 256843004: Get the WebGeolocationClient from WebFrameClient instead of WebViewClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix linking errors Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/geolocation/testing/GeolocationClientMock.cpp
diff --git a/Source/modules/geolocation/testing/GeolocationClientMock.cpp b/Source/modules/geolocation/testing/GeolocationClientMock.cpp
index bf048f8946a933aba3e93df7784e5da43f9377f5..47dd046951af4272534bce5e93494871f71068b4 100644
--- a/Source/modules/geolocation/testing/GeolocationClientMock.cpp
+++ b/Source/modules/geolocation/testing/GeolocationClientMock.cpp
@@ -39,8 +39,7 @@
namespace WebCore {
GeolocationClientMock::GeolocationClientMock()
- : m_controller(0)
- , m_hasError(false)
+ : m_hasError(false)
, m_controllerTimer(this, &GeolocationClientMock::controllerTimerFired)
, m_permissionTimer(this, &GeolocationClientMock::permissionTimerFired)
, m_isActive(false)
@@ -53,12 +52,6 @@ GeolocationClientMock::~GeolocationClientMock()
ASSERT(!m_isActive);
}
-void GeolocationClientMock::setController(GeolocationController *controller)
-{
- ASSERT(controller && !m_controller);
- m_controller = controller;
-}
-
void GeolocationClientMock::setPosition(PassRefPtrWillBeRawPtr<GeolocationPosition> position)
{
m_lastPosition = position;
@@ -100,6 +93,16 @@ void GeolocationClientMock::cancelPermissionRequest(Geolocation* geolocation)
m_permissionTimer.stop();
}
+void GeolocationClientMock::controllerForTestAdded(GeolocationController* controller)
+{
+ m_controllers.add(controller);
+}
+
+void GeolocationClientMock::controllerForTestRemoved(GeolocationController* controller)
+{
+ m_controllers.remove(controller);
+}
+
void GeolocationClientMock::asyncUpdatePermission()
{
ASSERT(m_permissionState != PermissionStateUnset);
@@ -155,7 +158,6 @@ GeolocationPosition* GeolocationClientMock::lastPosition()
void GeolocationClientMock::asyncUpdateController()
{
- ASSERT(m_controller);
if (m_isActive && !m_controllerTimer.isActive())
m_controllerTimer.startOneShot(0, FROM_HERE);
}
@@ -163,13 +165,16 @@ void GeolocationClientMock::asyncUpdateController()
void GeolocationClientMock::controllerTimerFired(Timer<GeolocationClientMock>* timer)
{
ASSERT_UNUSED(timer, timer == &m_controllerTimer);
- ASSERT(m_controller);
+ // Make a copy of the set of controllers since it might be modified while iterating.
+ HashSet<GeolocationController*> controllers = m_controllers;
if (m_lastPosition.get()) {
ASSERT(!m_hasError);
- m_controller->positionChanged(m_lastPosition.get());
+ for (HashSet<GeolocationController*>::iterator it = controllers.begin(); it != controllers.end(); ++it)
+ (*it)->positionChanged(m_lastPosition.get());
} else if (m_hasError) {
- m_controller->errorOccurred(GeolocationError::create(GeolocationError::PositionUnavailable, m_errorMessage).get());
+ for (HashSet<GeolocationController*>::iterator it = controllers.begin(); it != controllers.end(); ++it)
+ (*it)->errorOccurred(GeolocationError::create(GeolocationError::PositionUnavailable, m_errorMessage).get());
}
}

Powered by Google App Engine
This is Rietveld 408576698