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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 17151010: Move histograms and supporting code that don't belong in content out. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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
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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 #if defined(OS_WIN) && !defined(USE_AURA) 390 #if defined(OS_WIN) && !defined(USE_AURA)
391 // If we still have a window handle, destroy it. GetNativeView can return 391 // If we still have a window handle, destroy it. GetNativeView can return
392 // NULL if this contents was part of a window that closed. 392 // NULL if this contents was part of a window that closed.
393 if (view_->GetNativeView()) { 393 if (view_->GetNativeView()) {
394 RenderViewHost* host = GetRenderViewHost(); 394 RenderViewHost* host = GetRenderViewHost();
395 if (host && host->GetView()) 395 if (host && host->GetView())
396 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); 396 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy();
397 } 397 }
398 #endif 398 #endif
399 399
400 // OnCloseStarted isn't called in unit tests.
401 if (!close_start_time_.is_null()) {
402 base::TimeTicks now = base::TimeTicks::Now();
403 base::TimeDelta close_time = now - close_start_time_;
404 UMA_HISTOGRAM_TIMES("Tab.Close", close_time);
405
406 base::TimeTicks unload_start_time = close_start_time_;
407 base::TimeTicks unload_end_time = now;
408 if (!before_unload_end_time_.is_null())
409 unload_start_time = before_unload_end_time_;
410 if (!unload_detached_start_time_.is_null())
411 unload_end_time = unload_detached_start_time_;
412 base::TimeDelta unload_time = unload_end_time - unload_start_time;
413 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time);
414
415 }
416
417 FOR_EACH_OBSERVER(WebContentsObserver, 400 FOR_EACH_OBSERVER(WebContentsObserver,
418 observers_, 401 observers_,
419 WebContentsImplDestroyed()); 402 WebContentsImplDestroyed());
420 403
421 SetDelegate(NULL); 404 SetDelegate(NULL);
422 405
423 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), 406 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(),
424 destruction_observers_.end()); 407 destruction_observers_.end());
425 } 408 }
426 409
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 1922
1940 void WebContentsImpl::ResetOverrideEncoding() { 1923 void WebContentsImpl::ResetOverrideEncoding() {
1941 encoding_.clear(); 1924 encoding_.clear();
1942 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID())); 1925 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID()));
1943 } 1926 }
1944 1927
1945 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { 1928 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() {
1946 return &renderer_preferences_; 1929 return &renderer_preferences_;
1947 } 1930 }
1948 1931
1949 void WebContentsImpl::SetNewTabStartTime(const base::TimeTicks& time) {
1950 new_tab_start_time_ = time;
1951 }
1952
1953 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const {
1954 return new_tab_start_time_;
1955 }
1956
1957 void WebContentsImpl::Close() { 1932 void WebContentsImpl::Close() {
1958 Close(GetRenderViewHost()); 1933 Close(GetRenderViewHost());
1959 } 1934 }
1960 1935
1961 void WebContentsImpl::OnCloseStarted() {
1962 if (close_start_time_.is_null())
1963 close_start_time_ = base::TimeTicks::Now();
1964 }
1965
1966 void WebContentsImpl::OnCloseCanceled() {
1967 close_start_time_ = base::TimeTicks();
1968 before_unload_end_time_ = base::TimeTicks();
1969 unload_detached_start_time_ = base::TimeTicks();
1970 }
1971
1972 void WebContentsImpl::OnUnloadStarted() {
1973 before_unload_end_time_ = base::TimeTicks::Now();
1974 }
1975
1976 void WebContentsImpl::OnUnloadDetachedStarted() {
1977 if (unload_detached_start_time_.is_null())
1978 unload_detached_start_time_ = base::TimeTicks::Now();
1979 }
1980
1981 void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y, 1936 void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y,
1982 int screen_x, int screen_y, WebKit::WebDragOperation operation) { 1937 int screen_x, int screen_y, WebKit::WebDragOperation operation) {
1983 if (browser_plugin_embedder_.get()) 1938 if (browser_plugin_embedder_.get())
1984 browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y, 1939 browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y,
1985 screen_x, screen_y, operation); 1940 screen_x, screen_y, operation);
1986 if (GetRenderViewHost()) 1941 if (GetRenderViewHost())
1987 GetRenderViewHostImpl()->DragSourceEndedAt(client_x, client_y, 1942 GetRenderViewHostImpl()->DragSourceEndedAt(client_x, client_y,
1988 screen_x, screen_y, operation); 1943 screen_x, screen_y, operation);
1989 } 1944 }
1990 1945
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
3493 } 3448 }
3494 3449
3495 void WebContentsImpl::WorkerCrashed() { 3450 void WebContentsImpl::WorkerCrashed() {
3496 if (delegate_) 3451 if (delegate_)
3497 delegate_->WorkerCrashed(this); 3452 delegate_->WorkerCrashed(this);
3498 } 3453 }
3499 3454
3500 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( 3455 void WebContentsImpl::BeforeUnloadFiredFromRenderManager(
3501 bool proceed, const base::TimeTicks& proceed_time, 3456 bool proceed, const base::TimeTicks& proceed_time,
3502 bool* proceed_to_fire_unload) { 3457 bool* proceed_to_fire_unload) {
3503 before_unload_end_time_ = proceed_time;
3504 if (delegate_) 3458 if (delegate_)
3505 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); 3459 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload);
3460 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3461 BeforeUnloadFired(proceed_time));
3506 } 3462 }
3507 3463
3508 void WebContentsImpl::RenderViewGoneFromRenderManager( 3464 void WebContentsImpl::RenderViewGoneFromRenderManager(
3509 RenderViewHost* render_view_host) { 3465 RenderViewHost* render_view_host) {
3510 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); 3466 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING);
3511 RenderViewTerminated(render_view_host, crashed_status_, crashed_error_code_); 3467 RenderViewTerminated(render_view_host, crashed_status_, crashed_error_code_);
3512 } 3468 }
3513 3469
3514 void WebContentsImpl::UpdateRenderViewSizeForRenderManager() { 3470 void WebContentsImpl::UpdateRenderViewSizeForRenderManager() {
3515 // TODO(brettw) this is a hack. See WebContentsView::SizeContents. 3471 // TODO(brettw) this is a hack. See WebContentsView::SizeContents.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 3591
3636 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, 3592 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh,
3637 IPC::Message* reply_msg, 3593 IPC::Message* reply_msg,
3638 bool success, 3594 bool success,
3639 const string16& user_input) { 3595 const string16& user_input) {
3640 if (is_showing_before_unload_dialog_ && !success) { 3596 if (is_showing_before_unload_dialog_ && !success) {
3641 // If a beforeunload dialog is canceled, we need to stop the throbber from 3597 // If a beforeunload dialog is canceled, we need to stop the throbber from
3642 // spinning, since we forced it to start spinning in Navigate. 3598 // spinning, since we forced it to start spinning in Navigate.
3643 DidStopLoading(rvh); 3599 DidStopLoading(rvh);
3644 controller_.DiscardNonCommittedEntries(); 3600 controller_.DiscardNonCommittedEntries();
3645 OnCloseCanceled(); 3601
3602 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3603 BeforeUnloadDialogCancelled());
3646 } 3604 }
3647 is_showing_before_unload_dialog_ = false; 3605 is_showing_before_unload_dialog_ = false;
3648 static_cast<RenderViewHostImpl*>( 3606 static_cast<RenderViewHostImpl*>(
3649 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); 3607 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input);
3650 } 3608 }
3651 3609
3652 void WebContentsImpl::SetEncoding(const std::string& encoding) { 3610 void WebContentsImpl::SetEncoding(const std::string& encoding) {
3653 encoding_ = GetContentClient()->browser()-> 3611 encoding_ = GetContentClient()->browser()->
3654 GetCanonicalEncodingNameByAliasName(encoding); 3612 GetCanonicalEncodingNameByAliasName(encoding);
3655 } 3613 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3698 } 3656 }
3699 3657
3700 BrowserPluginGuestManager* 3658 BrowserPluginGuestManager*
3701 WebContentsImpl::GetBrowserPluginGuestManager() const { 3659 WebContentsImpl::GetBrowserPluginGuestManager() const {
3702 return static_cast<BrowserPluginGuestManager*>( 3660 return static_cast<BrowserPluginGuestManager*>(
3703 GetBrowserContext()->GetUserData( 3661 GetBrowserContext()->GetUserData(
3704 browser_plugin::kBrowserPluginGuestManagerKeyName)); 3662 browser_plugin::kBrowserPluginGuestManagerKeyName));
3705 } 3663 }
3706 3664
3707 } // namespace content 3665 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698