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