Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/metrics/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace | 127 } // namespace |
| 128 | 128 |
| 129 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, | 129 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, |
| 130 int render_frame_id) { | 130 int render_frame_id) { |
| 131 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | 131 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // static | 134 // static |
| 135 RenderFrameHostImpl* RenderFrameHostImpl::FromID( | 135 RenderFrameHostImpl* RenderFrameHostImpl::FromID(int process_id, |
| 136 int process_id, int routing_id) { | 136 int routing_id) { |
| 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 138 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer(); | 138 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer(); |
| 139 RoutingIDFrameMap::iterator it = frames->find( | 139 RoutingIDFrameMap::iterator it = frames->find( |
| 140 RenderFrameHostID(process_id, routing_id)); | 140 RenderFrameHostID(process_id, routing_id)); |
| 141 return it == frames->end() ? NULL : it->second; | 141 return it == frames->end() ? NULL : it->second; |
| 142 } | 142 } |
| 143 | 143 |
| 144 RenderFrameHostImpl::RenderFrameHostImpl( | 144 RenderFrameHostImpl::RenderFrameHostImpl( |
| 145 RenderViewHostImpl* render_view_host, | 145 RenderViewHostImpl* render_view_host, |
| 146 RenderFrameHostDelegate* delegate, | 146 RenderFrameHostDelegate* delegate, |
| 147 FrameTree* frame_tree, | 147 FrameTree* frame_tree, |
| 148 FrameTreeNode* frame_tree_node, | 148 FrameTreeNode* frame_tree_node, |
| 149 int routing_id, | 149 int routing_id, |
| 150 bool is_swapped_out) | 150 bool is_swapped_out) |
| 151 : render_view_host_(render_view_host), | 151 : render_view_host_(render_view_host), |
| 152 delegate_(delegate), | 152 delegate_(delegate), |
| 153 cross_process_frame_connector_(NULL), | 153 cross_process_frame_connector_(NULL), |
| 154 render_frame_proxy_host_(NULL), | 154 render_frame_proxy_host_(NULL), |
| 155 frame_tree_(frame_tree), | 155 frame_tree_(frame_tree), |
| 156 frame_tree_node_(frame_tree_node), | 156 frame_tree_node_(frame_tree_node), |
| 157 routing_id_(routing_id), | 157 routing_id_(routing_id), |
| 158 is_swapped_out_(is_swapped_out), | 158 is_swapped_out_(is_swapped_out), |
| 159 renderer_initialized_(false), | |
| 160 has_received_swap_out_ack_(false), | |
| 159 weak_ptr_factory_(this) { | 161 weak_ptr_factory_(this) { |
| 162 RenderFrameHostManager* manager = NULL; | |
| 163 if (frame_tree_node_->parent()) { | |
| 164 manager = frame_tree_node_->parent()->render_manager(); | |
| 165 } | |
| 166 LOG(ERROR) << "RFHI::RFHI[" << this << "]: " | |
| 167 << " process:" << GetProcess()->GetID() | |
| 168 << ", routing:" << routing_id | |
| 169 << ", site:" << GetSiteInstance()->GetSiteURL() | |
| 170 << ", parent: " << manager; | |
| 160 frame_tree_->RegisterRenderFrameHost(this); | 171 frame_tree_->RegisterRenderFrameHost(this); |
| 161 GetProcess()->AddRoute(routing_id_, this); | 172 GetProcess()->AddRoute(routing_id_, this); |
| 162 g_routing_id_frame_map.Get().insert(std::make_pair( | 173 g_routing_id_frame_map.Get().insert(std::make_pair( |
| 163 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 174 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
| 164 this)); | 175 this)); |
| 165 } | 176 } |
| 166 | 177 |
| 167 RenderFrameHostImpl::~RenderFrameHostImpl() { | 178 RenderFrameHostImpl::~RenderFrameHostImpl() { |
| 168 GetProcess()->RemoveRoute(routing_id_); | 179 GetProcess()->RemoveRoute(routing_id_); |
| 169 g_routing_id_frame_map.Get().erase( | 180 g_routing_id_frame_map.Get().erase( |
| 170 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); | 181 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
| 171 if (delegate_) | 182 if (delegate_) |
| 172 delegate_->RenderFrameDeleted(this); | 183 delegate_->RenderFrameDeleted(this); |
| 173 | 184 |
| 174 // Notify the FrameTree that this RFH is going away, allowing it to shut down | 185 // Notify the FrameTree that this RFH is going away, allowing it to shut down |
| 175 // the corresponding RenderViewHost if it is no longer needed. | 186 // the corresponding RenderViewHost if it is no longer needed. |
| 176 frame_tree_->UnregisterRenderFrameHost(this); | 187 frame_tree_->UnregisterRenderFrameHost(this); |
| 188 LOG(ERROR) << "RFHI::~RFHI[" << this << "]"; | |
| 177 } | 189 } |
| 178 | 190 |
| 179 int RenderFrameHostImpl::GetRoutingID() { | 191 int RenderFrameHostImpl::GetRoutingID() { |
| 180 return routing_id_; | 192 return routing_id_; |
| 181 } | 193 } |
| 182 | 194 |
| 183 SiteInstance* RenderFrameHostImpl::GetSiteInstance() { | 195 SiteInstance* RenderFrameHostImpl::GetSiteInstance() { |
| 184 return render_view_host_->GetSiteInstance(); | 196 return render_view_host_->GetSiteInstance(); |
| 185 } | 197 } |
| 186 | 198 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { | 253 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { |
| 242 return render_view_host_; | 254 return render_view_host_; |
| 243 } | 255 } |
| 244 | 256 |
| 245 bool RenderFrameHostImpl::Send(IPC::Message* message) { | 257 bool RenderFrameHostImpl::Send(IPC::Message* message) { |
| 246 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { | 258 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { |
| 247 return render_view_host_->input_router()->SendInput( | 259 return render_view_host_->input_router()->SendInput( |
| 248 make_scoped_ptr(message)); | 260 make_scoped_ptr(message)); |
| 249 } | 261 } |
| 250 | 262 |
| 251 if (render_view_host_->IsSwappedOut()) { | 263 // Route IPCs through the RenderFrameProxyHost when in swapped out state. |
| 264 // Note: For subframes in --site-per-process mode, we don't use swapped out | |
| 265 // RenderFrameHosts. | |
| 266 if (frame_tree_node_->IsMainFrame() && render_view_host_->IsSwappedOut()) { | |
| 252 DCHECK(render_frame_proxy_host_); | 267 DCHECK(render_frame_proxy_host_); |
| 253 return render_frame_proxy_host_->Send(message); | 268 return render_frame_proxy_host_->Send(message); |
| 254 } | 269 } |
| 255 | 270 |
| 256 return GetProcess()->Send(message); | 271 return GetProcess()->Send(message); |
| 257 } | 272 } |
| 258 | 273 |
| 259 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { | 274 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| 260 // Filter out most IPC messages if this renderer is swapped out. | 275 // Filter out most IPC messages if this renderer is swapped out. |
| 261 // We still want to handle certain ACKs to keep our state consistent. | 276 // We still want to handle certain ACKs to keep our state consistent. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 OnShowDesktopNotification) | 339 OnShowDesktopNotification) |
| 325 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, | 340 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, |
| 326 OnCancelDesktopNotification) | 341 OnCancelDesktopNotification) |
| 327 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, | 342 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, |
| 328 OnTextSurroundingSelectionResponse) | 343 OnTextSurroundingSelectionResponse) |
| 329 IPC_END_MESSAGE_MAP() | 344 IPC_END_MESSAGE_MAP() |
| 330 | 345 |
| 331 return handled; | 346 return handled; |
| 332 } | 347 } |
| 333 | 348 |
| 349 bool RenderFrameHostImpl::CreateRenderFrame( | |
| 350 int parent_routing_id) { | |
|
ncarter (slow)
2014/06/25 01:07:55
NIT PLEASE INDENT FOUR SPACES OR USE CLANG FORMAT
| |
| 351 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); | |
| 352 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | |
| 353 | |
| 354 // The process may (if we're sharing a process with another host that already | |
| 355 // initialized it) or may not (we have our own process or the old process | |
| 356 // crashed) have been initialized. Calling Init multiple times will be | |
| 357 // ignored, so this is safe. | |
| 358 if (!GetProcess()->Init()) | |
| 359 return false; | |
| 360 | |
| 361 DCHECK(GetProcess()->HasConnection()); | |
| 362 DCHECK(GetProcess()->GetBrowserContext()); | |
| 363 | |
| 364 renderer_initialized_ = true; | |
| 365 Send(new FrameMsg_NewFrame(routing_id_, parent_routing_id)); | |
| 366 | |
| 367 return true; | |
| 368 } | |
| 369 | |
| 370 bool RenderFrameHostImpl::IsRenderFrameLive() { | |
| 371 return GetProcess()->HasConnection() && renderer_initialized_; | |
|
ncarter (slow)
2014/06/25 01:07:55
If I recall correctly, RVHImpl::IsRenderFrameLive
| |
| 372 } | |
| 373 | |
| 334 void RenderFrameHostImpl::Init() { | 374 void RenderFrameHostImpl::Init() { |
| 335 GetProcess()->ResumeRequestsForView(routing_id_); | 375 GetProcess()->ResumeRequestsForView(routing_id_); |
| 336 } | 376 } |
| 337 | 377 |
| 338 void RenderFrameHostImpl::OnAddMessageToConsole( | 378 void RenderFrameHostImpl::OnAddMessageToConsole( |
| 339 int32 level, | 379 int32 level, |
| 340 const base::string16& message, | 380 const base::string16& message, |
| 341 int32 line_no, | 381 int32 line_no, |
| 342 const base::string16& source_id) { | 382 const base::string16& source_id) { |
| 343 if (delegate_->AddMessageToConsole(level, message, line_no, source_id)) | 383 if (delegate_->AddMessageToConsole(level, message, line_no, source_id)) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 // action. | 466 // action. |
| 427 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { | 467 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { |
| 428 // Read the parameters out of the IPC message directly to avoid making another | 468 // Read the parameters out of the IPC message directly to avoid making another |
| 429 // copy when we filter the URLs. | 469 // copy when we filter the URLs. |
| 430 PickleIterator iter(msg); | 470 PickleIterator iter(msg); |
| 431 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; | 471 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; |
| 432 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: | 472 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: |
| 433 Read(&msg, &iter, &validated_params)) | 473 Read(&msg, &iter, &validated_params)) |
| 434 return; | 474 return; |
| 435 | 475 |
| 476 LOG(ERROR) << "RFH[" << this << "]::OnNavigate:" | |
| 477 << " url:" << validated_params.url; | |
| 478 | |
| 436 // If we're waiting for a cross-site beforeunload ack from this renderer and | 479 // If we're waiting for a cross-site beforeunload ack from this renderer and |
| 437 // we receive a Navigate message from the main frame, then the renderer was | 480 // we receive a Navigate message from the main frame, then the renderer was |
| 438 // navigating already and sent it before hearing the ViewMsg_Stop message. | 481 // navigating already and sent it before hearing the ViewMsg_Stop message. |
| 439 // We do not want to cancel the pending navigation in this case, since the | 482 // We do not want to cancel the pending navigation in this case, since the |
| 440 // old page will soon be stopped. Instead, treat this as a beforeunload ack | 483 // old page will soon be stopped. Instead, treat this as a beforeunload ack |
| 441 // to allow the pending navigation to continue. | 484 // to allow the pending navigation to continue. |
| 442 if (render_view_host_->is_waiting_for_beforeunload_ack_ && | 485 if (render_view_host_->is_waiting_for_beforeunload_ack_ && |
| 443 render_view_host_->unload_ack_is_for_cross_site_transition_ && | 486 render_view_host_->unload_ack_is_for_cross_site_transition_ && |
| 444 PageTransitionIsMainFrame(validated_params.transition)) { | 487 PageTransitionIsMainFrame(validated_params.transition)) { |
| 445 OnBeforeUnloadACK(true, send_before_unload_start_time_, | 488 OnBeforeUnloadACK(true, send_before_unload_start_time_, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 | 580 |
| 538 render_view_host_->SetState( | 581 render_view_host_->SetState( |
| 539 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); | 582 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); |
| 540 render_view_host_->unload_event_monitor_timeout_->Start( | 583 render_view_host_->unload_event_monitor_timeout_->Start( |
| 541 base::TimeDelta::FromMilliseconds( | 584 base::TimeDelta::FromMilliseconds( |
| 542 RenderViewHostImpl::kUnloadTimeoutMS)); | 585 RenderViewHostImpl::kUnloadTimeoutMS)); |
| 543 } | 586 } |
| 544 | 587 |
| 545 set_render_frame_proxy_host(proxy); | 588 set_render_frame_proxy_host(proxy); |
| 546 | 589 |
| 547 if (render_view_host_->IsRenderViewLive()) | 590 if (render_view_host_->IsRenderViewLive()) { |
| 591 has_received_swap_out_ack_ = false; | |
|
ncarter (slow)
2014/06/25 01:07:56
Do we need this at all? (when looking through this
| |
| 548 Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID())); | 592 Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID())); |
| 593 } | |
| 549 | 594 |
| 550 if (!GetParent()) | 595 if (!GetParent()) |
| 551 delegate_->SwappedOut(this); | 596 delegate_->SwappedOut(this); |
| 552 | 597 |
| 553 // Allow the navigation to proceed. | 598 // Allow the navigation to proceed. |
| 554 frame_tree_node_->render_manager()->SwappedOut(this); | 599 frame_tree_node_->render_manager()->SwappedOut(this); |
| 555 } | 600 } |
| 556 | 601 |
| 557 void RenderFrameHostImpl::OnBeforeUnloadACK( | 602 void RenderFrameHostImpl::OnBeforeUnloadACK( |
| 558 bool proceed, | 603 bool proceed, |
| 559 const base::TimeTicks& renderer_before_unload_start_time, | 604 const base::TimeTicks& renderer_before_unload_start_time, |
| 560 const base::TimeTicks& renderer_before_unload_end_time) { | 605 const base::TimeTicks& renderer_before_unload_end_time) { |
| 606 LOG(ERROR) << "RFHI::OnBeforeUnloadACK[" << this << "]: "; | |
| 561 // TODO(creis): Support properly beforeunload on subframes. For now just | 607 // TODO(creis): Support properly beforeunload on subframes. For now just |
| 562 // pretend that the handler ran and allowed the navigation to proceed. | 608 // pretend that the handler ran and allowed the navigation to proceed. |
| 563 if (GetParent()) { | 609 if (GetParent()) { |
| 564 render_view_host_->is_waiting_for_beforeunload_ack_ = false; | 610 render_view_host_->is_waiting_for_beforeunload_ack_ = false; |
| 565 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 611 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| 566 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, | 612 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, |
| 567 renderer_before_unload_end_time); | 613 renderer_before_unload_end_time); |
| 568 return; | 614 return; |
| 569 } | 615 } |
| 570 | 616 |
| 571 render_view_host_->decrement_in_flight_event_count(); | 617 render_view_host_->decrement_in_flight_event_count(); |
| 572 render_view_host_->StopHangMonitorTimeout(); | 618 render_view_host_->StopHangMonitorTimeout(); |
| 573 // If this renderer navigated while the beforeunload request was in flight, we | 619 // If this renderer navigated while the beforeunload request was in flight, we |
| 574 // may have cleared this state in OnNavigate, in which case we can ignore | 620 // may have cleared this state in OnNavigate, in which case we can ignore |
| 575 // this message. | 621 // this message. |
| 576 // However renderer might also be swapped out but we still want to proceed | 622 // However renderer might also be swapped out but we still want to proceed |
| 577 // with navigation, otherwise it would block future navigations. This can | 623 // with navigation, otherwise it would block future navigations. This can |
| 578 // happen when pending cross-site navigation is canceled by a second one just | 624 // happen when pending cross-site navigation is canceled by a second one just |
| 579 // before OnNavigate while current RVH is waiting for commit but second | 625 // before OnNavigate while current RVH is waiting for commit but second |
| 580 // navigation is started from the beginning. | 626 // navigation is started from the beginning. |
| 581 if (!render_view_host_->is_waiting_for_beforeunload_ack_) { | 627 if (!render_view_host_->is_waiting_for_beforeunload_ack_) { |
| 628 LOG(ERROR) << "RFHI::OnBeforeUnloadACK[" << this << "]: " | |
| 629 << "!is_waiting_for_beforeunload_ack_"; | |
| 582 return; | 630 return; |
| 583 } | 631 } |
| 584 | 632 |
| 585 render_view_host_->is_waiting_for_beforeunload_ack_ = false; | 633 render_view_host_->is_waiting_for_beforeunload_ack_ = false; |
| 586 | 634 |
| 587 base::TimeTicks before_unload_end_time; | 635 base::TimeTicks before_unload_end_time; |
| 588 if (!send_before_unload_start_time_.is_null() && | 636 if (!send_before_unload_start_time_.is_null() && |
| 589 !renderer_before_unload_start_time.is_null() && | 637 !renderer_before_unload_start_time.is_null() && |
| 590 !renderer_before_unload_end_time.is_null()) { | 638 !renderer_before_unload_end_time.is_null()) { |
| 591 // When passing TimeTicks across process boundaries, we need to compensate | 639 // When passing TimeTicks across process boundaries, we need to compensate |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 605 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 653 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| 606 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, | 654 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, |
| 607 before_unload_end_time); | 655 before_unload_end_time); |
| 608 | 656 |
| 609 // If canceled, notify the delegate to cancel its pending navigation entry. | 657 // If canceled, notify the delegate to cancel its pending navigation entry. |
| 610 if (!proceed) | 658 if (!proceed) |
| 611 render_view_host_->GetDelegate()->DidCancelLoading(); | 659 render_view_host_->GetDelegate()->DidCancelLoading(); |
| 612 } | 660 } |
| 613 | 661 |
| 614 void RenderFrameHostImpl::OnSwapOutACK() { | 662 void RenderFrameHostImpl::OnSwapOutACK() { |
| 663 has_received_swap_out_ack_ = true; | |
| 615 OnSwappedOut(false); | 664 OnSwappedOut(false); |
| 616 } | 665 } |
| 617 | 666 |
| 618 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { | 667 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { |
| 619 // For now, we only need to update the RVH state machine for top-level swaps. | 668 // For now, we only need to update the RVH state machine for top-level swaps. |
| 620 // Subframe swaps (in --site-per-process) can just continue via RFHM. | 669 // Subframe swaps (in --site-per-process) can just continue via RFHM. |
| 621 if (!GetParent()) | 670 if (!GetParent()) |
| 622 render_view_host_->OnSwappedOut(timed_out); | 671 render_view_host_->OnSwappedOut(timed_out); |
| 623 else | 672 else |
| 624 frame_tree_node_->render_manager()->SwappedOut(this); | 673 frame_tree_node_->render_manager()->SwappedOut(this); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 823 params.current_history_list_offset = -1; | 872 params.current_history_list_offset = -1; |
| 824 params.current_history_list_length = 0; | 873 params.current_history_list_length = 0; |
| 825 params.url = url; | 874 params.url = url; |
| 826 params.transition = PAGE_TRANSITION_LINK; | 875 params.transition = PAGE_TRANSITION_LINK; |
| 827 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 876 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 828 Navigate(params); | 877 Navigate(params); |
| 829 } | 878 } |
| 830 | 879 |
| 831 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 880 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
| 832 // TODO(creis): Support subframes. | 881 // TODO(creis): Support subframes. |
| 882 LOG(ERROR) << "RFHI::DispatchBeforeUnload[" << this << "]: "; | |
| 833 if (!render_view_host_->IsRenderViewLive() || GetParent()) { | 883 if (!render_view_host_->IsRenderViewLive() || GetParent()) { |
| 884 LOG(ERROR) << "RFHI::DispatchBeforeUnload[" << this << "]: " | |
| 885 << "!RenderViewLive or GetParent()"; | |
| 834 // We don't have a live renderer, so just skip running beforeunload. | 886 // We don't have a live renderer, so just skip running beforeunload. |
| 835 render_view_host_->is_waiting_for_beforeunload_ack_ = true; | 887 render_view_host_->is_waiting_for_beforeunload_ack_ = true; |
| 836 render_view_host_->unload_ack_is_for_cross_site_transition_ = | 888 render_view_host_->unload_ack_is_for_cross_site_transition_ = |
| 837 for_cross_site_transition; | 889 for_cross_site_transition; |
| 838 base::TimeTicks now = base::TimeTicks::Now(); | 890 base::TimeTicks now = base::TimeTicks::Now(); |
| 839 OnBeforeUnloadACK(true, now, now); | 891 OnBeforeUnloadACK(true, now, now); |
| 840 return; | 892 return; |
| 841 } | 893 } |
| 842 | 894 |
| 843 // This may be called more than once (if the user clicks the tab close button | 895 // This may be called more than once (if the user clicks the tab close button |
| 844 // several times, or if she clicks the tab close button then the browser close | 896 // several times, or if she clicks the tab close button then the browser close |
| 845 // button), and we only send the message once. | 897 // button), and we only send the message once. |
| 846 if (render_view_host_->is_waiting_for_beforeunload_ack_) { | 898 if (render_view_host_->is_waiting_for_beforeunload_ack_) { |
| 899 LOG(ERROR) << "RFHI::DispatchBeforeUnload[" << this << "]: " | |
| 900 << "is_waiting_for_beforeunload_ack"; | |
| 847 // Some of our close messages could be for the tab, others for cross-site | 901 // Some of our close messages could be for the tab, others for cross-site |
| 848 // transitions. We always want to think it's for closing the tab if any | 902 // transitions. We always want to think it's for closing the tab if any |
| 849 // of the messages were, since otherwise it might be impossible to close | 903 // of the messages were, since otherwise it might be impossible to close |
| 850 // (if there was a cross-site "close" request pending when the user clicked | 904 // (if there was a cross-site "close" request pending when the user clicked |
| 851 // the close button). We want to keep the "for cross site" flag only if | 905 // the close button). We want to keep the "for cross site" flag only if |
| 852 // both the old and the new ones are also for cross site. | 906 // both the old and the new ones are also for cross site. |
| 853 render_view_host_->unload_ack_is_for_cross_site_transition_ = | 907 render_view_host_->unload_ack_is_for_cross_site_transition_ = |
| 854 render_view_host_->unload_ack_is_for_cross_site_transition_ && | 908 render_view_host_->unload_ack_is_for_cross_site_transition_ && |
| 855 for_cross_site_transition; | 909 for_cross_site_transition; |
| 856 } else { | 910 } else { |
| 911 LOG(ERROR) << "RFHI::DispatchBeforeUnload[" << this << "]: " | |
| 912 << "send IPC"; | |
| 857 // Start the hang monitor in case the renderer hangs in the beforeunload | 913 // Start the hang monitor in case the renderer hangs in the beforeunload |
| 858 // handler. | 914 // handler. |
| 859 render_view_host_->is_waiting_for_beforeunload_ack_ = true; | 915 render_view_host_->is_waiting_for_beforeunload_ack_ = true; |
| 860 render_view_host_->unload_ack_is_for_cross_site_transition_ = | 916 render_view_host_->unload_ack_is_for_cross_site_transition_ = |
| 861 for_cross_site_transition; | 917 for_cross_site_transition; |
| 862 // Increment the in-flight event count, to ensure that input events won't | 918 // Increment the in-flight event count, to ensure that input events won't |
| 863 // cancel the timeout timer. | 919 // cancel the timeout timer. |
| 864 render_view_host_->increment_in_flight_event_count(); | 920 render_view_host_->increment_in_flight_event_count(); |
| 865 render_view_host_->StartHangMonitorTimeout( | 921 render_view_host_->StartHangMonitorTimeout( |
| 866 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); | 922 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 927 FROM_HERE, | 983 FROM_HERE, |
| 928 base::Bind( | 984 base::Bind( |
| 929 &TransitionRequestManager::SetHasPendingTransitionRequest, | 985 &TransitionRequestManager::SetHasPendingTransitionRequest, |
| 930 base::Unretained(TransitionRequestManager::GetInstance()), | 986 base::Unretained(TransitionRequestManager::GetInstance()), |
| 931 GetProcess()->GetID(), | 987 GetProcess()->GetID(), |
| 932 routing_id_, | 988 routing_id_, |
| 933 has_pending_request)); | 989 has_pending_request)); |
| 934 } | 990 } |
| 935 | 991 |
| 936 } // namespace content | 992 } // namespace content |
| OLD | NEW |