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

Side by Side Diff: chrome/browser/ui/fast_unload_controller.cc

Issue 1094153002: Move ClosePage() from RenderViewHost to WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 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 "chrome/browser/ui/fast_unload_controller.h" 5 #include "chrome/browser/ui/fast_unload_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/devtools/devtools_window.h" 10 #include "chrome/browser/devtools/devtools_window.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // Process all the unload handlers. (The beforeunload handlers have finished.) 408 // Process all the unload handlers. (The beforeunload handlers have finished.)
409 if (!tabs_needing_unload_.empty()) { 409 if (!tabs_needing_unload_.empty()) {
410 browser_->OnWindowClosing(); 410 browser_->OnWindowClosing();
411 411
412 // Run unload handlers detached since no more interaction is possible. 412 // Run unload handlers detached since no more interaction is possible.
413 WebContentsSet::iterator it = tabs_needing_unload_.begin(); 413 WebContentsSet::iterator it = tabs_needing_unload_.begin();
414 while (it != tabs_needing_unload_.end()) { 414 while (it != tabs_needing_unload_.end()) {
415 WebContentsSet::iterator current = it++; 415 WebContentsSet::iterator current = it++;
416 content::WebContents* contents = *current; 416 content::WebContents* contents = *current;
417 tabs_needing_unload_.erase(current); 417 tabs_needing_unload_.erase(current);
418 // Null check render_view_host here as this gets called on a PostTask 418 // Null check render_view_host here as this gets called on a PostTask
Charlie Reis 2015/04/21 17:28:08 I'm having trouble imagining how the WebContents c
nasko 2015/04/29 17:09:27 I don't know what the reason is. I think changing
419 // and the tab's render_view_host may have been nulled out. 419 // and the tab's render_view_host may have been nulled out.
420 if (contents->GetRenderViewHost()) { 420 if (contents->GetRenderViewHost()) {
421 CoreTabHelper* core_tab_helper = 421 CoreTabHelper* core_tab_helper =
422 CoreTabHelper::FromWebContents(contents); 422 CoreTabHelper::FromWebContents(contents);
423 core_tab_helper->OnUnloadStarted(); 423 core_tab_helper->OnUnloadStarted();
424 DetachWebContents(contents); 424 DetachWebContents(contents);
425 contents->GetRenderViewHost()->ClosePage(); 425 contents->ClosePage();
426 } 426 }
427 } 427 }
428 428
429 // Get the browser hidden. 429 // Get the browser hidden.
430 if (browser_->tab_strip_model()->empty()) { 430 if (browser_->tab_strip_model()->empty()) {
431 browser_->TabStripEmpty(); 431 browser_->TabStripEmpty();
432 } else { 432 } else {
433 browser_->tab_strip_model()->CloseAllTabs(); // tabs not needing unload 433 browser_->tab_strip_model()->CloseAllTabs(); // tabs not needing unload
434 } 434 }
435 return; 435 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 473 }
474 474
475 void FastUnloadController::PostTaskForProcessPendingTabs() { 475 void FastUnloadController::PostTaskForProcessPendingTabs() {
476 base::MessageLoop::current()->PostTask( 476 base::MessageLoop::current()->PostTask(
477 FROM_HERE, 477 FROM_HERE,
478 base::Bind(&FastUnloadController::ProcessPendingTabs, 478 base::Bind(&FastUnloadController::ProcessPendingTabs,
479 weak_factory_.GetWeakPtr())); 479 weak_factory_.GetWeakPtr()));
480 } 480 }
481 481
482 } // namespace chrome 482 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698