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

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

Issue 197054: Don't send the channel-disconnect message if the recipient is in the process (Closed)
Patch Set: raf's rewording is better Created 11 years, 3 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/extensions/extension_message_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_message_service.cc
diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc
index 95ff7f3b35a17c1f295f1b963d66e7f9bef71d26..c864efb9f8d1892b33be7122ae4bbbcd4a35f7e0 100644
--- a/chrome/browser/extensions/extension_message_service.cc
+++ b/chrome/browser/extensions/extension_message_service.cc
@@ -367,22 +367,23 @@ void ExtensionMessageService::CloseChannel(int port_id) {
// Note: The channel might be gone already, if the other side closed first.
MessageChannelMap::iterator it = channels_.find(GET_CHANNEL_ID(port_id));
if (it != channels_.end())
- CloseChannelImpl(it, port_id);
+ CloseChannelImpl(it, port_id, true);
}
void ExtensionMessageService::CloseChannelImpl(
- MessageChannelMap::iterator channel_iter, int closing_port_id) {
+ MessageChannelMap::iterator channel_iter, int closing_port_id,
+ bool notify_other_port) {
DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
// Notify the other side.
const MessagePort& port = IS_OPENER_PORT_ID(closing_port_id) ?
channel_iter->second->receiver : channel_iter->second->opener;
- DispatchOnDisconnect(port, GET_OPPOSITE_PORT_ID(closing_port_id));
+ if (notify_other_port)
+ DispatchOnDisconnect(port, GET_OPPOSITE_PORT_ID(closing_port_id));
channels_.erase(channel_iter);
}
-
void ExtensionMessageService::PostMessageFromRenderer(
int source_port_id, const std::string& message) {
DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
@@ -456,10 +457,16 @@ void ExtensionMessageService::OnSenderClosed(IPC::Message::Sender* sender) {
for (MessageChannelMap::iterator it = channels_.begin();
it != channels_.end(); ) {
MessageChannelMap::iterator current = it++;
+ // If both sides are the same renderer, and it is closing, there is no
+ // "other" port, so there's no need to notify it.
+ bool notify_other_port =
+ current->second->opener.sender != current->second->receiver.sender;
if (current->second->opener.sender == sender) {
- CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first));
+ CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first),
+ notify_other_port);
} else if (current->second->receiver.sender == sender) {
- CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first));
+ CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first),
+ notify_other_port);
}
}
}
« no previous file with comments | « chrome/browser/extensions/extension_message_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698