diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 22:19:18 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 22:19:18 +0000 |
commit | fe3f29f3e13d5a045e6ee527f24055e8b2c24cb2 (patch) | |
tree | b3000efd91ad01c95c71c99543b6af23a0e4a494 /chrome/browser/renderer_host | |
parent | f1a83e1a79e3ccd8866bda864f1325910f4dc9bf (diff) | |
download | chromium_src-fe3f29f3e13d5a045e6ee527f24055e8b2c24cb2.zip chromium_src-fe3f29f3e13d5a045e6ee527f24055e8b2c24cb2.tar.gz chromium_src-fe3f29f3e13d5a045e6ee527f24055e8b2c24cb2.tar.bz2 |
Clean up ExtensionMessageService.
- Remove debugging cruft from an old bug that has been closed.
- Make it UI-thread only. This complicates ResourceMessageFilter a little, but
makes the EMS lifetime a lot easier to reason about.
BUG=no
TEST=covered by unit tests
Review URL: http://codereview.chromium.org/3117024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
4 files changed, 51 insertions, 28 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index d41c9c3..148fa6b 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -241,11 +241,6 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() { audio_renderer_host_->Destroy(); ClearTransportDIBCache(); - - NotificationService::current()->Notify( - NotificationType::EXTENSION_PORT_DELETED_DEBUG, - Source<IPC::Message::Sender>(this), - NotificationService::NoDetails()); } bool BrowserRenderProcessHost::Init(bool is_extensions_process) { diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 0ba65d6..a477c92 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -145,11 +145,6 @@ RenderViewHost::~RenderViewHost() { // Be sure to clean up any leftover state from cross-site requests. Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest( process()->id(), routing_id(), false); - - NotificationService::current()->Notify( - NotificationType::EXTENSION_PORT_DELETED_DEBUG, - Source<IPC::Message::Sender>(this), - NotificationService::NoDetails()); } bool RenderViewHost::CreateRenderView(const string16& frame_name) { diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index e7985a0..797ed3c 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -221,7 +221,6 @@ ResourceMessageFilter::ResourceMessageFilter( ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)), media_request_context_(profile->GetRequestContextForMedia()), extensions_request_context_(profile->GetRequestContextForExtensions()), - extensions_message_service_(profile->GetExtensionMessageService()), render_widget_helper_(render_widget_helper), audio_renderer_host_(audio_renderer_host), appcache_dispatcher_host_( @@ -1266,24 +1265,52 @@ void ResourceMessageFilter::OnOpenChannelToExtension( int routing_id, const std::string& source_extension_id, const std::string& target_extension_id, const std::string& channel_name, int* port_id) { - if (extensions_message_service_.get()) { - *port_id = extensions_message_service_-> - OpenChannelToExtension(routing_id, source_extension_id, - target_extension_id, channel_name, this); - } else { - *port_id = -1; - } + int port2_id; + ExtensionMessageService::AllocatePortIdPair(port_id, &port2_id); + + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod( + this, &ResourceMessageFilter::OpenChannelToExtensionOnUIThread, + id(), routing_id, port2_id, source_extension_id, + target_extension_id, channel_name)); +} + +void ResourceMessageFilter::OpenChannelToExtensionOnUIThread( + int source_process_id, int source_routing_id, + int receiver_port_id, + const std::string& source_extension_id, + const std::string& target_extension_id, + const std::string& channel_name) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + profile_->GetExtensionMessageService()->OpenChannelToExtension( + source_process_id, source_routing_id, receiver_port_id, + source_extension_id, target_extension_id, channel_name); } void ResourceMessageFilter::OnOpenChannelToTab( int routing_id, int tab_id, const std::string& extension_id, const std::string& channel_name, int* port_id) { - if (extensions_message_service_.get()) { - *port_id = extensions_message_service_-> - OpenChannelToTab(routing_id, tab_id, extension_id, channel_name, this); - } else { - *port_id = -1; - } + int port2_id; + ExtensionMessageService::AllocatePortIdPair(port_id, &port2_id); + + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod( + this, &ResourceMessageFilter::OpenChannelToTabOnUIThread, + id(), routing_id, port2_id, tab_id, extension_id, channel_name)); +} + +void ResourceMessageFilter::OpenChannelToTabOnUIThread( + int source_process_id, int source_routing_id, + int receiver_port_id, + int tab_id, + const std::string& extension_id, + const std::string& channel_name) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + profile_->GetExtensionMessageService()->OpenChannelToTab( + source_process_id, source_routing_id, receiver_port_id, + tab_id, extension_id, channel_name); } bool ResourceMessageFilter::CheckBenchmarkingEnabled() const { diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index ebd94a6..16e329b 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -35,7 +35,6 @@ class AudioRendererHost; class ChromeURLRequestContext; class DatabaseDispatcherHost; class DOMStorageDispatcherHost; -class ExtensionMessageService; struct FontDescriptor; class GeolocationDispatcherHost; class HostZoomMap; @@ -325,9 +324,19 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, const std::string& source_extension_id, const std::string& target_extension_id, const std::string& channel_name, int* port_id); + void OpenChannelToExtensionOnUIThread(int source_process_id, + int source_routing_id, + int receiver_port_id, + const std::string& source_extension_id, + const std::string& target_extension_id, + const std::string& channel_name); void OnOpenChannelToTab(int routing_id, int tab_id, const std::string& extension_id, const std::string& channel_name, int* port_id); + void OpenChannelToTabOnUIThread(int source_process_id, int source_routing_id, + int receiver_port_id, + int tab_id, const std::string& extension_id, + const std::string& channel_name); void OnCloseCurrentConnections(); void OnSetCacheMode(bool enabled); @@ -419,9 +428,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // A request context that holds a cookie store for chrome-extension URLs. scoped_refptr<URLRequestContextGetter> extensions_request_context_; - // Used for routing extension messages. - scoped_refptr<ExtensionMessageService> extensions_message_service_; - scoped_refptr<RenderWidgetHelper> render_widget_helper_; // Object that should take care of audio related resource requests. |