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

Side by Side Diff: content/browser/message_port_provider.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Rebase Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/browser/message_port_provider.h" 5 #include "content/public/browser/message_port_provider.h"
6 6
7 #include "content/browser/browser_thread_impl.h" 7 #include "content/browser/browser_thread_impl.h"
8 #include "content/browser/message_port_message_filter.h"
9 #include "content/browser/message_port_service.h"
10 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
11 #include "content/browser/renderer_host/render_view_host_impl.h" 9 #include "content/browser/renderer_host/render_view_host_impl.h"
12 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/common/frame_messages.h" 11 #include "content/common/frame_messages.h"
14 #include "content/public/browser/message_port_delegate.h" 12 #include "content/public/browser/message_port_delegate.h"
15 13
16 #if defined(OS_ANDROID) 14 #if defined(OS_ANDROID)
17 #include "content/browser/android/app_web_message_port_service_impl.h" 15 #include "content/browser/android/app_web_message_port_service_impl.h"
18 #endif 16 #endif
19 17
20 namespace content { 18 namespace content {
21 19
22 // static 20 // static
23 void MessagePortProvider::PostMessageToFrame( 21 void MessagePortProvider::PostMessageToFrame(
24 WebContents* web_contents, 22 WebContents* web_contents,
25 const base::string16& source_origin, 23 const base::string16& source_origin,
26 const base::string16& target_origin, 24 const base::string16& target_origin,
27 const base::string16& data, 25 const base::string16& data,
28 const std::vector<int>& ports) { 26 const std::vector<MessagePort>& ports) {
29 DCHECK_CURRENTLY_ON(BrowserThread::UI); 27 DCHECK_CURRENTLY_ON(BrowserThread::UI);
30 28
31 #if defined(OS_ANDROID)
32 BrowserThread::PostTask(
33 BrowserThread::IO, FROM_HERE,
34 base::Bind(&content::AppWebMessagePortServiceImpl::RemoveSentPorts,
35 base::Unretained(AppWebMessagePortServiceImpl::GetInstance()),
36 ports));
37 #endif
38 FrameMsg_PostMessage_Params params; 29 FrameMsg_PostMessage_Params params;
39 params.is_data_raw_string = true; 30 params.is_data_raw_string = true;
40 params.data = data; 31 params.data = data;
41 params.source_routing_id = MSG_ROUTING_NONE; 32 params.source_routing_id = MSG_ROUTING_NONE;
42 params.source_origin = source_origin; 33 params.source_origin = source_origin;
43 params.target_origin = target_origin; 34 params.target_origin = target_origin;
44 params.message_ports = ports; 35 params.message_ports = ports;
45 36
46 RenderProcessHostImpl* rph = 37 RenderFrameHost* rfh = web_contents->GetMainFrame();
47 static_cast<RenderProcessHostImpl*>(web_contents->GetRenderProcessHost()); 38 rfh->Send(new FrameMsg_PostMessageEvent(rfh->GetRoutingID(), params));
48 BrowserThread::PostTask(
49 BrowserThread::IO, FROM_HERE,
50 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts,
51 rph->message_port_message_filter(),
52 web_contents->GetMainFrame()->GetRoutingID(), params));
53 } 39 }
54 40
55 #if defined(OS_ANDROID) 41 #if defined(OS_ANDROID)
56 // static 42 // static
57 AppWebMessagePortService* MessagePortProvider::GetAppWebMessagePortService() { 43 AppWebMessagePortService* MessagePortProvider::GetAppWebMessagePortService() {
58 return AppWebMessagePortServiceImpl::GetInstance(); 44 return AppWebMessagePortServiceImpl::GetInstance();
59 } 45 }
60 #endif 46 #endif
61 47
62 } // namespace content 48 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698