diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-11 01:58:19 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-11 01:58:19 +0000 |
commit | d6147bd26ea4e26f029cebfbce77438012c32c9e (patch) | |
tree | ed750a96162d0894a1fbe3f240b1da29bad208bc | |
parent | a6e8d2a0422d719ba611087ef2789b55f09df8c1 (diff) | |
download | chromium_src-d6147bd26ea4e26f029cebfbce77438012c32c9e.zip chromium_src-d6147bd26ea4e26f029cebfbce77438012c32c9e.tar.gz chromium_src-d6147bd26ea4e26f029cebfbce77438012c32c9e.tar.bz2 |
Componentize MetricsService.
MetricsService, along with prefs that it uses, is moved into the Metrics
component.
A later CL will move MetricsService (and all other code in the metrics
component) into the metrics namespace.
BUG=374198
TBR=jochen
Review URL: https://codereview.chromium.org/320553002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276229 0039d316-1c4b-4281-b951-d872f2087c98
29 files changed, 130 insertions, 126 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 809009c..01e0d30 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -45,7 +45,6 @@ #include "chrome/browser/intranet_redirect_detector.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/lifetime/application_lifetime.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/metrics/metrics_services_manager.h" #include "chrome/browser/metrics/thread_watcher.h" #include "chrome/browser/net/chrome_net_log.h" @@ -78,6 +77,7 @@ #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_update_settings.h" #include "components/gcm_driver/gcm_driver.h" +#include "components/metrics/metrics_service.h" #include "components/network_time/network_time_tracker.h" #include "components/policy/core/common/policy_service.h" #include "components/signin/core/common/profile_management_switches.h" @@ -406,7 +406,7 @@ void BrowserProcessImpl::EndSession() { #if !defined(OS_CHROMEOS) // MetricsService lazily writes to prefs, force it to write now. // On ChromeOS, chrome gets killed when hangs, so no need to - // commit prefs::kStabilitySessionEndCompleted change immediately. + // commit metrics::prefs::kStabilitySessionEndCompleted change immediately. local_state()->CommitPendingWrite(); #endif } diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc index 37b1ba3..8b39280 100644 --- a/chrome/browser/browser_shutdown.cc +++ b/chrome/browser/browser_shutdown.cc @@ -24,7 +24,6 @@ #include "chrome/browser/first_run/upgrade_util.h" #include "chrome/browser/jankometer.h" #include "chrome/browser/lifetime/application_lifetime.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/service_process/service_process_control.h" #include "chrome/common/chrome_paths.h" @@ -32,6 +31,7 @@ #include "chrome/common/crash_keys.h" #include "chrome/common/pref_names.h" #include "chrome/common/switch_utils.h" +#include "components/metrics/metrics_service.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index c8118f0..ff3dc9b 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -61,7 +61,6 @@ #include "chrome/browser/jankometer.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/metrics/field_trial_synchronizer.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/metrics/thread_watcher.h" #include "chrome/browser/metrics/tracking_synchronizer.h" #include "chrome/browser/metrics/variations/variations_http_header_provider.h" @@ -107,6 +106,7 @@ #include "chrome/common/profiling.h" #include "chrome/installer/util/google_update_settings.h" #include "components/language_usage_metrics/language_usage_metrics.h" +#include "components/metrics/metrics_service.h" #include "components/nacl/browser/nacl_browser.h" #include "components/nacl/browser/nacl_process_host.h" #include "components/rappor/rappor_service.h" diff --git a/chrome/browser/chrome_browser_main_linux.cc b/chrome/browser/chrome_browser_main_linux.cc index dba10a3..b7967f8 100644 --- a/chrome/browser/chrome_browser_main_linux.cc +++ b/chrome/browser/chrome_browser_main_linux.cc @@ -5,8 +5,8 @@ #include "chrome/browser/chrome_browser_main_linux.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/metrics/metrics_service.h" #include "components/breakpad/app/breakpad_linux.h" +#include "components/metrics/metrics_service.h" #if !defined(OS_CHROMEOS) #include "base/linux_util.h" diff --git a/chrome/browser/chrome_browser_main_mac.mm b/chrome/browser/chrome_browser_main_mac.mm index bda75fb..61a1faa 100644 --- a/chrome/browser/chrome_browser_main_mac.mm +++ b/chrome/browser/chrome_browser_main_mac.mm @@ -20,11 +20,11 @@ #import "chrome/browser/chrome_browser_application_mac.h" #include "chrome/browser/mac/install_from_dmg.h" #import "chrome/browser/mac/keystone_glue.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/ui/app_list/app_list_service.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "components/breakpad/app/breakpad_mac.h" +#include "components/metrics/metrics_service.h" #include "content/public/common/main_function_params.h" #include "content/public/common/result_codes.h" #include "ui/base/l10n/l10n_util_mac.h" diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index e73622f..79f4d84 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -74,7 +74,6 @@ #include "chrome/browser/chromeos/upgrade_detector_chromeos.h" #include "chrome/browser/defaults.h" #include "chrome/browser/lifetime/application_lifetime.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/net/chrome_network_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -105,6 +104,7 @@ #include "chromeos/network/network_handler.h" #include "chromeos/system/statistics_provider.h" #include "chromeos/tpm_token_loader.h" +#include "components/metrics/metrics_service.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/power_save_blocker.h" diff --git a/chrome/browser/chromeos/extensions/info_private_api.cc b/chrome/browser/chromeos/extensions/info_private_api.cc index 9d4d482..b55c897 100644 --- a/chrome/browser/chromeos/extensions/info_private_api.cc +++ b/chrome/browser/chromeos/extensions/info_private_api.cc @@ -15,7 +15,6 @@ #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/system/timezone_util.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" #include "chromeos/network/device_state.h" @@ -23,6 +22,7 @@ #include "chromeos/network/network_state_handler.h" #include "chromeos/settings/cros_settings_names.h" #include "chromeos/system/statistics_provider.h" +#include "components/metrics/metrics_service.h" #include "extensions/common/error_utils.h" #include "third_party/cros_system_api/dbus/service_constants.h" diff --git a/chrome/browser/chromeos/external_metrics.cc b/chrome/browser/chromeos/external_metrics.cc index 248e3e3..d295d63 100644 --- a/chrome/browser/chromeos/external_metrics.cc +++ b/chrome/browser/chromeos/external_metrics.cc @@ -17,9 +17,9 @@ #include "base/timer/elapsed_timer.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/metrics/chromeos_metrics_provider.h" -#include "chrome/browser/metrics/metrics_service.h" #include "components/metrics/chromeos/metric_sample.h" #include "components/metrics/chromeos/serialization_utils.h" +#include "components/metrics/metrics_service.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/user_metrics.h" diff --git a/chrome/browser/metrics/chrome_metrics_service_accessor.cc b/chrome/browser/metrics/chrome_metrics_service_accessor.cc index bd8dfa3..6c142fc 100644 --- a/chrome/browser/metrics/chrome_metrics_service_accessor.cc +++ b/chrome/browser/metrics/chrome_metrics_service_accessor.cc @@ -6,8 +6,8 @@ #include "base/prefs/pref_service.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/common/pref_names.h" +#include "components/metrics/metrics_service.h" #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/settings/cros_settings.h" diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc index 95063b6..2a180d2 100644 --- a/chrome/browser/metrics/chrome_metrics_service_client.cc +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc @@ -26,7 +26,6 @@ #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" #include "chrome/browser/metrics/extensions_metrics_provider.h" #include "chrome/browser/metrics/gpu_metrics_provider.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/metrics/network_metrics_provider.h" #include "chrome/browser/metrics/omnibox_metrics_provider.h" #include "chrome/browser/metrics/profiler_metrics_provider.h" @@ -38,6 +37,7 @@ #include "chrome/common/crash_keys.h" #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" +#include "components/metrics/metrics_service.h" #include "components/metrics/net/net_metrics_log_uploader.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/histogram_fetcher.h" @@ -144,6 +144,10 @@ scoped_ptr<ChromeMetricsServiceClient> ChromeMetricsServiceClient::Create( // static void ChromeMetricsServiceClient::RegisterPrefs(PrefRegistrySimple* registry) { + registry->RegisterInt64Pref(prefs::kInstallDate, 0); + registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); + registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); + MetricsService::RegisterPrefs(registry); ChromeStabilityMetricsProvider::RegisterPrefs(registry); diff --git a/chrome/browser/metrics/chromeos_metrics_provider.cc b/chrome/browser/metrics/chromeos_metrics_provider.cc index a3282d1..ef732c0 100644 --- a/chrome/browser/metrics/chromeos_metrics_provider.cc +++ b/chrome/browser/metrics/chromeos_metrics_provider.cc @@ -11,9 +11,9 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/login/users/user_manager.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/common/pref_names.h" #include "chromeos/system/statistics_provider.h" +#include "components/metrics/metrics_service.h" #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" #include "content/public/browser/browser_thread.h" #include "device/bluetooth/bluetooth_adapter.h" diff --git a/chrome/browser/metrics/metrics_service_accessor.cc b/chrome/browser/metrics/metrics_service_accessor.cc index 6d73e58..e7e8c20 100644 --- a/chrome/browser/metrics/metrics_service_accessor.cc +++ b/chrome/browser/metrics/metrics_service_accessor.cc @@ -5,7 +5,7 @@ #include "chrome/browser/metrics/metrics_service_accessor.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/metrics/metrics_service.h" +#include "components/metrics/metrics_service.h" #include "components/metrics/metrics_service_observer.h" // static diff --git a/chrome/browser/metrics/metrics_service_browsertest.cc b/chrome/browser/metrics/metrics_service_browsertest.cc index 328f994..65de2bb 100644 --- a/chrome/browser/metrics/metrics_service_browsertest.cc +++ b/chrome/browser/metrics/metrics_service_browsertest.cc @@ -5,7 +5,7 @@ // Tests the MetricsService stat recording to make sure that the numbers are // what we expect. -#include "chrome/browser/metrics/metrics_service.h" +#include "components/metrics/metrics_service.h" #include <string> @@ -67,7 +67,8 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CloseRenderersNormally) { EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount)); EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); - // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly + // TODO(isherman): We should also verify that + // metrics::prefs::kStabilityExitedCleanly // is set to true, but this preference isn't set until the browser // exits... it's not clear to me how to test that. } @@ -103,7 +104,8 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, MAYBE_CrashRenderers) { EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); - // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly + // TODO(isherman): We should also verify that + // metrics::prefs::kStabilityExitedCleanly // is set to true, but this preference isn't set until the browser // exits... it's not clear to me how to test that. } diff --git a/chrome/browser/metrics/metrics_service_unittest.cc b/chrome/browser/metrics/metrics_service_unittest.cc index 339e0d0..b75951d 100644 --- a/chrome/browser/metrics/metrics_service_unittest.cc +++ b/chrome/browser/metrics/metrics_service_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/metrics/metrics_service.h" +#include "components/metrics/metrics_service.h" #include <string> @@ -157,7 +157,7 @@ class TestMetricsServiceObserver : public MetricsServiceObserver { TEST_F(MetricsServiceTest, InitialStabilityLogAfterCleanShutDown) { EnableMetricsReporting(); - GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, true); + GetLocalState()->SetBoolean(metrics::prefs::kStabilityExitedCleanly, true); metrics::TestMetricsServiceClient client; TestMetricsService service( @@ -177,7 +177,7 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { TestingBrowserProcess::GetGlobal()); TestingPrefServiceSimple* local_state = testing_local_state.Get(); EnableMetricsReporting(); - local_state->ClearPref(prefs::kStabilityExitedCleanly); + local_state->ClearPref(metrics::prefs::kStabilityExitedCleanly); // Set up prefs to simulate restarting after a crash. @@ -190,12 +190,12 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { // Record stability build time and version from previous session, so that // stability metrics (including exited cleanly flag) won't be cleared. - local_state->SetInt64(prefs::kStabilityStatsBuildTime, + local_state->SetInt64(metrics::prefs::kStabilityStatsBuildTime, MetricsLog::GetBuildTime()); - local_state->SetString(prefs::kStabilityStatsVersion, + local_state->SetString(metrics::prefs::kStabilityStatsVersion, client.GetVersionString()); - local_state->SetBoolean(prefs::kStabilityExitedCleanly, false); + local_state->SetBoolean(metrics::prefs::kStabilityExitedCleanly, false); TestMetricsService service(GetMetricsStateManager(), &client, local_state); service.InitializeMetricsRecordingState(); diff --git a/chrome/browser/metrics/metrics_services_manager.cc b/chrome/browser/metrics/metrics_services_manager.cc index b8e835c..8278913 100644 --- a/chrome/browser/metrics/metrics_services_manager.cc +++ b/chrome/browser/metrics/metrics_services_manager.cc @@ -7,10 +7,10 @@ #include "base/command_line.h" #include "base/prefs/pref_service.h" #include "chrome/browser/metrics/chrome_metrics_service_client.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/metrics/variations/variations_service.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "components/metrics/metrics_service.h" #include "components/metrics/metrics_state_manager.h" #include "components/rappor/rappor_service.h" diff --git a/chrome/browser/prerender/prerender_field_trial.cc b/chrome/browser/prerender/prerender_field_trial.cc index e923547..759b269 100644 --- a/chrome/browser/prerender/prerender_field_trial.cc +++ b/chrome/browser/prerender/prerender_field_trial.cc @@ -11,7 +11,6 @@ #include "base/prefs/pref_service.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/predictors/autocomplete_action_predictor.h" #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/profiles/profile.h" @@ -19,6 +18,7 @@ #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" +#include "components/metrics/metrics_service.h" #include "components/variations/variations_associated_data.h" using base::FieldTrial; diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 069c314..49cfbdf 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -47,7 +47,6 @@ #include "chrome/browser/history/top_sites.h" #include "chrome/browser/media/chrome_midi_permission_context.h" #include "chrome/browser/media/chrome_midi_permission_context_factory.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/net_pref_observer.h" #include "chrome/browser/net/predictor.h" @@ -85,6 +84,7 @@ #include "components/bookmarks/browser/bookmark_model.h" #include "components/dom_distiller/content/dom_distiller_viewer_source.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" +#include "components/metrics/metrics_service.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/startup_metric_utils/startup_metric_utils.h" #include "components/user_prefs/user_prefs.h" diff --git a/chrome/browser/safe_browsing/database_manager.cc b/chrome/browser/safe_browsing/database_manager.cc index fa0a46e..fa2b9cd 100644 --- a/chrome/browser/safe_browsing/database_manager.cc +++ b/chrome/browser/safe_browsing/database_manager.cc @@ -18,7 +18,6 @@ #include "base/threading/thread_restrictions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/prerender/prerender_field_trial.h" #include "chrome/browser/safe_browsing/client_side_detection_service.h" #include "chrome/browser/safe_browsing/download_protection_service.h" @@ -30,6 +29,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "components/metrics/metrics_service.h" #include "components/startup_metric_utils/startup_metric_utils.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index 963cbfa..5f4b65c 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -19,7 +19,6 @@ #include "base/threading/thread_restrictions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/safe_browsing/client_side_detection_service.h" @@ -35,6 +34,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "components/metrics/metrics_service.h" #include "components/startup_metric_utils/startup_metric_utils.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cookie_crypto_delegate.h" diff --git a/chrome/browser/safe_browsing/ui_manager.cc b/chrome/browser/safe_browsing/ui_manager.cc index 611e95b..1f6a7cd 100644 --- a/chrome/browser/safe_browsing/ui_manager.cc +++ b/chrome/browser/safe_browsing/ui_manager.cc @@ -13,13 +13,13 @@ #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/safe_browsing/malware_details.h" #include "chrome/browser/safe_browsing/ping_manager.h" #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/common/url_constants.h" +#include "components/metrics/metrics_service.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_service.h" diff --git a/chrome/browser/ui/options/options_util.cc b/chrome/browser/ui/options/options_util.cc index ea76993..41efdc2 100644 --- a/chrome/browser/ui/options/options_util.cc +++ b/chrome/browser/ui/options/options_util.cc @@ -6,8 +6,8 @@ #include "base/threading/thread_restrictions.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/installer/util/google_update_settings.h" +#include "components/metrics/metrics_service.h" // static bool OptionsUtil::ResolveMetricsReportingEnabled(bool enabled) { diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 82724d1..7430393 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1228,8 +1228,6 @@ 'browser/metrics/gpu_metrics_provider.cc', 'browser/metrics/gpu_metrics_provider.h', 'browser/metrics/metric_event_duration_details.h', - 'browser/metrics/metrics_service.cc', - 'browser/metrics/metrics_service.h', 'browser/metrics/metrics_service_accessor.cc', 'browser/metrics/metrics_service_accessor.h', 'browser/metrics/metrics_services_manager.cc', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 6b4df83..edf2729 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1376,29 +1376,6 @@ const char kVariationsSeedHash[] = "variations_seed_hash"; // Digital signature of the binary variations seed data, base64-encoded. const char kVariationsSeedSignature[] = "variations_seed_signature"; -// An enum value to indicate the execution phase the browser was in. -const char kStabilityExecutionPhase[] = - "user_experience_metrics.stability.execution_phase"; - -// True if the previous run of the program exited cleanly. -const char kStabilityExitedCleanly[] = - "user_experience_metrics.stability.exited_cleanly"; - -// Version string of previous run, which is used to assure that stability -// metrics reported under current version reflect stability of the same version. -const char kStabilityStatsVersion[] = - "user_experience_metrics.stability.stats_version"; - -// Build time, in seconds since an epoch, which is used to assure that stability -// metrics reported reflect stability of the same build. -const char kStabilityStatsBuildTime[] = - "user_experience_metrics.stability.stats_buildtime"; - -// False if we received a session end and either we crashed during processing -// the session end or ran out of time and windows terminated us. -const char kStabilitySessionEndCompleted[] = - "user_experience_metrics.stability.session_end_completed"; - // Number of times a page load event occurred since the last report. const char kStabilityPageLoadCount[] = "user_experience_metrics.stability.page_load_count"; @@ -1411,15 +1388,6 @@ const char kStabilityRendererCrashCount[] = const char kStabilityExtensionRendererCrashCount[] = "user_experience_metrics.stability.extension_renderer_crash_count"; -// Time when the app was last launched, in seconds since the epoch. -const char kStabilityLaunchTimeSec[] = - "user_experience_metrics.stability.launch_time_sec"; - -// Time when the app was last known to be running, in seconds since -// the epoch. -const char kStabilityLastTimestampSec[] = - "user_experience_metrics.stability.last_timestamp_sec"; - // This is the location of a list of dictionaries of plugin stability stats. const char kStabilityPluginStats[] = "user_experience_metrics.stability.plugin_stats2"; @@ -1487,8 +1455,6 @@ const char kStabilityPluginLoadingErrors[] = "loading_errors"; const char kInstallDate[] = "uninstall_metrics.installation_date2"; const char kUninstallMetricsPageLoadCount[] = "uninstall_metrics.page_load_count"; -const char kUninstallLaunchCount[] = "uninstall_metrics.launch_count"; -const char kUninstallMetricsUptimeSec[] = "uninstall_metrics.uptime_sec"; const char kUninstallLastLaunchTimeSec[] = "uninstall_metrics.last_launch_time_sec"; const char kUninstallLastObservedRunTimeSec[] = diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index f672cee..a44fdbf 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -451,16 +451,9 @@ extern const char kProfilesNumCreated[]; extern const char kProfileInfoCache[]; extern const char kProfileCreatedByVersion[]; -extern const char kStabilityExecutionPhase[]; -extern const char kStabilityExitedCleanly[]; -extern const char kStabilityStatsVersion[]; -extern const char kStabilityStatsBuildTime[]; -extern const char kStabilitySessionEndCompleted[]; extern const char kStabilityPageLoadCount[]; extern const char kStabilityRendererCrashCount[]; extern const char kStabilityExtensionRendererCrashCount[]; -extern const char kStabilityLaunchTimeSec[]; -extern const char kStabilityLastTimestampSec[]; extern const char kStabilityRendererHangCount[]; extern const char kStabilityChildProcessCrashCount[]; extern const char kStabilityOtherUserCrashCount[]; @@ -482,8 +475,6 @@ extern const char kStabilityPluginLoadingErrors[]; extern const char kInstallDate[]; extern const char kUninstallMetricsPageLoadCount[]; -extern const char kUninstallLaunchCount[]; -extern const char kUninstallMetricsUptimeSec[]; extern const char kUninstallLastLaunchTimeSec[]; extern const char kUninstallLastObservedRunTimeSec[]; diff --git a/components/metrics.gypi b/components/metrics.gypi index 0a48dac..24fd27c 100644 --- a/components/metrics.gypi +++ b/components/metrics.gypi @@ -34,6 +34,8 @@ 'metrics/metrics_pref_names.h', 'metrics/metrics_reporting_scheduler.cc', 'metrics/metrics_reporting_scheduler.h', + 'metrics/metrics_service.cc', + 'metrics/metrics_service.h', 'metrics/metrics_service_client.h', 'metrics/metrics_service_observer.cc', 'metrics/metrics_service_observer.h', diff --git a/components/metrics/metrics_pref_names.cc b/components/metrics/metrics_pref_names.cc index 68b5f72..ed437a0 100644 --- a/components/metrics/metrics_pref_names.cc +++ b/components/metrics/metrics_pref_names.cc @@ -75,14 +75,31 @@ const char kStabilityDebuggerPresent[] = const char kStabilityDebuggerNotPresent[] = "user_experience_metrics.stability.debugger_not_present"; +// An enum value to indicate the execution phase the browser was in. +const char kStabilityExecutionPhase[] = + "user_experience_metrics.stability.execution_phase"; + +// True if the previous run of the program exited cleanly. +const char kStabilityExitedCleanly[] = + "user_experience_metrics.stability.exited_cleanly"; + // Number of times the session end did not complete. const char kStabilityIncompleteSessionEndCount[] = "user_experience_metrics.stability.incomplete_session_end_count"; +// Time when the app was last known to be running, in seconds since +// the epoch. +const char kStabilityLastTimestampSec[] = + "user_experience_metrics.stability.last_timestamp_sec"; + // Number of times the application was launched since last report. const char kStabilityLaunchCount[] = "user_experience_metrics.stability.launch_count"; +// Time when the app was last launched, in seconds since the epoch. +const char kStabilityLaunchTimeSec[] = + "user_experience_metrics.stability.launch_time_sec"; + // Base64 encoded serialized UMA system profile proto from the previous session. const char kStabilitySavedSystemProfile[] = "user_experience_metrics.stability.saved_system_profile"; @@ -91,5 +108,26 @@ const char kStabilitySavedSystemProfile[] = const char kStabilitySavedSystemProfileHash[] = "user_experience_metrics.stability.saved_system_profile_hash"; +// False if we received a session end and either we crashed during processing +// the session end or ran out of time and windows terminated us. +const char kStabilitySessionEndCompleted[] = + "user_experience_metrics.stability.session_end_completed"; + +// Build time, in seconds since an epoch, which is used to assure that stability +// metrics reported reflect stability of the same build. +const char kStabilityStatsBuildTime[] = + "user_experience_metrics.stability.stats_buildtime"; + +// Version string of previous run, which is used to assure that stability +// metrics reported under current version reflect stability of the same version. +const char kStabilityStatsVersion[] = + "user_experience_metrics.stability.stats_version"; + +// The keys below are strictly increasing counters over the lifetime of +// a chrome installation. They are (optionally) sent up to the uninstall +// survey in the event of uninstallation. +const char kUninstallLaunchCount[] = "uninstall_metrics.launch_count"; +const char kUninstallMetricsUptimeSec[] = "uninstall_metrics.uptime_sec"; + } // namespace prefs } // namespace metrics diff --git a/components/metrics/metrics_pref_names.h b/components/metrics/metrics_pref_names.h index b52365d..1862721 100644 --- a/components/metrics/metrics_pref_names.h +++ b/components/metrics/metrics_pref_names.h @@ -25,11 +25,19 @@ extern const char kStabilityBreakpadRegistrationFail[]; extern const char kStabilityCrashCount[]; extern const char kStabilityDebuggerPresent[]; extern const char kStabilityDebuggerNotPresent[]; +extern const char kStabilityExecutionPhase[]; +extern const char kStabilityExitedCleanly[]; extern const char kStabilityIncompleteSessionEndCount[]; +extern const char kStabilityLastTimestampSec[]; extern const char kStabilityLaunchCount[]; +extern const char kStabilityLaunchTimeSec[]; extern const char kStabilitySavedSystemProfile[]; extern const char kStabilitySavedSystemProfileHash[]; - +extern const char kStabilitySessionEndCompleted[]; +extern const char kStabilityStatsBuildTime[]; +extern const char kStabilityStatsVersion[]; +extern const char kUninstallLaunchCount[]; +extern const char kUninstallMetricsUptimeSec[]; } // namespace prefs } // namespace metrics diff --git a/chrome/browser/metrics/metrics_service.cc b/components/metrics/metrics_service.cc index ac4127b..ca57925 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/components/metrics/metrics_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -161,7 +161,7 @@ // //------------------------------------------------------------------------------ -#include "chrome/browser/metrics/metrics_service.h" +#include "components/metrics/metrics_service.h" #include <algorithm> @@ -181,7 +181,6 @@ #include "base/threading/thread_restrictions.h" #include "base/tracked_objects.h" #include "base/values.h" -#include "chrome/common/pref_names.h" #include "components/metrics/metrics_log.h" #include "components/metrics/metrics_log_manager.h" #include "components/metrics/metrics_log_uploader.h" @@ -190,7 +189,6 @@ #include "components/metrics/metrics_service_client.h" #include "components/metrics/metrics_state_manager.h" #include "components/variations/entropy_provider.h" -#include "content/public/browser/browser_thread.h" using base::Time; using metrics::MetricsLogManager; @@ -257,8 +255,8 @@ ResponseStatus ResponseCodeToStatus(int response_code) { } void MarkAppCleanShutdownAndCommit(PrefService* local_state) { - local_state->SetBoolean(prefs::kStabilityExitedCleanly, true); - local_state->SetInteger(prefs::kStabilityExecutionPhase, + local_state->SetBoolean(metrics::prefs::kStabilityExitedCleanly, true); + local_state->SetInteger(metrics::prefs::kStabilityExecutionPhase, MetricsService::SHUTDOWN_COMPLETE); // Start writing right away (write happens on a different thread). local_state->CommitPendingWrite(); @@ -288,24 +286,23 @@ void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { metrics::MetricsStateManager::RegisterPrefs(registry); MetricsLog::RegisterPrefs(registry); - registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); - registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); - registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); - registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); - registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); - registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase, + registry->RegisterInt64Pref(metrics::prefs::kStabilityLaunchTimeSec, 0); + registry->RegisterInt64Pref(metrics::prefs::kStabilityLastTimestampSec, 0); + registry->RegisterStringPref(metrics::prefs::kStabilityStatsVersion, + std::string()); + registry->RegisterInt64Pref(metrics::prefs::kStabilityStatsBuildTime, 0); + registry->RegisterBooleanPref(metrics::prefs::kStabilityExitedCleanly, true); + registry->RegisterIntegerPref(metrics::prefs::kStabilityExecutionPhase, UNINITIALIZED_PHASE); - registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); + registry->RegisterBooleanPref(metrics::prefs::kStabilitySessionEndCompleted, + true); registry->RegisterIntegerPref(metrics::prefs::kMetricsSessionID, -1); registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs); registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs); - registry->RegisterInt64Pref(prefs::kInstallDate, 0); - registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); - registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); - registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); - registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); + registry->RegisterInt64Pref(metrics::prefs::kUninstallLaunchCount, 0); + registry->RegisterInt64Pref(metrics::prefs::kUninstallMetricsUptimeSec, 0); } MetricsService::MetricsService(metrics::MetricsStateManager* state_manager, @@ -477,12 +474,12 @@ void MetricsService::OnApplicationNotIdle() { void MetricsService::RecordStartOfSessionEnd() { LogCleanShutdown(); - RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, false); + RecordBooleanPrefValue(metrics::prefs::kStabilitySessionEndCompleted, false); } void MetricsService::RecordCompletedSessionEnd() { LogCleanShutdown(); - RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, true); + RecordBooleanPrefValue(metrics::prefs::kStabilitySessionEndCompleted, true); } #if defined(OS_ANDROID) || defined(OS_IOS) @@ -505,12 +502,12 @@ void MetricsService::OnAppEnterBackground() { } void MetricsService::OnAppEnterForeground() { - local_state_->SetBoolean(prefs::kStabilityExitedCleanly, false); + local_state_->SetBoolean(metrics::prefs::kStabilityExitedCleanly, false); StartSchedulerIfNecessary(); } #else void MetricsService::LogNeedForCleanShutdown(PrefService* local_state) { - local_state->SetBoolean(prefs::kStabilityExitedCleanly, false); + local_state->SetBoolean(metrics::prefs::kStabilityExitedCleanly, false); // Redundant setting to be sure we call for a clean shutdown. clean_shutdown_status_ = NEED_TO_SHUTDOWN; } @@ -520,7 +517,8 @@ void MetricsService::LogNeedForCleanShutdown(PrefService* local_state) { void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase, PrefService* local_state) { execution_phase_ = execution_phase; - local_state->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_); + local_state->SetInteger(metrics::prefs::kStabilityExecutionPhase, + execution_phase_); } void MetricsService::RecordBreakpadRegistration(bool success) { @@ -546,23 +544,23 @@ void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { // Initialization methods void MetricsService::InitializeMetricsState() { - local_state_->SetString(prefs::kStabilityStatsVersion, + local_state_->SetString(metrics::prefs::kStabilityStatsVersion, client_->GetVersionString()); - local_state_->SetInt64(prefs::kStabilityStatsBuildTime, + local_state_->SetInt64(metrics::prefs::kStabilityStatsBuildTime, MetricsLog::GetBuildTime()); session_id_ = local_state_->GetInteger(metrics::prefs::kMetricsSessionID); - if (!local_state_->GetBoolean(prefs::kStabilityExitedCleanly)) { + if (!local_state_->GetBoolean(metrics::prefs::kStabilityExitedCleanly)) { IncrementPrefValue(metrics::prefs::kStabilityCrashCount); // Reset flag, and wait until we call LogNeedForCleanShutdown() before // monitoring. - local_state_->SetBoolean(prefs::kStabilityExitedCleanly, true); + local_state_->SetBoolean(metrics::prefs::kStabilityExitedCleanly, true); // TODO(rtenneti): On windows, consider saving/getting execution_phase from // the registry. int execution_phase = - local_state_->GetInteger(prefs::kStabilityExecutionPhase); + local_state_->GetInteger(metrics::prefs::kStabilityExecutionPhase); UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", execution_phase); @@ -582,10 +580,12 @@ void MetricsService::InitializeMetricsState() { DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); SetExecutionPhase(START_METRICS_RECORDING, local_state_); - if (!local_state_->GetBoolean(prefs::kStabilitySessionEndCompleted)) { + if (!local_state_->GetBoolean( + metrics::prefs::kStabilitySessionEndCompleted)) { IncrementPrefValue(metrics::prefs::kStabilityIncompleteSessionEndCount); // This is marked false when we get a WM_ENDSESSION. - local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true); + local_state_->SetBoolean(metrics::prefs::kStabilitySessionEndCompleted, + true); } // Call GetUptimes() for the first time, thus allowing all later calls @@ -595,12 +595,13 @@ void MetricsService::InitializeMetricsState() { GetUptimes(local_state_, &startup_uptime, &ignored_uptime_parameter); DCHECK_EQ(0, startup_uptime.InMicroseconds()); // For backwards compatibility, leave this intact in case Omaha is checking - // them. prefs::kStabilityLastTimestampSec may also be useless now. + // them. metrics::prefs::kStabilityLastTimestampSec may also be useless now. // TODO(jar): Delete these if they have no uses. - local_state_->SetInt64(prefs::kStabilityLaunchTimeSec, Time::Now().ToTimeT()); + local_state_->SetInt64(metrics::prefs::kStabilityLaunchTimeSec, + Time::Now().ToTimeT()); // Bookkeeping for the uninstall metrics. - IncrementLongPrefsValue(prefs::kUninstallLaunchCount); + IncrementLongPrefsValue(metrics::prefs::kUninstallLaunchCount); // Kick off the process of saving the state (so the uptime numbers keep // getting updated) every n minutes. @@ -644,9 +645,10 @@ void MetricsService::GetUptimes(PrefService* pref, const int64 incremental_time_secs = incremental_uptime->InSeconds(); if (incremental_time_secs > 0) { - int64 metrics_uptime = pref->GetInt64(prefs::kUninstallMetricsUptimeSec); + int64 metrics_uptime = + pref->GetInt64(metrics::prefs::kUninstallMetricsUptimeSec); metrics_uptime += incremental_time_secs; - pref->SetInt64(prefs::kUninstallMetricsUptimeSec, metrics_uptime); + pref->SetInt64(metrics::prefs::kUninstallMetricsUptimeSec, metrics_uptime); } } @@ -700,8 +702,7 @@ void MetricsService::OpenNewLog() { // We only need to schedule that run once. state_ = INIT_TASK_SCHEDULED; - content::BrowserThread::PostDelayedTask( - content::BrowserThread::UI, + base::MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&MetricsService::StartGatheringMetrics, self_ptr_factory_.GetWeakPtr()), @@ -1176,8 +1177,8 @@ void MetricsService::LogCleanShutdown() { // (and that we don't use some alternate path, and not call LogCleanShutdown). clean_shutdown_status_ = CLEANLY_SHUTDOWN; - RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); - local_state_->SetInteger(prefs::kStabilityExecutionPhase, + RecordBooleanPrefValue(metrics::prefs::kStabilityExitedCleanly, true); + local_state_->SetInteger(metrics::prefs::kStabilityExecutionPhase, MetricsService::SHUTDOWN_COMPLETE); } @@ -1195,7 +1196,8 @@ void MetricsService::RecordBooleanPrefValue(const char* path, bool value) { } void MetricsService::RecordCurrentState(PrefService* pref) { - pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); + pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, + Time::Now().ToTimeT()); for (size_t i = 0; i < metrics_providers_.size(); ++i) metrics_providers_[i]->RecordCurrentState(); diff --git a/chrome/browser/metrics/metrics_service.h b/components/metrics/metrics_service.h index e20c23f..b586263 100644 --- a/chrome/browser/metrics/metrics_service.h +++ b/components/metrics/metrics_service.h @@ -1,12 +1,12 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file defines a service that collects information about the user // experience in order to help improve future versions of the app. -#ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ -#define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ +#ifndef COMPONENTS_METRICS_METRICS_SERVICE_H_ +#define COMPONENTS_METRICS_METRICS_SERVICE_H_ #include <map> #include <string> @@ -46,9 +46,6 @@ namespace variations { struct ActiveGroupId; } -namespace content { -} - namespace metrics { class MetricsLogUploader; class MetricsServiceClient; @@ -59,10 +56,6 @@ namespace net { class URLFetcher; } -namespace tracked_objects { -struct ProcessDataSnapshot; -} - // A Field Trial and its selected group, which represent a particular // Chrome configuration state. For example, the trial name could map to // a preference name, and the group name could map to a preference value. @@ -472,4 +465,4 @@ class MetricsService : public base::HistogramFlattener { DISALLOW_COPY_AND_ASSIGN(MetricsService); }; -#endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ +#endif // COMPONENTS_METRICS_METRICS_SERVICE_H_ |