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

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: Patch for landing Created 7 years, 6 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "base/metrics/stats_counters.h" 13 #include "base/metrics/stats_counters.h"
13 #include "base/string16.h" 14 #include "base/string16.h"
14 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
15 #include "base/string_util.h" 16 #include "base/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/sys_info.h" 18 #include "base/sys_info.h"
18 #include "base/time.h" 19 #include "base/time.h"
19 #include "cc/base/switches.h" 20 #include "cc/base/switches.h"
20 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 21 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (view_->GetNativeView()) { 392 if (view_->GetNativeView()) {
392 RenderViewHost* host = GetRenderViewHost(); 393 RenderViewHost* host = GetRenderViewHost();
393 if (host && host->GetView()) 394 if (host && host->GetView())
394 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); 395 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy();
395 } 396 }
396 #endif 397 #endif
397 398
398 // OnCloseStarted isn't called in unit tests. 399 // OnCloseStarted isn't called in unit tests.
399 if (!close_start_time_.is_null()) { 400 if (!close_start_time_.is_null()) {
400 base::TimeTicks now = base::TimeTicks::Now(); 401 base::TimeTicks now = base::TimeTicks::Now();
402 base::TimeDelta close_time = now - close_start_time_;
403 UMA_HISTOGRAM_TIMES("Tab.Close", close_time);
404
401 base::TimeTicks unload_start_time = close_start_time_; 405 base::TimeTicks unload_start_time = close_start_time_;
406 base::TimeTicks unload_end_time = now;
402 if (!before_unload_end_time_.is_null()) 407 if (!before_unload_end_time_.is_null())
403 unload_start_time = before_unload_end_time_; 408 unload_start_time = before_unload_end_time_;
404 UMA_HISTOGRAM_TIMES("Tab.Close", now - close_start_time_); 409 if (!unload_detached_start_time_.is_null())
405 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", now - unload_start_time); 410 unload_end_time = unload_detached_start_time_;
411 base::TimeDelta unload_time = unload_end_time - unload_start_time;
412 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time);
413
406 } 414 }
407 415
408 FOR_EACH_OBSERVER(WebContentsObserver, 416 FOR_EACH_OBSERVER(WebContentsObserver,
409 observers_, 417 observers_,
410 WebContentsImplDestroyed()); 418 WebContentsImplDestroyed());
411 419
412 SetDelegate(NULL); 420 SetDelegate(NULL);
413 421
414 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), 422 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(),
415 destruction_observers_.end()); 423 destruction_observers_.end());
(...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 1931
1924 void WebContentsImpl::Close() { 1932 void WebContentsImpl::Close() {
1925 Close(GetRenderViewHost()); 1933 Close(GetRenderViewHost());
1926 } 1934 }
1927 1935
1928 void WebContentsImpl::OnCloseStarted() { 1936 void WebContentsImpl::OnCloseStarted() {
1929 if (close_start_time_.is_null()) 1937 if (close_start_time_.is_null())
1930 close_start_time_ = base::TimeTicks::Now(); 1938 close_start_time_ = base::TimeTicks::Now();
1931 } 1939 }
1932 1940
1941 void WebContentsImpl::OnCloseCanceled() {
1942 close_start_time_ = base::TimeTicks();
1943 before_unload_end_time_ = base::TimeTicks();
1944 unload_detached_start_time_ = base::TimeTicks();
1945 }
1946
1947 void WebContentsImpl::OnUnloadStarted() {
1948 before_unload_end_time_ = base::TimeTicks::Now();
1949 }
1950
1951 void WebContentsImpl::OnUnloadDetachedStarted() {
1952 if (unload_detached_start_time_.is_null())
1953 unload_detached_start_time_ = base::TimeTicks::Now();
1954 }
1955
1933 void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y, 1956 void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y,
1934 int screen_x, int screen_y, WebKit::WebDragOperation operation) { 1957 int screen_x, int screen_y, WebKit::WebDragOperation operation) {
1935 if (browser_plugin_embedder_.get()) 1958 if (browser_plugin_embedder_.get())
1936 browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y, 1959 browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y,
1937 screen_x, screen_y, operation); 1960 screen_x, screen_y, operation);
1938 if (GetRenderViewHost()) 1961 if (GetRenderViewHost())
1939 GetRenderViewHostImpl()->DragSourceEndedAt(client_x, client_y, 1962 GetRenderViewHostImpl()->DragSourceEndedAt(client_x, client_y,
1940 screen_x, screen_y, operation); 1963 screen_x, screen_y, operation);
1941 } 1964 }
1942 1965
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
3576 3599
3577 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, 3600 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh,
3578 IPC::Message* reply_msg, 3601 IPC::Message* reply_msg,
3579 bool success, 3602 bool success,
3580 const string16& user_input) { 3603 const string16& user_input) {
3581 if (is_showing_before_unload_dialog_ && !success) { 3604 if (is_showing_before_unload_dialog_ && !success) {
3582 // If a beforeunload dialog is canceled, we need to stop the throbber from 3605 // If a beforeunload dialog is canceled, we need to stop the throbber from
3583 // spinning, since we forced it to start spinning in Navigate. 3606 // spinning, since we forced it to start spinning in Navigate.
3584 DidStopLoading(rvh); 3607 DidStopLoading(rvh);
3585 controller_.DiscardNonCommittedEntries(); 3608 controller_.DiscardNonCommittedEntries();
3586 3609 OnCloseCanceled();
3587 close_start_time_ = base::TimeTicks();
3588 before_unload_end_time_ = base::TimeTicks();
3589 } 3610 }
3590 is_showing_before_unload_dialog_ = false; 3611 is_showing_before_unload_dialog_ = false;
3591 static_cast<RenderViewHostImpl*>( 3612 static_cast<RenderViewHostImpl*>(
3592 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); 3613 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input);
3593 } 3614 }
3594 3615
3595 void WebContentsImpl::SetEncoding(const std::string& encoding) { 3616 void WebContentsImpl::SetEncoding(const std::string& encoding) {
3596 encoding_ = GetContentClient()->browser()-> 3617 encoding_ = GetContentClient()->browser()->
3597 GetCanonicalEncodingNameByAliasName(encoding); 3618 GetCanonicalEncodingNameByAliasName(encoding);
3598 } 3619 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3641 } 3662 }
3642 3663
3643 BrowserPluginGuestManager* 3664 BrowserPluginGuestManager*
3644 WebContentsImpl::GetBrowserPluginGuestManager() const { 3665 WebContentsImpl::GetBrowserPluginGuestManager() const {
3645 return static_cast<BrowserPluginGuestManager*>( 3666 return static_cast<BrowserPluginGuestManager*>(
3646 GetBrowserContext()->GetUserData( 3667 GetBrowserContext()->GetUserData(
3647 browser_plugin::kBrowserPluginGuestManagerKeyName)); 3668 browser_plugin::kBrowserPluginGuestManagerKeyName));
3648 } 3669 }
3649 3670
3650 } // namespace content 3671 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698