Chromium Code Reviews| Index: chrome/browser/extensions/api/messaging/message_service.cc |
| diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc |
| index 11ec6922b2efcbb9ac098ff60c3801d6907e992b..c71ceca297a6715e907e03f003213fdfbeb5ed47 100644 |
| --- a/chrome/browser/extensions/api/messaging/message_service.cc |
| +++ b/chrome/browser/extensions/api/messaging/message_service.cc |
| @@ -193,6 +193,13 @@ static content::RenderProcessHost* GetExtensionProcess( |
| } // namespace |
| +void MessageService::MessagePort::WillConnectToPort(const MessagePort& port) {} |
| + |
| +bool MessageService::MessagePort::HasFrame( |
| + content::RenderFrameHost* rfh) const { |
| + return false; |
| +} |
| + |
| // static |
| void MessageService::AllocatePortIdPair(int* port1, int* port2) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| @@ -569,6 +576,13 @@ void MessageService::OpenChannelImpl(BrowserContext* browser_context, |
| if (!opener->IsValidPort()) |
| return; |
| + // Remove duplicate frames. |
|
Devlin
2016/01/13 17:37:22
Nit: since all this method does is check for dupli
robwu
2016/01/13 19:56:20
Done (renamed to RemoveCommonFrames).
|
| + params->receiver->WillConnectToPort(*opener); |
| + if (!params->receiver->IsValidPort()) { |
| + opener->DispatchOnDisconnect(kReceivingEndDoesntExistError); |
| + return; |
| + } |
| + |
| MessageChannel* channel(new MessageChannel()); |
| channel->opener.reset(opener.release()); |
| channel->receiver.reset(params->receiver.release()); |
| @@ -708,6 +722,9 @@ void MessageService::CloseChannelImpl( |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| MessageChannel* channel = channel_iter->second; |
| + // Remove from map to make sure that it is impossible for CloseChannelImpl to |
| + // run twice for the same channel. |
| + channels_.erase(channel_iter); |
| // Notify the other side. |
| if (notify_other_port) { |
| @@ -720,8 +737,7 @@ void MessageService::CloseChannelImpl( |
| channel->opener->DecrementLazyKeepaliveCount(); |
| channel->receiver->DecrementLazyKeepaliveCount(); |
| - delete channel_iter->second; |
| - channels_.erase(channel_iter); |
| + delete channel; |
| } |
| void MessageService::PostMessage(int source_port_id, const Message& message) { |