summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_message_service.h
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-23 18:37:08 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-23 18:37:08 +0000
commit1706d76540b092bda26d7101709cf3906e22de91 (patch)
tree59bda7db915e049b7a5f77e63a355e8f4b0ff52e /chrome/browser/extensions/extension_message_service.h
parentdd07d60bc0f068a4749c91b481ccc948e1b00483 (diff)
downloadchromium_src-1706d76540b092bda26d7101709cf3906e22de91.zip
chromium_src-1706d76540b092bda26d7101709cf3906e22de91.tar.gz
chromium_src-1706d76540b092bda26d7101709cf3906e22de91.tar.bz2
Arrange so ExtensionMessageService::RendererReady is called on the IO thread.
This fixes a bug where it wouldn't notice when a renderer died because it was observing the notification on the wrong thread. This also simplifies some logic in ExtensionMessageService. Review URL: http://codereview.chromium.org/88002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14336 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_message_service.h')
-rwxr-xr-xchrome/browser/extensions/extension_message_service.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/chrome/browser/extensions/extension_message_service.h b/chrome/browser/extensions/extension_message_service.h
index d4eb856..0c8d63f 100755
--- a/chrome/browser/extensions/extension_message_service.h
+++ b/chrome/browser/extensions/extension_message_service.h
@@ -52,16 +52,16 @@ class ExtensionMessageService : public NotificationObserver {
void PostMessageFromRenderer(int port_id, const std::string& message,
ResourceMessageFilter* source);
- // --- UI or IO thread:
-
// Called to let us know that a renderer has been started.
- void RendererReady(ResourceMessageFilter* filter);
+ void RendererReady(ResourceMessageFilter* renderer);
// NotificationObserver interface.
void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
+ // --- UI or IO thread:
+
// Send an event to every registered extension renderer.
void DispatchEventToRenderers(
const std::string& event_name, const std::string& event_args);
@@ -71,15 +71,10 @@ class ExtensionMessageService : public NotificationObserver {
typedef std::map<std::string, int> ProcessIDMap;
ProcessIDMap process_ids_;
- // A map of render_process_id to its corresponding message filter, which we
- // use for sending messages.
- typedef std::map<int, ResourceMessageFilter*> RendererMap;
- RendererMap renderers_;
-
- // Protects the two maps above, since each can be accessed on the IO thread
+ // Protects the process_ids map, since it can be accessed on the IO thread
// or UI thread. Be careful not to hold this lock when calling external
// code (especially sending messages) to avoid deadlock.
- Lock renderers_lock_;
+ Lock process_ids_lock_;
// --- IO thread only:
@@ -96,8 +91,16 @@ class ExtensionMessageService : public NotificationObserver {
// For generating unique channel IDs.
int next_port_id_;
- // For tracking the ResourceMessageFilters we are observing.
- std::set<ResourceMessageFilter*> filters_;
+ // A map of render_process_id to its corresponding message filter, which we
+ // use for sending messages.
+ typedef std::map<int, ResourceMessageFilter*> RendererMap;
+ RendererMap renderers_;
+
+ // A unique list of renderers that we are aware of.
+ std::set<ResourceMessageFilter*> renderers_unique_;
+
+ // Set to true when we start observing this notification.
+ bool observing_renderer_shutdown_;
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_