Chromium Code Reviews| Index: content/browser/message_port_provider.cc |
| diff --git a/content/browser/message_port_provider.cc b/content/browser/message_port_provider.cc |
| index 12be06530fdaa872e592fe2b5e541241f2bc6cb8..7f0d8932f1e87ced26a695243201950cf1561520 100644 |
| --- a/content/browser/message_port_provider.cc |
| +++ b/content/browser/message_port_provider.cc |
| @@ -12,9 +12,11 @@ |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/common/view_messages.h" |
| +#include "content/public/browser/message_port_delegate.h" |
| namespace content { |
| +// static |
| void MessagePortProvider::PostMessageToFrame( |
| WebContents* web_contents, |
| const base::string16& source_origin, |
|
sgurun-gerrit only
2015/01/06 17:57:06
passing web_contents to IO thread is not safe. We
sgurun-gerrit only
2015/01/10 02:36:29
Done.
|
| @@ -48,23 +50,28 @@ void MessagePortProvider::PostMessageToFrame( |
| params)); |
| } |
| -void MessagePortProvider::CreateMessageChannel(WebContents* web_contents, |
| +// static |
| +void MessagePortProvider::CreateMessageChannel(MessagePortDelegate* delegate, |
| int* port1, |
| int* port2) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - |
| *port1 = 0; |
| *port2 = 0; |
| - |
| - RenderProcessHostImpl* rph = |
| - static_cast<RenderProcessHostImpl*>( |
| - web_contents->GetRenderProcessHost()); |
| - MessagePortMessageFilter* mf = rph->message_port_message_filter(); |
| MessagePortService* msp = MessagePortService::GetInstance(); |
| - msp->Create(mf->GetNextRoutingID(), mf, port1); |
| - msp->Create(mf->GetNextRoutingID(), mf, port2); |
| + msp->Create(MSG_ROUTING_NONE, delegate, port1); |
| + msp->Create(MSG_ROUTING_NONE, delegate, port2); |
| + // Update the routing number of the message ports to be equal to the message |
| + // port numbers. |
| + msp->UpdateMessagePort(*port1, delegate, *port1); |
| + msp->UpdateMessagePort(*port2, delegate, *port2); |
| msp->Entangle(*port1, *port2); |
| msp->Entangle(*port2, *port1); |
| } |
| +// static |
| +void MessagePortProvider::OnMessagePortDelegateClosing( |
| + MessagePortDelegate* delegate) { |
| + MessagePortService::GetInstance()->OnMessagePortDelegateClosing(delegate); |
| +} |
| + |
| } // namespace content |