Index: chrome/browser/geolocation/geolocation_dispatcher_host.cc |
diff --git a/chrome/browser/geolocation/geolocation_dispatcher_host_old.cc b/chrome/browser/geolocation/geolocation_dispatcher_host.cc |
similarity index 73% |
rename from chrome/browser/geolocation/geolocation_dispatcher_host_old.cc |
rename to chrome/browser/geolocation/geolocation_dispatcher_host.cc |
index ca5298df5efe7c230e2596d748771e577f722937..4f4020b333d7181ed027c66a8f5f27119a64e3ff 100644 |
--- a/chrome/browser/geolocation/geolocation_dispatcher_host_old.cc |
+++ b/chrome/browser/geolocation/geolocation_dispatcher_host.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/geolocation/geolocation_dispatcher_host_old.h" |
+#include "chrome/browser/geolocation/geolocation_dispatcher_host.h" |
#include <map> |
#include <set> |
@@ -19,24 +19,21 @@ |
#include "ipc/ipc_message.h" |
namespace { |
-class GeolocationDispatcherHostOldImpl : public GeolocationDispatcherHostOld, |
- public GeolocationObserver { |
+class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost, |
+ public GeolocationObserver { |
public: |
- GeolocationDispatcherHostOldImpl( |
- int resource_message_filter_process_id, |
+ GeolocationDispatcherHostImpl( |
+ int render_process_id, |
GeolocationPermissionContext* geolocation_permission_context); |
- // GeolocationDispatcherHostOld |
- // Called to possibly handle the incoming IPC message. Returns true if |
- // handled. Called in the browser process. |
+ // GeolocationDispatcherHost |
virtual bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); |
- // GeolocationArbitrator::Delegate |
+ // GeolocationObserver |
virtual void OnLocationUpdate(const Geoposition& position); |
private: |
- friend class base::RefCountedThreadSafe<GeolocationDispatcherHostOldImpl>; |
- virtual ~GeolocationDispatcherHostOldImpl(); |
+ virtual ~GeolocationDispatcherHostImpl(); |
void OnRegisterDispatcher(int render_view_id); |
void OnUnregisterDispatcher(int render_view_id); |
@@ -55,7 +52,7 @@ class GeolocationDispatcherHostOldImpl : public GeolocationDispatcherHostOld, |
// options, based on |bridge_update_options_|. |
void RefreshGeolocationObserverOptions(); |
- int resource_message_filter_process_id_; |
+ int render_process_id_; |
scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; |
// Iterated when sending location updates to renderer processes. The fan out |
@@ -70,13 +67,13 @@ class GeolocationDispatcherHostOldImpl : public GeolocationDispatcherHostOld, |
// Only set whilst we are registered with the arbitrator. |
GeolocationProvider* location_provider_; |
- DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostOldImpl); |
+ DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostImpl); |
}; |
-GeolocationDispatcherHostOldImpl::GeolocationDispatcherHostOldImpl( |
- int resource_message_filter_process_id, |
+GeolocationDispatcherHostImpl::GeolocationDispatcherHostImpl( |
+ int render_process_id, |
GeolocationPermissionContext* geolocation_permission_context) |
- : resource_message_filter_process_id_(resource_message_filter_process_id), |
+ : render_process_id_(render_process_id), |
geolocation_permission_context_(geolocation_permission_context), |
location_provider_(NULL) { |
// This is initialized by ResourceMessageFilter. Do not add any non-trivial |
@@ -84,17 +81,17 @@ GeolocationDispatcherHostOldImpl::GeolocationDispatcherHostOldImpl( |
// a javascript geolocation object is actually initialized. |
} |
-GeolocationDispatcherHostOldImpl::~GeolocationDispatcherHostOldImpl() { |
+GeolocationDispatcherHostImpl::~GeolocationDispatcherHostImpl() { |
if (location_provider_) |
location_provider_->RemoveObserver(this); |
} |
-bool GeolocationDispatcherHostOldImpl::OnMessageReceived( |
+bool GeolocationDispatcherHostImpl::OnMessageReceived( |
const IPC::Message& msg, bool* msg_was_ok) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
*msg_was_ok = true; |
bool handled = true; |
- IPC_BEGIN_MESSAGE_MAP_EX(GeolocationDispatcherHostOldImpl, msg, *msg_was_ok) |
+ IPC_BEGIN_MESSAGE_MAP_EX(GeolocationDispatcherHostImpl, msg, *msg_was_ok) |
IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_RegisterDispatcher, |
OnRegisterDispatcher) |
IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_UnregisterDispatcher, |
@@ -116,103 +113,112 @@ bool GeolocationDispatcherHostOldImpl::OnMessageReceived( |
return handled; |
} |
-void GeolocationDispatcherHostOldImpl::OnLocationUpdate( |
+void GeolocationDispatcherHostImpl::OnLocationUpdate( |
const Geoposition& geoposition) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
for (std::set<int>::iterator it = geolocation_renderer_ids_.begin(); |
it != geolocation_renderer_ids_.end(); ++it) { |
IPC::Message* message = |
new ViewMsg_Geolocation_PositionUpdated(*it, geoposition); |
- CallRenderViewHost(resource_message_filter_process_id_, *it, |
+ CallRenderViewHost(render_process_id_, *it, |
&RenderViewHost::Send, message); |
} |
} |
-void GeolocationDispatcherHostOldImpl::OnRegisterDispatcher( |
+void GeolocationDispatcherHostImpl::OnRegisterDispatcher( |
int render_view_id) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
DCHECK_EQ(0u, geolocation_renderer_ids_.count(render_view_id)); |
geolocation_renderer_ids_.insert(render_view_id); |
} |
-void GeolocationDispatcherHostOldImpl::OnUnregisterDispatcher( |
+void GeolocationDispatcherHostImpl::OnUnregisterDispatcher( |
int render_view_id) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
DCHECK_EQ(1u, geolocation_renderer_ids_.count(render_view_id)); |
geolocation_renderer_ids_.erase(render_view_id); |
} |
-void GeolocationDispatcherHostOldImpl::OnRequestPermission( |
+void GeolocationDispatcherHostImpl::OnRequestPermission( |
int render_view_id, |
int bridge_id, |
const GURL& requesting_frame) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" |
+ DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
<< render_view_id << ":" << bridge_id; |
geolocation_permission_context_->RequestGeolocationPermission( |
- resource_message_filter_process_id_, render_view_id, bridge_id, |
+ render_process_id_, render_view_id, bridge_id, |
requesting_frame); |
} |
-void GeolocationDispatcherHostOldImpl::OnCancelPermissionRequest( |
+void GeolocationDispatcherHostImpl::OnCancelPermissionRequest( |
int render_view_id, |
int bridge_id, |
const GURL& requesting_frame) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" |
+ DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
<< render_view_id << ":" << bridge_id; |
geolocation_permission_context_->CancelGeolocationPermissionRequest( |
- resource_message_filter_process_id_, render_view_id, bridge_id, |
+ render_process_id_, render_view_id, bridge_id, |
requesting_frame); |
} |
-void GeolocationDispatcherHostOldImpl::OnStartUpdating( |
+void GeolocationDispatcherHostImpl::OnStartUpdating( |
int render_view_id, |
int bridge_id, |
const GURL& requesting_frame, |
bool enable_high_accuracy) { |
+#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
+ // StartUpdating() can be invoked as a result of high-accuracy mode |
+ // being enabled / disabled. No need to register the dispatcher again. |
+ if (!geolocation_renderer_ids_.count(render_view_id)) |
+ OnRegisterDispatcher(render_view_id); |
+#endif |
// WebKit sends the startupdating request before checking permissions, to |
// optimize the no-location-available case and reduce latency in the success |
// case (location lookup happens in parallel with the permission request). |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" |
+ DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
<< render_view_id << ":" << bridge_id; |
bridge_update_options_[std::make_pair(render_view_id, bridge_id)] = |
GeolocationObserverOptions(enable_high_accuracy); |
geolocation_permission_context_->StartUpdatingRequested( |
- resource_message_filter_process_id_, render_view_id, bridge_id, |
+ render_process_id_, render_view_id, bridge_id, |
requesting_frame); |
RefreshGeolocationObserverOptions(); |
} |
-void GeolocationDispatcherHostOldImpl::OnStopUpdating(int render_view_id, |
+void GeolocationDispatcherHostImpl::OnStopUpdating(int render_view_id, |
int bridge_id) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" |
+ DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
<< render_view_id << ":" << bridge_id; |
if (bridge_update_options_.erase(std::make_pair(render_view_id, bridge_id))) |
RefreshGeolocationObserverOptions(); |
geolocation_permission_context_->StopUpdatingRequested( |
- resource_message_filter_process_id_, render_view_id, bridge_id); |
+ render_process_id_, render_view_id, bridge_id); |
+#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
+ OnUnregisterDispatcher(render_view_id); |
+#endif |
} |
-void GeolocationDispatcherHostOldImpl::OnSuspend(int render_view_id, |
+void GeolocationDispatcherHostImpl::OnSuspend(int render_view_id, |
int bridge_id) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" |
+ DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
<< render_view_id << ":" << bridge_id; |
// TODO(bulach): connect this with GeolocationArbitrator. |
} |
-void GeolocationDispatcherHostOldImpl::OnResume(int render_view_id, |
+void GeolocationDispatcherHostImpl::OnResume(int render_view_id, |
int bridge_id) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" |
+ DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
<< render_view_id << ":" << bridge_id; |
// TODO(bulach): connect this with GeolocationArbitrator. |
} |
-void GeolocationDispatcherHostOldImpl::RefreshGeolocationObserverOptions() { |
+void GeolocationDispatcherHostImpl::RefreshGeolocationObserverOptions() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
if (bridge_update_options_.empty()) { |
if (location_provider_) { |
@@ -230,10 +236,10 @@ void GeolocationDispatcherHostOldImpl::RefreshGeolocationObserverOptions() { |
} |
} // namespace |
-GeolocationDispatcherHostOld* GeolocationDispatcherHostOld::New( |
- int resource_message_filter_process_id, |
+GeolocationDispatcherHost* GeolocationDispatcherHost::New( |
+ int render_process_id, |
GeolocationPermissionContext* geolocation_permission_context) { |
- return new GeolocationDispatcherHostOldImpl( |
- resource_message_filter_process_id, |
+ return new GeolocationDispatcherHostImpl( |
+ render_process_id, |
geolocation_permission_context); |
} |