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

Side by Side Diff: chrome/browser/metrics/thread_watcher.cc

Issue 289283011: Introduce ChromeStabilityMetricsProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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 | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/chrome_browser.gypi » ('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 "chrome/browser/metrics/thread_watcher.h" 5 #include "chrome/browser/metrics/thread_watcher.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/debug/alias.h" 11 #include "base/debug/alias.h"
12 #include "base/debug/dump_without_crashing.h" 12 #include "base/debug/dump_without_crashing.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/metrics/field_trial.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/strings/string_tokenizer.h" 17 #include "base/strings/string_tokenizer.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "base/threading/thread_restrictions.h" 19 #include "base/threading/thread_restrictions.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "chrome/browser/metrics/metrics_service.h" 21 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/chrome_version_info.h" 23 #include "chrome/common/chrome_version_info.h"
23 #include "chrome/common/logging_chrome.h" 24 #include "chrome/common/logging_chrome.h"
25 #include "content/public/browser/notification_service.h"
24 26
25 #if defined(OS_WIN) 27 #if defined(OS_WIN)
26 #include "base/win/windows_version.h" 28 #include "base/win/windows_version.h"
27 #endif 29 #endif
28 30
29 using content::BrowserThread; 31 using content::BrowserThread;
30 32
31 namespace { 33 namespace {
32 34
33 // The following are unique function names for forcing the crash when a thread 35 // The following are unique function names for forcing the crash when a thread
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 ThreadWatcherObserver::~ThreadWatcherObserver() { 778 ThreadWatcherObserver::~ThreadWatcherObserver() {
777 DCHECK(this == g_thread_watcher_observer_); 779 DCHECK(this == g_thread_watcher_observer_);
778 g_thread_watcher_observer_ = NULL; 780 g_thread_watcher_observer_ = NULL;
779 } 781 }
780 782
781 // static 783 // static
782 void ThreadWatcherObserver::SetupNotifications( 784 void ThreadWatcherObserver::SetupNotifications(
783 const base::TimeDelta& wakeup_interval) { 785 const base::TimeDelta& wakeup_interval) {
784 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 786 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
785 ThreadWatcherObserver* observer = new ThreadWatcherObserver(wakeup_interval); 787 ThreadWatcherObserver* observer = new ThreadWatcherObserver(wakeup_interval);
786 MetricsService::SetUpNotifications(&observer->registrar_, observer); 788 observer->registrar_.Add(
789 observer,
790 chrome::NOTIFICATION_BROWSER_OPENED,
791 content::NotificationService::AllBrowserContextsAndSources());
792 observer->registrar_.Add(observer,
793 chrome::NOTIFICATION_BROWSER_CLOSED,
794 content::NotificationService::AllSources());
795 observer->registrar_.Add(observer,
796 chrome::NOTIFICATION_TAB_PARENTED,
797 content::NotificationService::AllSources());
798 observer->registrar_.Add(observer,
799 chrome::NOTIFICATION_TAB_CLOSING,
800 content::NotificationService::AllSources());
801 observer->registrar_.Add(observer,
802 content::NOTIFICATION_LOAD_START,
803 content::NotificationService::AllSources());
804 observer->registrar_.Add(observer,
805 content::NOTIFICATION_LOAD_STOP,
806 content::NotificationService::AllSources());
807 observer->registrar_.Add(observer,
808 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
809 content::NotificationService::AllSources());
810 observer->registrar_.Add(observer,
811 content::NOTIFICATION_RENDER_WIDGET_HOST_HANG,
812 content::NotificationService::AllSources());
813 observer->registrar_.Add(observer,
814 chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
815 content::NotificationService::AllSources());
787 } 816 }
788 817
789 // static 818 // static
790 void ThreadWatcherObserver::RemoveNotifications() { 819 void ThreadWatcherObserver::RemoveNotifications() {
791 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 820 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
792 if (!g_thread_watcher_observer_) 821 if (!g_thread_watcher_observer_)
793 return; 822 return;
794 g_thread_watcher_observer_->registrar_.RemoveAll(); 823 g_thread_watcher_observer_->registrar_.RemoveAll();
795 delete g_thread_watcher_observer_; 824 delete g_thread_watcher_observer_;
796 } 825 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 1079
1051 #if defined(OS_WIN) 1080 #if defined(OS_WIN)
1052 // On Windows XP, give twice the time for shutdown. 1081 // On Windows XP, give twice the time for shutdown.
1053 if (base::win::GetVersion() <= base::win::VERSION_XP) 1082 if (base::win::GetVersion() <= base::win::VERSION_XP)
1054 actual_duration *= 2; 1083 actual_duration *= 2;
1055 #endif 1084 #endif
1056 1085
1057 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); 1086 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration);
1058 shutdown_watchdog_->Arm(); 1087 shutdown_watchdog_->Arm();
1059 } 1088 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698