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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
7 // | 7 // |
8 // OVERVIEW | 8 // OVERVIEW |
9 // | 9 // |
10 // A MetricsService instance is typically created at application startup. It is | 10 // A MetricsService instance is typically created at application startup. It is |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 #include "extensions/browser/process_map.h" | 219 #include "extensions/browser/process_map.h" |
220 #include "net/base/load_flags.h" | 220 #include "net/base/load_flags.h" |
221 #include "net/url_request/url_fetcher.h" | 221 #include "net/url_request/url_fetcher.h" |
222 | 222 |
223 // TODO(port): port browser_distribution.h. | 223 // TODO(port): port browser_distribution.h. |
224 #if !defined(OS_POSIX) | 224 #if !defined(OS_POSIX) |
225 #include "chrome/installer/util/browser_distribution.h" | 225 #include "chrome/installer/util/browser_distribution.h" |
226 #endif | 226 #endif |
227 | 227 |
228 #if defined(OS_CHROMEOS) | 228 #if defined(OS_CHROMEOS) |
229 #include "chrome/browser/chromeos/settings/cros_settings.h" | 229 #include "chrome/browser/chromeos/settings/cros_settings.h" |
Alexei Svitkine (slow)
2014/05/23 08:41:47
Do you mind doing the hardware class fetching and
Alexei Svitkine (slow)
2014/05/23 08:42:31
(Similar to what GoogleUpdateMetricsProviderWin do
blundell
2014/05/23 12:09:22
I'd prefer to leave this as a followup (and create
Alexei Svitkine (slow)
2014/05/23 14:16:20
OK
| |
230 #include "chrome/browser/metrics/chromeos_metrics_provider.h" | |
230 #include "chromeos/system/statistics_provider.h" | 231 #include "chromeos/system/statistics_provider.h" |
231 #endif | 232 #endif |
232 | 233 |
233 #if defined(OS_WIN) | 234 #if defined(OS_WIN) |
234 #include <windows.h> // Needed for STATUS_* codes | 235 #include <windows.h> // Needed for STATUS_* codes |
235 #include "base/win/registry.h" | 236 #include "base/win/registry.h" |
236 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" | 237 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" |
237 #endif | 238 #endif |
238 | 239 |
239 #if !defined(OS_ANDROID) | 240 #if !defined(OS_ANDROID) |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 | 484 |
484 // TODO(asvitkine): Move this out of MetricsService. | 485 // TODO(asvitkine): Move this out of MetricsService. |
485 RegisterMetricsProvider( | 486 RegisterMetricsProvider( |
486 scoped_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider)); | 487 scoped_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider)); |
487 | 488 |
488 #if defined(OS_WIN) | 489 #if defined(OS_WIN) |
489 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; | 490 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; |
490 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>( | 491 RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider>( |
491 google_update_metrics_provider_)); | 492 google_update_metrics_provider_)); |
492 #endif | 493 #endif |
494 | |
495 #if defined(OS_CHROMEOS) | |
496 RegisterMetricsProvider( | |
497 scoped_ptr<metrics::MetricsProvider>(new ChromeOSMetricsProvider)); | |
498 #endif | |
499 | |
493 BrowserChildProcessObserver::Add(this); | 500 BrowserChildProcessObserver::Add(this); |
494 } | 501 } |
495 | 502 |
496 MetricsService::~MetricsService() { | 503 MetricsService::~MetricsService() { |
497 DisableRecording(); | 504 DisableRecording(); |
498 | 505 |
499 BrowserChildProcessObserver::Remove(this); | 506 BrowserChildProcessObserver::Remove(this); |
500 } | 507 } |
501 | 508 |
502 void MetricsService::InitializeMetricsRecordingState() { | 509 void MetricsService::InitializeMetricsRecordingState() { |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1025 | 1032 |
1026 void MetricsService::RemoveObserver(MetricsServiceObserver* observer) { | 1033 void MetricsService::RemoveObserver(MetricsServiceObserver* observer) { |
1027 DCHECK(thread_checker_.CalledOnValidThread()); | 1034 DCHECK(thread_checker_.CalledOnValidThread()); |
1028 observers_.RemoveObserver(observer); | 1035 observers_.RemoveObserver(observer); |
1029 } | 1036 } |
1030 | 1037 |
1031 void MetricsService::NotifyOnDidCreateMetricsLog() { | 1038 void MetricsService::NotifyOnDidCreateMetricsLog() { |
1032 DCHECK(thread_checker_.CalledOnValidThread()); | 1039 DCHECK(thread_checker_.CalledOnValidThread()); |
1033 FOR_EACH_OBSERVER( | 1040 FOR_EACH_OBSERVER( |
1034 MetricsServiceObserver, observers_, OnDidCreateMetricsLog()); | 1041 MetricsServiceObserver, observers_, OnDidCreateMetricsLog()); |
1042 for (size_t i = 0; i < metrics_providers_.size(); ++i) | |
1043 metrics_providers_[i]->OnDidCreateMetricsLog(); | |
1035 } | 1044 } |
1036 | 1045 |
1037 //------------------------------------------------------------------------------ | 1046 //------------------------------------------------------------------------------ |
1038 // State save methods | 1047 // State save methods |
1039 | 1048 |
1040 void MetricsService::ScheduleNextStateSave() { | 1049 void MetricsService::ScheduleNextStateSave() { |
1041 state_saver_factory_.InvalidateWeakPtrs(); | 1050 state_saver_factory_.InvalidateWeakPtrs(); |
1042 | 1051 |
1043 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1052 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1044 base::Bind(&MetricsService::SaveLocalState, | 1053 base::Bind(&MetricsService::SaveLocalState, |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1720 // Redundant setting to assure that we always reset this value at shutdown | 1729 // Redundant setting to assure that we always reset this value at shutdown |
1721 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1730 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
1722 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1731 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
1723 | 1732 |
1724 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); | 1733 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); |
1725 PrefService* pref = g_browser_process->local_state(); | 1734 PrefService* pref = g_browser_process->local_state(); |
1726 pref->SetInteger(prefs::kStabilityExecutionPhase, | 1735 pref->SetInteger(prefs::kStabilityExecutionPhase, |
1727 MetricsService::SHUTDOWN_COMPLETE); | 1736 MetricsService::SHUTDOWN_COMPLETE); |
1728 } | 1737 } |
1729 | 1738 |
1730 #if defined(OS_CHROMEOS) | |
1731 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { | |
1732 if (crash_type == "user") | |
1733 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount); | |
1734 else if (crash_type == "kernel") | |
1735 IncrementPrefValue(prefs::kStabilityKernelCrashCount); | |
1736 else if (crash_type == "uncleanshutdown") | |
1737 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount); | |
1738 else | |
1739 NOTREACHED() << "Unexpected Chrome OS crash type " << crash_type; | |
1740 // Wake up metrics logs sending if necessary now that new | |
1741 // log data is available. | |
1742 HandleIdleSinceLastTransmission(false); | |
1743 } | |
1744 #endif // OS_CHROMEOS | |
1745 | |
1746 void MetricsService::LogPluginLoadingError(const base::FilePath& plugin_path) { | 1739 void MetricsService::LogPluginLoadingError(const base::FilePath& plugin_path) { |
1747 content::WebPluginInfo plugin; | 1740 content::WebPluginInfo plugin; |
1748 bool success = | 1741 bool success = |
1749 content::PluginService::GetInstance()->GetPluginInfoByPath(plugin_path, | 1742 content::PluginService::GetInstance()->GetPluginInfoByPath(plugin_path, |
1750 &plugin); | 1743 &plugin); |
1751 DCHECK(success); | 1744 DCHECK(success); |
1752 ChildProcessStats& stats = child_process_stats_buffer_[plugin.name]; | 1745 ChildProcessStats& stats = child_process_stats_buffer_[plugin.name]; |
1753 // Initialize the type if this entry is new. | 1746 // Initialize the type if this entry is new. |
1754 if (stats.process_type == content::PROCESS_TYPE_UNKNOWN) { | 1747 if (stats.process_type == content::PROCESS_TYPE_UNKNOWN) { |
1755 // The plug-in process might not actually of type PLUGIN (which means | 1748 // The plug-in process might not actually of type PLUGIN (which means |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1930 if (metrics_service) | 1923 if (metrics_service) |
1931 metrics_service->AddObserver(observer); | 1924 metrics_service->AddObserver(observer); |
1932 } | 1925 } |
1933 | 1926 |
1934 void MetricsServiceHelper::RemoveMetricsServiceObserver( | 1927 void MetricsServiceHelper::RemoveMetricsServiceObserver( |
1935 MetricsServiceObserver* observer) { | 1928 MetricsServiceObserver* observer) { |
1936 MetricsService* metrics_service = g_browser_process->metrics_service(); | 1929 MetricsService* metrics_service = g_browser_process->metrics_service(); |
1937 if (metrics_service) | 1930 if (metrics_service) |
1938 metrics_service->RemoveObserver(observer); | 1931 metrics_service->RemoveObserver(observer); |
1939 } | 1932 } |
OLD | NEW |