| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 if (GetNativeView()) { | 356 if (GetNativeView()) { |
| 357 RenderViewHost* host = GetRenderViewHost(); | 357 RenderViewHost* host = GetRenderViewHost(); |
| 358 if (host && host->GetView()) | 358 if (host && host->GetView()) |
| 359 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); | 359 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); |
| 360 } | 360 } |
| 361 #endif | 361 #endif |
| 362 | 362 |
| 363 // OnCloseStarted isn't called in unit tests. | 363 // OnCloseStarted isn't called in unit tests. |
| 364 if (!close_start_time_.is_null()) { | 364 if (!close_start_time_.is_null()) { |
| 365 base::TimeTicks now = base::TimeTicks::Now(); | 365 base::TimeTicks now = base::TimeTicks::Now(); |
| 366 base::TimeDelta close_time = now - close_start_time_; |
| 367 UMA_HISTOGRAM_TIMES("Tab.Close", close_time); |
| 368 |
| 366 base::TimeTicks unload_start_time = close_start_time_; | 369 base::TimeTicks unload_start_time = close_start_time_; |
| 370 base::TimeTicks unload_end_time = now; |
| 367 if (!before_unload_end_time_.is_null()) | 371 if (!before_unload_end_time_.is_null()) |
| 368 unload_start_time = before_unload_end_time_; | 372 unload_start_time = before_unload_end_time_; |
| 369 UMA_HISTOGRAM_TIMES("Tab.Close", now - close_start_time_); | 373 if (!unload_detached_start_time_.is_null()) |
| 370 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", now - unload_start_time); | 374 unload_end_time = unload_detached_start_time_; |
| 375 base::TimeDelta unload_time = unload_end_time - unload_start_time; |
| 376 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time); |
| 371 } | 377 } |
| 372 | 378 |
| 373 FOR_EACH_OBSERVER(WebContentsObserver, | 379 FOR_EACH_OBSERVER(WebContentsObserver, |
| 374 observers_, | 380 observers_, |
| 375 WebContentsImplDestroyed()); | 381 WebContentsImplDestroyed()); |
| 376 | 382 |
| 377 SetDelegate(NULL); | 383 SetDelegate(NULL); |
| 378 } | 384 } |
| 379 | 385 |
| 380 WebContentsImpl* WebContentsImpl::Create( | 386 WebContentsImpl* WebContentsImpl::Create( |
| (...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 | 1754 |
| 1749 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const { | 1755 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const { |
| 1750 return new_tab_start_time_; | 1756 return new_tab_start_time_; |
| 1751 } | 1757 } |
| 1752 | 1758 |
| 1753 void WebContentsImpl::Close() { | 1759 void WebContentsImpl::Close() { |
| 1754 Close(GetRenderViewHost()); | 1760 Close(GetRenderViewHost()); |
| 1755 } | 1761 } |
| 1756 | 1762 |
| 1757 void WebContentsImpl::OnCloseStarted() { | 1763 void WebContentsImpl::OnCloseStarted() { |
| 1758 if (close_start_time_.is_null()) | 1764 if (close_start_time_.is_null()) { |
| 1759 close_start_time_ = base::TimeTicks::Now(); | 1765 close_start_time_ = base::TimeTicks::Now(); |
| 1766 } |
| 1767 } |
| 1768 |
| 1769 void WebContentsImpl::OnUnloadDetachedStarted() { |
| 1770 if (unload_detached_start_time_.is_null()) { |
| 1771 unload_detached_start_time_ = base::TimeTicks::Now(); |
| 1772 } |
| 1760 } | 1773 } |
| 1761 | 1774 |
| 1762 bool WebContentsImpl::ShouldAcceptDragAndDrop() const { | 1775 bool WebContentsImpl::ShouldAcceptDragAndDrop() const { |
| 1763 #if defined(OS_CHROMEOS) | 1776 #if defined(OS_CHROMEOS) |
| 1764 // ChromeOS panels (pop-ups) do not take drag-n-drop. | 1777 // ChromeOS panels (pop-ups) do not take drag-n-drop. |
| 1765 // See http://crosbug.com/2413 | 1778 // See http://crosbug.com/2413 |
| 1766 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 1779 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
| 1767 return false; | 1780 return false; |
| 1768 return true; | 1781 return true; |
| 1769 #else | 1782 #else |
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3313 bool success, | 3326 bool success, |
| 3314 const string16& user_input) { | 3327 const string16& user_input) { |
| 3315 if (is_showing_before_unload_dialog_ && !success) { | 3328 if (is_showing_before_unload_dialog_ && !success) { |
| 3316 // If a beforeunload dialog is canceled, we need to stop the throbber from | 3329 // If a beforeunload dialog is canceled, we need to stop the throbber from |
| 3317 // spinning, since we forced it to start spinning in Navigate. | 3330 // spinning, since we forced it to start spinning in Navigate. |
| 3318 DidStopLoading(rvh); | 3331 DidStopLoading(rvh); |
| 3319 controller_.DiscardNonCommittedEntries(); | 3332 controller_.DiscardNonCommittedEntries(); |
| 3320 | 3333 |
| 3321 close_start_time_ = base::TimeTicks(); | 3334 close_start_time_ = base::TimeTicks(); |
| 3322 before_unload_end_time_ = base::TimeTicks(); | 3335 before_unload_end_time_ = base::TimeTicks(); |
| 3336 unload_detached_start_time_ = base::TimeTicks(); |
| 3323 } | 3337 } |
| 3324 is_showing_before_unload_dialog_ = false; | 3338 is_showing_before_unload_dialog_ = false; |
| 3325 static_cast<RenderViewHostImpl*>( | 3339 static_cast<RenderViewHostImpl*>( |
| 3326 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); | 3340 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
| 3327 } | 3341 } |
| 3328 | 3342 |
| 3329 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 3343 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
| 3330 encoding_ = GetContentClient()->browser()-> | 3344 encoding_ = GetContentClient()->browser()-> |
| 3331 GetCanonicalEncodingNameByAliasName(encoding); | 3345 GetCanonicalEncodingNameByAliasName(encoding); |
| 3332 } | 3346 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3385 | 3399 |
| 3386 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3400 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3387 return browser_plugin_guest_.get(); | 3401 return browser_plugin_guest_.get(); |
| 3388 } | 3402 } |
| 3389 | 3403 |
| 3390 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3404 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3391 return browser_plugin_embedder_.get(); | 3405 return browser_plugin_embedder_.get(); |
| 3392 } | 3406 } |
| 3393 | 3407 |
| 3394 } // namespace content | 3408 } // namespace content |
| OLD | NEW |