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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 11016023: Quickly close tabs/window with long-running unload handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests. Drop test's use of non-public API. Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (GetNativeView()) { 396 if (GetNativeView()) {
397 RenderViewHost* host = GetRenderViewHost(); 397 RenderViewHost* host = GetRenderViewHost();
398 if (host && host->GetView()) 398 if (host && host->GetView())
399 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); 399 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy();
400 } 400 }
401 #endif 401 #endif
402 402
403 // OnCloseStarted isn't called in unit tests. 403 // OnCloseStarted isn't called in unit tests.
404 if (!close_start_time_.is_null()) { 404 if (!close_start_time_.is_null()) {
405 base::TimeTicks now = base::TimeTicks::Now(); 405 base::TimeTicks now = base::TimeTicks::Now();
406 base::TimeDelta close_time = now - close_start_time_;
407 UMA_HISTOGRAM_TIMES("Tab.Close", close_time);
408
406 base::TimeTicks unload_start_time = close_start_time_; 409 base::TimeTicks unload_start_time = close_start_time_;
410 base::TimeTicks unload_end_time = now;
407 if (!before_unload_end_time_.is_null()) 411 if (!before_unload_end_time_.is_null())
408 unload_start_time = before_unload_end_time_; 412 unload_start_time = before_unload_end_time_;
409 UMA_HISTOGRAM_TIMES("Tab.Close", now - close_start_time_); 413 if (!unload_detached_start_time_.is_null())
410 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", now - unload_start_time); 414 unload_end_time = unload_detached_start_time_;
415 base::TimeDelta unload_time = unload_end_time - unload_start_time;
416 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time);
411 } 417 }
412 418
413 FOR_EACH_OBSERVER(WebContentsObserver, 419 FOR_EACH_OBSERVER(WebContentsObserver,
414 observers_, 420 observers_,
415 WebContentsImplDestroyed()); 421 WebContentsImplDestroyed());
416 422
417 SetDelegate(NULL); 423 SetDelegate(NULL);
418 } 424 }
419 425
420 WebContentsImpl* WebContentsImpl::Create( 426 WebContentsImpl* WebContentsImpl::Create(
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 1795
1790 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const { 1796 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const {
1791 return new_tab_start_time_; 1797 return new_tab_start_time_;
1792 } 1798 }
1793 1799
1794 void WebContentsImpl::Close() { 1800 void WebContentsImpl::Close() {
1795 Close(GetRenderViewHost()); 1801 Close(GetRenderViewHost());
1796 } 1802 }
1797 1803
1798 void WebContentsImpl::OnCloseStarted() { 1804 void WebContentsImpl::OnCloseStarted() {
1799 if (close_start_time_.is_null()) 1805 if (close_start_time_.is_null()) {
1800 close_start_time_ = base::TimeTicks::Now(); 1806 close_start_time_ = base::TimeTicks::Now();
1807 }
1808 }
1809
1810 void WebContentsImpl::OnUnloadDetachedStarted() {
1811 if (unload_detached_start_time_.is_null()) {
1812 unload_detached_start_time_ = base::TimeTicks::Now();
1813 }
1801 } 1814 }
1802 1815
1803 bool WebContentsImpl::ShouldAcceptDragAndDrop() const { 1816 bool WebContentsImpl::ShouldAcceptDragAndDrop() const {
1804 #if defined(OS_CHROMEOS) 1817 #if defined(OS_CHROMEOS)
1805 // ChromeOS panels (pop-ups) do not take drag-n-drop. 1818 // ChromeOS panels (pop-ups) do not take drag-n-drop.
1806 // See http://crosbug.com/2413 1819 // See http://crosbug.com/2413
1807 if (delegate_ && delegate_->IsPopupOrPanel(this)) 1820 if (delegate_ && delegate_->IsPopupOrPanel(this))
1808 return false; 1821 return false;
1809 return true; 1822 return true;
1810 #else 1823 #else
(...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after
3357 bool success, 3370 bool success,
3358 const string16& user_input) { 3371 const string16& user_input) {
3359 if (is_showing_before_unload_dialog_ && !success) { 3372 if (is_showing_before_unload_dialog_ && !success) {
3360 // If a beforeunload dialog is canceled, we need to stop the throbber from 3373 // If a beforeunload dialog is canceled, we need to stop the throbber from
3361 // spinning, since we forced it to start spinning in Navigate. 3374 // spinning, since we forced it to start spinning in Navigate.
3362 DidStopLoading(rvh); 3375 DidStopLoading(rvh);
3363 controller_.DiscardNonCommittedEntries(); 3376 controller_.DiscardNonCommittedEntries();
3364 3377
3365 close_start_time_ = base::TimeTicks(); 3378 close_start_time_ = base::TimeTicks();
3366 before_unload_end_time_ = base::TimeTicks(); 3379 before_unload_end_time_ = base::TimeTicks();
3380 unload_detached_start_time_ = base::TimeTicks();
3367 } 3381 }
3368 is_showing_before_unload_dialog_ = false; 3382 is_showing_before_unload_dialog_ = false;
3369 static_cast<RenderViewHostImpl*>( 3383 static_cast<RenderViewHostImpl*>(
3370 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); 3384 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input);
3371 } 3385 }
3372 3386
3373 void WebContentsImpl::SetEncoding(const std::string& encoding) { 3387 void WebContentsImpl::SetEncoding(const std::string& encoding) {
3374 encoding_ = content::GetContentClient()->browser()-> 3388 encoding_ = content::GetContentClient()->browser()->
3375 GetCanonicalEncodingNameByAliasName(encoding); 3389 GetCanonicalEncodingNameByAliasName(encoding);
3376 } 3390 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 } 3442 }
3429 } 3443 }
3430 3444
3431 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { 3445 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
3432 return browser_plugin_guest_.get(); 3446 return browser_plugin_guest_.get();
3433 } 3447 }
3434 3448
3435 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { 3449 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() {
3436 return browser_plugin_embedder_.get(); 3450 return browser_plugin_embedder_.get();
3437 } 3451 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698