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

Side by Side Diff: content/browser/frame_host/render_frame_proxy_host.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Eliminate unnecessary PostTask Created 3 years, 10 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/browser/frame_host/render_frame_proxy_host.h" 5 #include "content/browser/frame_host/render_frame_proxy_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "content/browser/bad_message.h" 10 #include "content/browser/bad_message.h"
11 #include "content/browser/frame_host/cross_process_frame_connector.h" 11 #include "content/browser/frame_host/cross_process_frame_connector.h"
12 #include "content/browser/frame_host/frame_tree.h" 12 #include "content/browser/frame_host/frame_tree.h"
13 #include "content/browser/frame_host/frame_tree_node.h" 13 #include "content/browser/frame_host/frame_tree_node.h"
14 #include "content/browser/frame_host/navigator.h" 14 #include "content/browser/frame_host/navigator.h"
15 #include "content/browser/frame_host/render_frame_host_delegate.h" 15 #include "content/browser/frame_host/render_frame_host_delegate.h"
16 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 16 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
17 #include "content/browser/message_port_message_filter.h"
18 #include "content/browser/renderer_host/render_view_host_impl.h" 17 #include "content/browser/renderer_host/render_view_host_impl.h"
19 #include "content/browser/renderer_host/render_widget_host_view_base.h" 18 #include "content/browser/renderer_host/render_widget_host_view_base.h"
20 #include "content/browser/site_instance_impl.h" 19 #include "content/browser/site_instance_impl.h"
21 #include "content/common/frame_messages.h" 20 #include "content/common/frame_messages.h"
22 #include "content/common/frame_owner_properties.h" 21 #include "content/common/frame_owner_properties.h"
23 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
24 #include "ipc/ipc_message.h" 23 #include "ipc/ipc_message.h"
25 24
26 namespace content { 25 namespace content {
27 26
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 ->GetRenderFrameProxyHost(target_site_instance); 311 ->GetRenderFrameProxyHost(target_site_instance);
313 if (source_proxy_in_target_site_instance) { 312 if (source_proxy_in_target_site_instance) {
314 new_params.source_routing_id = 313 new_params.source_routing_id =
315 source_proxy_in_target_site_instance->GetRoutingID(); 314 source_proxy_in_target_site_instance->GetRoutingID();
316 } else { 315 } else {
317 new_params.source_routing_id = MSG_ROUTING_NONE; 316 new_params.source_routing_id = MSG_ROUTING_NONE;
318 } 317 }
319 } 318 }
320 } 319 }
321 320
322 if (!params.message_ports.empty()) { 321 target_rfh->Send(
323 // Updating the message port information has to be done in the IO thread; 322 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params));
324 // MessagePortMessageFilter::RouteMessageEventWithMessagePorts will send
325 // FrameMsg_PostMessageEvent after it's done. Note that a trivial solution
326 // would've been to post a task on the IO thread to do the IO-thread-bound
327 // work, and make that post a task back to WebContentsImpl in the UI
328 // thread. But we cannot do that, since there's nothing to guarantee that
329 // WebContentsImpl stays alive during the round trip.
330 scoped_refptr<MessagePortMessageFilter> message_port_message_filter(
331 static_cast<RenderProcessHostImpl*>(target_rfh->GetProcess())
332 ->message_port_message_filter());
333 BrowserThread::PostTask(
334 BrowserThread::IO, FROM_HERE,
335 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts,
336 message_port_message_filter, target_rfh->GetRoutingID(),
337 new_params));
338 } else {
339 target_rfh->Send(
340 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params));
341 }
342 } 323 }
343 324
344 void RenderFrameProxyHost::OnDidChangeOpener(int32_t opener_routing_id) { 325 void RenderFrameProxyHost::OnDidChangeOpener(int32_t opener_routing_id) {
345 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, 326 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id,
346 GetSiteInstance()); 327 GetSiteInstance());
347 } 328 }
348 329
349 void RenderFrameProxyHost::OnAdvanceFocus(blink::WebFocusType type, 330 void RenderFrameProxyHost::OnAdvanceFocus(blink::WebFocusType type,
350 int32_t source_routing_id) { 331 int32_t source_routing_id) {
351 RenderFrameHostImpl* target_rfh = 332 RenderFrameHostImpl* target_rfh =
(...skipping 14 matching lines...) Expand all
366 347
367 target_rfh->AdvanceFocus(type, source_proxy); 348 target_rfh->AdvanceFocus(type, source_proxy);
368 } 349 }
369 350
370 void RenderFrameProxyHost::OnFrameFocused() { 351 void RenderFrameProxyHost::OnFrameFocused() {
371 frame_tree_node_->current_frame_host()->delegate()->SetFocusedFrame( 352 frame_tree_node_->current_frame_host()->delegate()->SetFocusedFrame(
372 frame_tree_node_, GetSiteInstance()); 353 frame_tree_node_, GetSiteInstance());
373 } 354 }
374 355
375 } // namespace content 356 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698