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

Unified Diff: chrome/browser/extensions/extension_message_service.h

Issue 100214: Only send events to renderers that are listening to an event.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | « no previous file | chrome/browser/extensions/extension_message_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_message_service.h
===================================================================
--- chrome/browser/extensions/extension_message_service.h (revision 14939)
+++ chrome/browser/extensions/extension_message_service.h (working copy)
@@ -40,6 +40,10 @@
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 @@
// 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 @@
// 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_
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_message_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698