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

Unified Diff: chrome/browser/renderer_host/resource_message_filter.cc

Issue 3117024: Clean up ExtensionMessageService. (Closed)
Patch Set: comments fixed Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/resource_message_filter.cc
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 500212c0092a033d93bce10e4079d80d9e156374..125210b5fcdc5aab75289339609c6d8c572fba75 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -219,7 +219,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_(
@@ -1241,24 +1240,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 {
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698