summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_message_service.h
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-01 15:12:56 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-01 15:12:56 +0000
commitc02b7c98f49e94910d622162455293e52841089e (patch)
tree709d9ab5c72a99198cb47ebd46f3b07a580bb280 /chrome/browser/extensions/extension_message_service.h
parent43b24b69d766df5f801daa86656c50d361fe8a6b (diff)
downloadchromium_src-c02b7c98f49e94910d622162455293e52841089e.zip
chromium_src-c02b7c98f49e94910d622162455293e52841089e.tar.gz
chromium_src-c02b7c98f49e94910d622162455293e52841089e.tar.bz2
Only send events to renderers that are listening to an event.Notify browser when a renderer is listening to an event.
Review URL: http://codereview.chromium.org/100214 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_message_service.h')
-rwxr-xr-xchrome/browser/extensions/extension_message_service.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_message_service.h b/chrome/browser/extensions/extension_message_service.h
index 0c8d63f..52b1682 100755
--- a/chrome/browser/extensions/extension_message_service.h
+++ b/chrome/browser/extensions/extension_message_service.h
@@ -40,6 +40,10 @@ class ExtensionMessageService : public NotificationObserver {
void RegisterExtension(const std::string& extension_id,
int render_process_id);
+ // Add or remove |render_process_pid| as a listener for |event_name|.
+ void AddEventListener(std::string event_name, int render_process_id);
+ void RemoveEventListener(std::string event_name, int render_process_id);
+
// --- IO thread only:
// Given an extension's ID, opens a channel between the given renderer "port"
@@ -76,6 +80,16 @@ class ExtensionMessageService : public NotificationObserver {
// code (especially sending messages) to avoid deadlock.
Lock process_ids_lock_;
+ // A map between an event name and a set of process id's that are listening
+ // to that event.
+ typedef std::map<std::string, std::set<int> > ListenerMap;
+ ListenerMap listeners_;
+
+ // Protects listeners_ map, since it can be accessed from either the IO or
+ // UI thread. Be careful not to hold this lock when calling external code
+ // (especially sending messages) to avoid deadlock.
+ Lock listener_lock_;
+
// --- IO thread only:
// The connection between two renderers.
@@ -101,6 +115,8 @@ class ExtensionMessageService : public NotificationObserver {
// Set to true when we start observing this notification.
bool observing_renderer_shutdown_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService);
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_