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_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 } | 310 } |
| 311 | 311 |
| 312 void RenderFrameHostManager::SetIsLoading(bool is_loading) { | 312 void RenderFrameHostManager::SetIsLoading(bool is_loading) { |
| 313 render_frame_host_->render_view_host()->GetWidget()->SetIsLoading(is_loading); | 313 render_frame_host_->render_view_host()->GetWidget()->SetIsLoading(is_loading); |
| 314 if (pending_render_frame_host_) { | 314 if (pending_render_frame_host_) { |
| 315 pending_render_frame_host_->render_view_host()->GetWidget()->SetIsLoading( | 315 pending_render_frame_host_->render_view_host()->GetWidget()->SetIsLoading( |
| 316 is_loading); | 316 is_loading); |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 bool RenderFrameHostManager::ShouldCloseTabOnUnresponsiveRenderer() { | |
| 321 // If we're waiting for a close ACK, then the tab should close whether there's | |
| 322 // a navigation in progress or not. Unfortunately, we also need to check for | |
| 323 // cases that we arrive here with no navigation in progress, since there are | |
| 324 // some tab closure paths that don't set is_waiting_for_close_ack to true. | |
| 325 // TODO(creis): Clean this up in http://crbug.com/418266. | |
| 326 if (!pending_render_frame_host_ || | |
| 327 render_frame_host_->render_view_host()->is_waiting_for_close_ack()) | |
| 328 return true; | |
| 329 | |
| 330 // We should always have a pending RFH when there's a cross-process navigation | |
| 331 // in progress. Sanity check this for http://crbug.com/276333. | |
| 332 CHECK(pending_render_frame_host_); | |
| 333 | |
| 334 // Unload handlers run in the background, so we should never get an | |
| 335 // unresponsiveness warning for them. | |
| 336 CHECK(!render_frame_host_->IsWaitingForUnloadACK()); | |
| 337 | |
| 338 // If the tab becomes unresponsive during beforeunload while doing a | |
| 339 // cross-process navigation, proceed with the navigation. (This assumes that | |
| 340 // the pending RenderFrameHost is still responsive.) | |
| 341 if (render_frame_host_->is_waiting_for_beforeunload_ack()) { | |
| 342 // Haven't gotten around to starting the request, because we're still | |
| 343 // waiting for the beforeunload handler to finish. We'll pretend that it | |
| 344 // did finish, to let the navigation proceed. Note that there's a danger | |
| 345 // that the beforeunload handler will later finish and possibly return | |
| 346 // false (meaning the navigation should not proceed), but we'll ignore it | |
| 347 // in this case because it took too long. | |
| 348 if (pending_render_frame_host_->are_navigations_suspended()) { | |
| 349 pending_render_frame_host_->SetNavigationsSuspended( | |
| 350 false, base::TimeTicks::Now()); | |
| 351 } | |
| 352 } | |
| 353 return false; | |
| 354 } | |
| 355 | |
| 356 void RenderFrameHostManager::OnBeforeUnloadACK( | 320 void RenderFrameHostManager::OnBeforeUnloadACK( |
| 357 bool for_cross_site_transition, | 321 bool for_cross_site_transition, |
| 358 bool proceed, | 322 bool proceed, |
| 359 const base::TimeTicks& proceed_time) { | 323 const base::TimeTicks& proceed_time) { |
| 360 if (for_cross_site_transition) { | 324 if (for_cross_site_transition) { |
| 361 DCHECK(!IsBrowserSideNavigationEnabled()); | 325 DCHECK(!IsBrowserSideNavigationEnabled()); |
| 362 // Ignore if we're not in a cross-process navigation. | 326 // Ignore if we're not in a cross-process navigation. |
| 363 if (!pending_render_frame_host_) | 327 if (!pending_render_frame_host_) |
| 364 return; | 328 return; |
| 365 | 329 |
| 366 if (proceed) { | 330 if (proceed) { |
| 367 // Ok to unload the current page, so proceed with the cross-process | 331 // Ok to unload the current page, so proceed with the cross-process |
| 368 // navigation. Note that if navigations are not currently suspended, it | 332 // navigation. Note that if navigations are not currently suspended, it |
| 369 // might be because the renderer was deemed unresponsive and this call was | 333 // might be because the renderer was deemed unresponsive and this call was |
| 370 // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it | 334 // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it |
| 371 // is ok to do nothing here. | 335 // is ok to do nothing here. |
|
Avi (use Gerrit)
2017/03/02 05:36:33
I may also need to cut down this comment.
| |
| 372 if (pending_render_frame_host_ && | 336 if (pending_render_frame_host_ && |
| 373 pending_render_frame_host_->are_navigations_suspended()) { | 337 pending_render_frame_host_->are_navigations_suspended()) { |
| 374 pending_render_frame_host_->SetNavigationsSuspended(false, | 338 pending_render_frame_host_->SetNavigationsSuspended(false, |
| 375 proceed_time); | 339 proceed_time); |
| 376 } | 340 } |
| 377 } else { | 341 } else { |
| 378 // Current page says to cancel. | 342 // Current page says to cancel. |
| 379 CancelPending(); | 343 CancelPending(); |
| 380 } | 344 } |
| 381 } else { | 345 } else { |
| (...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2814 resolved_url)) { | 2778 resolved_url)) { |
| 2815 DCHECK(!dest_instance || | 2779 DCHECK(!dest_instance || |
| 2816 dest_instance == render_frame_host_->GetSiteInstance()); | 2780 dest_instance == render_frame_host_->GetSiteInstance()); |
| 2817 return false; | 2781 return false; |
| 2818 } | 2782 } |
| 2819 | 2783 |
| 2820 return true; | 2784 return true; |
| 2821 } | 2785 } |
| 2822 | 2786 |
| 2823 } // namespace content | 2787 } // namespace content |
| OLD | NEW |