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

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: Keep original TabsNeedBeforeUnloadFired implementation. Created 8 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 | 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (GetNativeView()) { 351 if (GetNativeView()) {
352 RenderViewHost* host = GetRenderViewHost(); 352 RenderViewHost* host = GetRenderViewHost();
353 if (host && host->GetView()) 353 if (host && host->GetView())
354 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); 354 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy();
355 } 355 }
356 #endif 356 #endif
357 357
358 // OnCloseStarted isn't called in unit tests. 358 // OnCloseStarted isn't called in unit tests.
359 if (!close_start_time_.is_null()) { 359 if (!close_start_time_.is_null()) {
360 base::TimeTicks now = base::TimeTicks::Now(); 360 base::TimeTicks now = base::TimeTicks::Now();
361 base::TimeDelta close_time = now - close_start_time_;
362 UMA_HISTOGRAM_TIMES("Tab.Close", close_time);
363
361 base::TimeTicks unload_start_time = close_start_time_; 364 base::TimeTicks unload_start_time = close_start_time_;
365 base::TimeTicks unload_end_time = now;
362 if (!before_unload_end_time_.is_null()) 366 if (!before_unload_end_time_.is_null())
363 unload_start_time = before_unload_end_time_; 367 unload_start_time = before_unload_end_time_;
364 UMA_HISTOGRAM_TIMES("Tab.Close", now - close_start_time_); 368 if (!unload_detached_start_time_.is_null())
365 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", now - unload_start_time); 369 unload_end_time = unload_detached_start_time_;
370 base::TimeDelta unload_time = unload_end_time - unload_start_time;
371 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time);
366 } 372 }
367 373
368 FOR_EACH_OBSERVER(WebContentsObserver, 374 FOR_EACH_OBSERVER(WebContentsObserver,
369 observers_, 375 observers_,
370 WebContentsImplDestroyed()); 376 WebContentsImplDestroyed());
371 377
372 SetDelegate(NULL); 378 SetDelegate(NULL);
373 } 379 }
374 380
375 WebContentsImpl* WebContentsImpl::Create( 381 WebContentsImpl* WebContentsImpl::Create(
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 1742
1737 void WebContentsImpl::Close() { 1743 void WebContentsImpl::Close() {
1738 Close(GetRenderViewHost()); 1744 Close(GetRenderViewHost());
1739 } 1745 }
1740 1746
1741 void WebContentsImpl::OnCloseStarted() { 1747 void WebContentsImpl::OnCloseStarted() {
1742 if (close_start_time_.is_null()) 1748 if (close_start_time_.is_null())
1743 close_start_time_ = base::TimeTicks::Now(); 1749 close_start_time_ = base::TimeTicks::Now();
1744 } 1750 }
1745 1751
1752 void WebContentsImpl::OnCloseCanceled() {
1753 close_start_time_ = base::TimeTicks();
1754 before_unload_end_time_ = base::TimeTicks();
1755 unload_detached_start_time_ = base::TimeTicks();
1756 }
1757
1758 void WebContentsImpl::OnUnloadStarted() {
1759 before_unload_end_time_ = base::TimeTicks::Now();
1760 }
1761
1762 void WebContentsImpl::OnUnloadDetachedStarted() {
1763 if (unload_detached_start_time_.is_null())
1764 unload_detached_start_time_ = base::TimeTicks::Now();
1765 }
1766
1746 bool WebContentsImpl::ShouldAcceptDragAndDrop() const { 1767 bool WebContentsImpl::ShouldAcceptDragAndDrop() const {
1747 #if defined(OS_CHROMEOS) 1768 #if defined(OS_CHROMEOS)
1748 // ChromeOS panels (pop-ups) do not take drag-n-drop. 1769 // ChromeOS panels (pop-ups) do not take drag-n-drop.
1749 // See http://crosbug.com/2413 1770 // See http://crosbug.com/2413
1750 if (delegate_ && delegate_->IsPopupOrPanel(this)) 1771 if (delegate_ && delegate_->IsPopupOrPanel(this))
1751 return false; 1772 return false;
1752 return true; 1773 return true;
1753 #else 1774 #else
1754 return true; 1775 return true;
1755 #endif 1776 #endif
(...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after
3263 3284
3264 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, 3285 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh,
3265 IPC::Message* reply_msg, 3286 IPC::Message* reply_msg,
3266 bool success, 3287 bool success,
3267 const string16& user_input) { 3288 const string16& user_input) {
3268 if (is_showing_before_unload_dialog_ && !success) { 3289 if (is_showing_before_unload_dialog_ && !success) {
3269 // If a beforeunload dialog is canceled, we need to stop the throbber from 3290 // If a beforeunload dialog is canceled, we need to stop the throbber from
3270 // spinning, since we forced it to start spinning in Navigate. 3291 // spinning, since we forced it to start spinning in Navigate.
3271 DidStopLoading(rvh); 3292 DidStopLoading(rvh);
3272 controller_.DiscardNonCommittedEntries(); 3293 controller_.DiscardNonCommittedEntries();
3273 3294 OnCloseCanceled();
3274 close_start_time_ = base::TimeTicks();
3275 before_unload_end_time_ = base::TimeTicks();
3276 } 3295 }
3277 is_showing_before_unload_dialog_ = false; 3296 is_showing_before_unload_dialog_ = false;
3278 static_cast<RenderViewHostImpl*>( 3297 static_cast<RenderViewHostImpl*>(
3279 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); 3298 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input);
3280 } 3299 }
3281 3300
3282 void WebContentsImpl::SetEncoding(const std::string& encoding) { 3301 void WebContentsImpl::SetEncoding(const std::string& encoding) {
3283 encoding_ = GetContentClient()->browser()-> 3302 encoding_ = GetContentClient()->browser()->
3284 GetCanonicalEncodingNameByAliasName(encoding); 3303 GetCanonicalEncodingNameByAliasName(encoding);
3285 } 3304 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 3340
3322 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { 3341 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
3323 return browser_plugin_guest_.get(); 3342 return browser_plugin_guest_.get();
3324 } 3343 }
3325 3344
3326 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { 3345 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() {
3327 return browser_plugin_embedder_.get(); 3346 return browser_plugin_embedder_.get();
3328 } 3347 }
3329 3348
3330 } // namespace content 3349 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698