summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_message_service.cc
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-16 22:27:21 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-16 22:27:21 +0000
commit69f1be8a969af735b2173349c9bd57a174a9bf16 (patch)
treebf6bda97490b5884ca6a15f9c1b7d923bcb40886 /chrome/browser/extensions/extension_message_service.cc
parent1c86467953f1e633be06ca65e3a38113dcbe63e8 (diff)
downloadchromium_src-69f1be8a969af735b2173349c9bd57a174a9bf16.zip
chromium_src-69f1be8a969af735b2173349c9bd57a174a9bf16.tar.gz
chromium_src-69f1be8a969af735b2173349c9bd57a174a9bf16.tar.bz2
Remove ExtensionProcessManager and move its functionality onto
ExtensionsService. Also add "chrome-extension" to the list of schemes that BrowsingInstance groups per-site, instead of per-tab. This means that navigating to an extension URL will use the same process as a running extension toolstrip. Review URL: http://codereview.chromium.org/77002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13887 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_message_service.cc')
-rwxr-xr-xchrome/browser/extensions/extension_message_service.cc50
1 files changed, 39 insertions, 11 deletions
diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc
index 3c2c1de..a49cf47 100755
--- a/chrome/browser/extensions/extension_message_service.cc
+++ b/chrome/browser/extensions/extension_message_service.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/extensions/extension_message_service.h"
#include "base/singleton.h"
+#include "base/values.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extension.h"
#include "chrome/browser/extensions/extension_view.h"
@@ -36,6 +37,13 @@ struct SingletonData {
};
} // namespace
+// Since ExtensionMessageService is a collection of Singletons, we don't need to
+// grab a reference to it when creating Tasks involving it.
+template <> struct RunnableMethodTraits<ExtensionMessageService> {
+ static void RetainCallee(ExtensionMessageService*) {}
+ static void ReleaseCallee(ExtensionMessageService*) {}
+};
+
// static
ExtensionMessageService* ExtensionMessageService::GetInstance(
URLRequestContext* context) {
@@ -54,17 +62,6 @@ ExtensionMessageService::ExtensionMessageService()
: next_port_id_(0) {
}
-std::set<int> ExtensionMessageService::GetUniqueProcessIds() {
- std::set<int> ids;
- ProcessIDMap::iterator it;
- AutoLock lock(renderers_lock_);
-
- for (it = process_ids_.begin(); it != process_ids_.end(); it++) {
- ids.insert(it->second);
- }
- return ids;
-}
-
void ExtensionMessageService::RegisterExtension(
const std::string& extension_id, int render_process_id) {
AutoLock lock(renderers_lock_);
@@ -137,6 +134,37 @@ void ExtensionMessageService::PostMessageFromRenderer(
dest->Send(new ViewMsg_ExtensionHandleMessage(message, source_port_id));
}
+void ExtensionMessageService::DispatchEventToRenderers(
+ const std::string& event_name, const std::string& event_args) {
+ MessageLoop* io_thread = ChromeThread::GetMessageLoop(ChromeThread::IO);
+ if (MessageLoop::current() != io_thread) {
+ // Do the actual work on the IO thread.
+ io_thread->PostTask(FROM_HERE, NewRunnableMethod(this,
+ &ExtensionMessageService::DispatchEventToRenderers,
+ event_name, event_args));
+ return;
+ }
+
+ // TODO(mpcomplete): this set should probably just be a member var.
+ std::set<ResourceMessageFilter*> renderer_set;
+ {
+ ProcessIDMap::iterator it;
+ AutoLock lock(renderers_lock_);
+
+ for (it = process_ids_.begin(); it != process_ids_.end(); it++) {
+ RendererMap::iterator renderer = renderers_.find(it->second);
+ if (renderer != renderers_.end())
+ renderer_set.insert(renderer->second);
+ }
+ }
+
+ std::set<ResourceMessageFilter*>::iterator renderer;
+ for (renderer = renderer_set.begin(); renderer != renderer_set.end();
+ ++renderer) {
+ (*renderer)->Send(new ViewMsg_ExtensionHandleEvent(event_name, event_args));
+ }
+}
+
void ExtensionMessageService::RendererReady(ResourceMessageFilter* filter) {
AutoLock lock(renderers_lock_);
DCHECK(renderers_.find(filter->GetProcessId()) == renderers_.end());