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

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

Issue 666563005: Set up Mojo connection when RenderFrameHost is reused for new RenderFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 RenderFrameHostID(GetProcess()->GetID(), routing_id_), 195 RenderFrameHostID(GetProcess()->GetID(), routing_id_),
196 this)); 196 this));
197 197
198 if (is_swapped_out) { 198 if (is_swapped_out) {
199 rfh_state_ = STATE_SWAPPED_OUT; 199 rfh_state_ = STATE_SWAPPED_OUT;
200 } else { 200 } else {
201 rfh_state_ = STATE_DEFAULT; 201 rfh_state_ = STATE_DEFAULT;
202 GetSiteInstance()->increment_active_frame_count(); 202 GetSiteInstance()->increment_active_frame_count();
203 } 203 }
204 204
205 if (GetProcess()->GetServiceRegistry()) { 205 SetUpMojoIfNeeded();
206 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(
207 &render_frame_setup_);
208 mojo::ServiceProviderPtr service_provider;
209 render_frame_setup_->GetServiceProviderForFrame(
210 routing_id_, mojo::GetProxy(&service_provider));
211 service_registry_.BindRemoteServiceProvider(
212 service_provider.PassMessagePipe());
213
214 #if defined(OS_ANDROID)
215 service_registry_android_.reset(
216 new ServiceRegistryAndroid(&service_registry_));
217 #endif
218 }
219 206
220 swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( 207 swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind(
221 &RenderFrameHostImpl::OnSwappedOut, weak_ptr_factory_.GetWeakPtr()))); 208 &RenderFrameHostImpl::OnSwappedOut, weak_ptr_factory_.GetWeakPtr())));
222 } 209 }
223 210
224 RenderFrameHostImpl::~RenderFrameHostImpl() { 211 RenderFrameHostImpl::~RenderFrameHostImpl() {
225 GetProcess()->RemoveRoute(routing_id_); 212 GetProcess()->RemoveRoute(routing_id_);
226 g_routing_id_frame_map.Get().erase( 213 g_routing_id_frame_map.Get().erase(
227 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); 214 RenderFrameHostID(GetProcess()->GetID(), routing_id_));
228 215
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 Send(new FrameMsg_JavaScriptExecuteRequestForTests(routing_id_, 295 Send(new FrameMsg_JavaScriptExecuteRequestForTests(routing_id_,
309 javascript, 296 javascript,
310 0, false)); 297 0, false));
311 } 298 }
312 299
313 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { 300 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() {
314 return render_view_host_; 301 return render_view_host_;
315 } 302 }
316 303
317 ServiceRegistry* RenderFrameHostImpl::GetServiceRegistry() { 304 ServiceRegistry* RenderFrameHostImpl::GetServiceRegistry() {
318 return &service_registry_; 305 return service_registry_.get();
319 } 306 }
320 307
321 bool RenderFrameHostImpl::Send(IPC::Message* message) { 308 bool RenderFrameHostImpl::Send(IPC::Message* message) {
322 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { 309 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) {
323 return render_view_host_->input_router()->SendInput( 310 return render_view_host_->input_router()->SendInput(
324 make_scoped_ptr(message)); 311 make_scoped_ptr(message));
325 } 312 }
326 313
327 // Route IPCs through the RenderFrameProxyHost when in swapped out state. 314 // Route IPCs through the RenderFrameProxyHost when in swapped out state.
328 // Note: For subframes in --site-per-process mode, we don't use swapped out 315 // Note: For subframes in --site-per-process mode, we don't use swapped out
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 routing_id_, response->head, body->GetURL(), 1393 routing_id_, response->head, body->GetURL(),
1407 common_params, commit_params)); 1394 common_params, commit_params));
1408 // TODO(clamy): Check if we should start the throbber for non javascript urls 1395 // TODO(clamy): Check if we should start the throbber for non javascript urls
1409 // here. 1396 // here.
1410 1397
1411 // TODO(clamy): Release the stream handle once the renderer has finished 1398 // TODO(clamy): Release the stream handle once the renderer has finished
1412 // reading it. 1399 // reading it.
1413 stream_handle_ = body.Pass(); 1400 stream_handle_ = body.Pass();
1414 } 1401 }
1415 1402
1403 void RenderFrameHostImpl::SetUpMojoIfNeeded() {
1404 if (service_registry_.get())
1405 return;
1406
1407 service_registry_.reset(new ServiceRegistryImpl());
1408 if (!GetProcess()->GetServiceRegistry())
1409 return;
1410
1411 RenderFrameSetupPtr setup;
1412 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup);
1413 mojo::ServiceProviderPtr service_provider;
1414 setup->GetServiceProviderForFrame(routing_id_,
1415 mojo::GetProxy(&service_provider));
1416 service_registry_->BindRemoteServiceProvider(
1417 service_provider.PassMessagePipe());
1418
1419 #if defined(OS_ANDROID)
1420 service_registry_android_.reset(
1421 new ServiceRegistryAndroid(service_registry_.get()));
1422 #endif
1423 }
1424
1425 void RenderFrameHostImpl::InvalidateMojoConnection() {
1426 service_registry_.reset();
1427 #if defined(OS_ANDROID)
1428 service_registry_android_.reset();
1429 #endif
1430 }
1431
1416 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( 1432 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone(
1417 int request_id, blink::WebNotificationPermission permission) { 1433 int request_id, blink::WebNotificationPermission permission) {
1418 Send(new PlatformNotificationMsg_PermissionRequestComplete( 1434 Send(new PlatformNotificationMsg_PermissionRequestComplete(
1419 routing_id_, request_id, permission)); 1435 routing_id_, request_id, permission));
1420 } 1436 }
1421 1437
1422 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( 1438 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility(
1423 const std::map<int32, int> node_to_frame_routing_id_map) { 1439 const std::map<int32, int> node_to_frame_routing_id_map) {
1424 std::map<int32, int>::const_iterator iter; 1440 std::map<int32, int>::const_iterator iter;
1425 for (iter = node_to_frame_routing_id_map.begin(); 1441 for (iter = node_to_frame_routing_id_map.begin();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 // Clear any state if a pending navigation is canceled or preempted. 1579 // Clear any state if a pending navigation is canceled or preempted.
1564 if (suspended_nav_params_) 1580 if (suspended_nav_params_)
1565 suspended_nav_params_.reset(); 1581 suspended_nav_params_.reset();
1566 1582
1567 TRACE_EVENT_ASYNC_END0("navigation", 1583 TRACE_EVENT_ASYNC_END0("navigation",
1568 "RenderFrameHostImpl navigation suspended", this); 1584 "RenderFrameHostImpl navigation suspended", this);
1569 navigations_suspended_ = false; 1585 navigations_suspended_ = false;
1570 } 1586 }
1571 1587
1572 } // namespace content 1588 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698