OLD | NEW |
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" | 8 #include "content/browser/message_port_message_filter.h" |
9 #include "content/browser/message_port_service.h" | 9 #include "content/browser/message_port_service.h" |
10 #include "content/browser/renderer_host/render_process_host_impl.h" | 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
11 #include "content/browser/renderer_host/render_view_host_impl.h" | 11 #include "content/browser/renderer_host/render_view_host_impl.h" |
12 #include "content/browser/web_contents/web_contents_impl.h" | 12 #include "content/browser/web_contents/web_contents_impl.h" |
13 #include "content/common/frame_messages.h" | 13 #include "content/common/frame_messages.h" |
14 #include "content/public/browser/message_port_delegate.h" | 14 #include "content/public/browser/message_port_delegate.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 // static | 18 // static |
19 void MessagePortProvider::PostMessageToFrame( | 19 void MessagePortProvider::PostMessageToFrame( |
20 WebContents* web_contents, | 20 WebContents* web_contents, |
21 const base::string16& source_origin, | 21 const base::string16& source_origin, |
22 const base::string16& target_origin, | 22 const base::string16& target_origin, |
23 const base::string16& data, | 23 const base::string16& data, |
24 const std::vector<TransferredMessagePort>& ports) { | 24 const std::vector<int>& ports) { |
25 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 25 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
26 | 26 |
27 FrameMsg_PostMessage_Params params; | 27 FrameMsg_PostMessage_Params params; |
28 params.is_data_raw_string = true; | 28 params.is_data_raw_string = true; |
29 params.data = data; | 29 params.data = data; |
30 params.source_routing_id = MSG_ROUTING_NONE; | 30 params.source_routing_id = MSG_ROUTING_NONE; |
31 params.source_origin = source_origin; | 31 params.source_origin = source_origin; |
32 params.target_origin = target_origin; | 32 params.target_origin = target_origin; |
33 params.message_ports = ports; | 33 params.message_ports = ports; |
34 | 34 |
(...skipping 20 matching lines...) Expand all Loading... |
55 // port numbers. | 55 // port numbers. |
56 msp->UpdateMessagePort(*port1, delegate, *port1); | 56 msp->UpdateMessagePort(*port1, delegate, *port1); |
57 msp->UpdateMessagePort(*port2, delegate, *port2); | 57 msp->UpdateMessagePort(*port2, delegate, *port2); |
58 msp->Entangle(*port1, *port2); | 58 msp->Entangle(*port1, *port2); |
59 msp->Entangle(*port2, *port1); | 59 msp->Entangle(*port2, *port1); |
60 } | 60 } |
61 | 61 |
62 // static | 62 // static |
63 void MessagePortProvider::PostMessageToPort( | 63 void MessagePortProvider::PostMessageToPort( |
64 int sender_port_id, | 64 int sender_port_id, |
65 const MessagePortMessage& message, | 65 const base::string16& message, |
66 const std::vector<TransferredMessagePort>& sent_ports) { | 66 const std::vector<int>& sent_ports) { |
67 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 67 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
68 MessagePortService* msp = MessagePortService::GetInstance(); | 68 MessagePortService* msp = MessagePortService::GetInstance(); |
69 msp->PostMessage(sender_port_id, message, sent_ports); | 69 msp->PostMessage(sender_port_id, message, sent_ports); |
70 } | 70 } |
71 | 71 |
72 // static | 72 // static |
73 void MessagePortProvider::ClosePort(int message_port_id) { | 73 void MessagePortProvider::ClosePort(int message_port_id) { |
74 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
75 MessagePortService* msp = MessagePortService::GetInstance(); | 75 MessagePortService* msp = MessagePortService::GetInstance(); |
76 msp->ClosePort(message_port_id); | 76 msp->ClosePort(message_port_id); |
(...skipping 22 matching lines...) Expand all Loading... |
99 // static | 99 // static |
100 void MessagePortProvider::UpdateMessagePort(int message_port_id, | 100 void MessagePortProvider::UpdateMessagePort(int message_port_id, |
101 MessagePortDelegate* delegate) { | 101 MessagePortDelegate* delegate) { |
102 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 102 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
103 MessagePortService::GetInstance()->UpdateMessagePort(message_port_id, | 103 MessagePortService::GetInstance()->UpdateMessagePort(message_port_id, |
104 delegate, | 104 delegate, |
105 message_port_id); | 105 message_port_id); |
106 } | 106 } |
107 | 107 |
108 } // namespace content | 108 } // namespace content |
OLD | NEW |