| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 if (view_->GetNativeView()) { | 340 if (view_->GetNativeView()) { |
| 341 RenderViewHost* host = GetRenderViewHost(); | 341 RenderViewHost* host = GetRenderViewHost(); |
| 342 if (host && host->GetView()) | 342 if (host && host->GetView()) |
| 343 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); | 343 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); |
| 344 } | 344 } |
| 345 #endif | 345 #endif |
| 346 | 346 |
| 347 // OnCloseStarted isn't called in unit tests. | 347 // OnCloseStarted isn't called in unit tests. |
| 348 if (!close_start_time_.is_null()) { | 348 if (!close_start_time_.is_null()) { |
| 349 base::TimeTicks now = base::TimeTicks::Now(); | 349 base::TimeTicks now = base::TimeTicks::Now(); |
| 350 base::TimeDelta close_time = now - close_start_time_; | |
| 351 UMA_HISTOGRAM_TIMES("Tab.Close", close_time); | |
| 352 | |
| 353 base::TimeTicks unload_start_time = close_start_time_; | 350 base::TimeTicks unload_start_time = close_start_time_; |
| 354 base::TimeTicks unload_end_time = now; | |
| 355 if (!before_unload_end_time_.is_null()) | 351 if (!before_unload_end_time_.is_null()) |
| 356 unload_start_time = before_unload_end_time_; | 352 unload_start_time = before_unload_end_time_; |
| 357 if (!unload_detached_start_time_.is_null()) | 353 UMA_HISTOGRAM_TIMES("Tab.Close", now - close_start_time_); |
| 358 unload_end_time = unload_detached_start_time_; | 354 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", now - unload_start_time); |
| 359 base::TimeDelta unload_time = unload_end_time - unload_start_time; | |
| 360 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time); | |
| 361 } | 355 } |
| 362 | 356 |
| 363 FOR_EACH_OBSERVER(WebContentsObserver, | 357 FOR_EACH_OBSERVER(WebContentsObserver, |
| 364 observers_, | 358 observers_, |
| 365 WebContentsImplDestroyed()); | 359 WebContentsImplDestroyed()); |
| 366 | 360 |
| 367 SetDelegate(NULL); | 361 SetDelegate(NULL); |
| 368 } | 362 } |
| 369 | 363 |
| 370 WebContentsImpl* WebContentsImpl::CreateWithOpener( | 364 WebContentsImpl* WebContentsImpl::CreateWithOpener( |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 | 1816 |
| 1823 void WebContentsImpl::Close() { | 1817 void WebContentsImpl::Close() { |
| 1824 Close(GetRenderViewHost()); | 1818 Close(GetRenderViewHost()); |
| 1825 } | 1819 } |
| 1826 | 1820 |
| 1827 void WebContentsImpl::OnCloseStarted() { | 1821 void WebContentsImpl::OnCloseStarted() { |
| 1828 if (close_start_time_.is_null()) | 1822 if (close_start_time_.is_null()) |
| 1829 close_start_time_ = base::TimeTicks::Now(); | 1823 close_start_time_ = base::TimeTicks::Now(); |
| 1830 } | 1824 } |
| 1831 | 1825 |
| 1832 void WebContentsImpl::OnCloseCanceled() { | |
| 1833 close_start_time_ = base::TimeTicks(); | |
| 1834 before_unload_end_time_ = base::TimeTicks(); | |
| 1835 unload_detached_start_time_ = base::TimeTicks(); | |
| 1836 } | |
| 1837 | |
| 1838 void WebContentsImpl::OnUnloadStarted() { | |
| 1839 before_unload_end_time_ = base::TimeTicks::Now(); | |
| 1840 } | |
| 1841 | |
| 1842 void WebContentsImpl::OnUnloadDetachedStarted() { | |
| 1843 if (unload_detached_start_time_.is_null()) | |
| 1844 unload_detached_start_time_ = base::TimeTicks::Now(); | |
| 1845 } | |
| 1846 | |
| 1847 void WebContentsImpl::SystemDragEnded() { | 1826 void WebContentsImpl::SystemDragEnded() { |
| 1848 if (GetRenderViewHost()) | 1827 if (GetRenderViewHost()) |
| 1849 GetRenderViewHostImpl()->DragSourceSystemDragEnded(); | 1828 GetRenderViewHostImpl()->DragSourceSystemDragEnded(); |
| 1850 if (delegate_) | 1829 if (delegate_) |
| 1851 delegate_->DragEnded(); | 1830 delegate_->DragEnded(); |
| 1852 } | 1831 } |
| 1853 | 1832 |
| 1854 void WebContentsImpl::UserGestureDone() { | 1833 void WebContentsImpl::UserGestureDone() { |
| 1855 OnUserGesture(); | 1834 OnUserGesture(); |
| 1856 } | 1835 } |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3366 | 3345 |
| 3367 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, | 3346 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, |
| 3368 IPC::Message* reply_msg, | 3347 IPC::Message* reply_msg, |
| 3369 bool success, | 3348 bool success, |
| 3370 const string16& user_input) { | 3349 const string16& user_input) { |
| 3371 if (is_showing_before_unload_dialog_ && !success) { | 3350 if (is_showing_before_unload_dialog_ && !success) { |
| 3372 // If a beforeunload dialog is canceled, we need to stop the throbber from | 3351 // If a beforeunload dialog is canceled, we need to stop the throbber from |
| 3373 // spinning, since we forced it to start spinning in Navigate. | 3352 // spinning, since we forced it to start spinning in Navigate. |
| 3374 DidStopLoading(rvh); | 3353 DidStopLoading(rvh); |
| 3375 controller_.DiscardNonCommittedEntries(); | 3354 controller_.DiscardNonCommittedEntries(); |
| 3376 OnCloseCanceled(); | 3355 |
| 3356 close_start_time_ = base::TimeTicks(); |
| 3357 before_unload_end_time_ = base::TimeTicks(); |
| 3377 } | 3358 } |
| 3378 is_showing_before_unload_dialog_ = false; | 3359 is_showing_before_unload_dialog_ = false; |
| 3379 static_cast<RenderViewHostImpl*>( | 3360 static_cast<RenderViewHostImpl*>( |
| 3380 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); | 3361 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
| 3381 } | 3362 } |
| 3382 | 3363 |
| 3383 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 3364 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
| 3384 encoding_ = GetContentClient()->browser()-> | 3365 encoding_ = GetContentClient()->browser()-> |
| 3385 GetCanonicalEncodingNameByAliasName(encoding); | 3366 GetCanonicalEncodingNameByAliasName(encoding); |
| 3386 } | 3367 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3429 } | 3410 } |
| 3430 | 3411 |
| 3431 BrowserPluginGuestManager* | 3412 BrowserPluginGuestManager* |
| 3432 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3413 WebContentsImpl::GetBrowserPluginGuestManager() const { |
| 3433 return static_cast<BrowserPluginGuestManager*>( | 3414 return static_cast<BrowserPluginGuestManager*>( |
| 3434 GetBrowserContext()->GetUserData( | 3415 GetBrowserContext()->GetUserData( |
| 3435 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3416 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
| 3436 } | 3417 } |
| 3437 | 3418 |
| 3438 } // namespace content | 3419 } // namespace content |
| OLD | NEW |