Move more metrics classes to metrics namespace.
BUG=374763
[email protected]
Review URL: https://codereview.chromium.org/502173002
Cr-Commit-Position: refs/heads/master@{#291994}
diff --git a/base/threading/thread_restrictions.h b/base/threading/thread_restrictions.h
index 2288049..3c8612d 100644
--- a/base/threading/thread_restrictions.h
+++ b/base/threading/thread_restrictions.h
@@ -18,7 +18,6 @@
class AcceleratedPresenter;
class BrowserProcessImpl;
class HistogramSynchronizer;
-class MetricsService;
class NativeBackendKWallet;
class ScopedAllowWaitForLegacyWebViewApi;
class TestingAutomationProvider;
@@ -61,6 +60,9 @@
namespace media {
class AudioOutputController;
}
+namespace metrics {
+class MetricsService;
+}
namespace mojo {
namespace common {
class WatcherThreadManager;
@@ -223,7 +225,7 @@
friend class net::internal::AddressTrackerLinux; // http://crbug.com/125097
friend class ::AcceleratedPresenter; // http://crbug.com/125391
friend class ::BrowserProcessImpl; // http://crbug.com/125207
- friend class ::MetricsService; // http://crbug.com/124954
+ friend class metrics::MetricsService; // http://crbug.com/124954
friend class ::NativeBackendKWallet; // http://crbug.com/125331
// END USAGE THAT NEEDS TO BE FIXED.
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index fefc63f6..df2ad5ea9 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -28,7 +28,6 @@
class IntranetRedirectDetector;
class IOThread;
class MediaFileSystemRegistry;
-class MetricsService;
class MetricsServicesManager;
class NotificationUIManager;
class PrefRegistrySimple;
@@ -63,6 +62,10 @@
class MessageCenter;
}
+namespace metrics {
+class MetricsService;
+}
+
namespace net {
class URLRequestContextGetter;
}
@@ -115,7 +118,7 @@
virtual MetricsServicesManager* GetMetricsServicesManager() = 0;
// Services: any of these getters may return NULL
- virtual MetricsService* metrics_service() = 0;
+ virtual metrics::MetricsService* metrics_service() = 0;
virtual rappor::RapporService* rappor_service() = 0;
virtual ProfileManager* profile_manager() = 0;
virtual PrefService* local_state() = 0;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index b178721..c1546cb 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -479,7 +479,7 @@
}
// Tell the metrics service it was cleanly shutdown.
- MetricsService* metrics = g_browser_process->metrics_service();
+ metrics::MetricsService* metrics = g_browser_process->metrics_service();
if (metrics && local_state()) {
metrics->RecordStartOfSessionEnd();
#if !defined(OS_CHROMEOS)
@@ -535,7 +535,7 @@
return metrics_services_manager_.get();
}
-MetricsService* BrowserProcessImpl::metrics_service() {
+metrics::MetricsService* BrowserProcessImpl::metrics_service() {
DCHECK(CalledOnValidThread());
return GetMetricsServicesManager()->GetMetricsService();
}
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 6234faf..8fd4ce5 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -23,7 +23,6 @@
class ChromeNetLog;
class ChromeResourceDispatcherHostDelegate;
-class MetricsServicesManager;
class RemoteDebuggingServer;
class PrefRegistrySimple;
class PromoResourceService;
@@ -78,7 +77,7 @@
virtual void ResourceDispatcherHostCreated() OVERRIDE;
virtual void EndSession() OVERRIDE;
virtual MetricsServicesManager* GetMetricsServicesManager() OVERRIDE;
- virtual MetricsService* metrics_service() OVERRIDE;
+ virtual metrics::MetricsService* metrics_service() OVERRIDE;
virtual rappor::RapporService* rappor_service() OVERRIDE;
virtual IOThread* io_thread() OVERRIDE;
virtual WatchDogThread* watchdog_thread() OVERRIDE;
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index fa50225..a07f6910 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -149,7 +149,7 @@
// consider putting it in BrowserProcessImpl::EndSession.
PrefService* prefs = g_browser_process->local_state();
- MetricsService* metrics = g_browser_process->metrics_service();
+ metrics::MetricsService* metrics = g_browser_process->metrics_service();
if (metrics)
metrics->RecordCompletedSessionEnd();
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index a603ffd..1c2ca9a 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -574,7 +574,7 @@
// Initialize FieldTrialList to support FieldTrials that use one-time
// randomization.
- MetricsService* metrics = browser_process_->metrics_service();
+ metrics::MetricsService* metrics = browser_process_->metrics_service();
field_trial_list_.reset(
new base::FieldTrialList(metrics->CreateEntropyProvider().release()));
@@ -631,7 +631,7 @@
void ChromeBrowserMainParts::StartMetricsRecording() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording");
- MetricsService* metrics = g_browser_process->metrics_service();
+ metrics::MetricsService* metrics = g_browser_process->metrics_service();
const bool only_do_metrics_recording =
parsed_command_line_.HasSwitch(switches::kMetricsRecordingOnly) ||
@@ -1236,8 +1236,9 @@
// Profile creation ----------------------------------------------------------
- MetricsService::SetExecutionPhase(MetricsService::CREATE_PROFILE,
- g_browser_process->local_state());
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::CREATE_PROFILE,
+ g_browser_process->local_state());
profile_ = CreatePrimaryProfile(parameters(),
user_data_dir_,
parsed_command_line());
@@ -1408,8 +1409,9 @@
// Start watching for hangs during startup. We disarm this hang detector when
// ThreadWatcher takes over or when browser is shutdown or when
// startup_watcher_ is deleted.
- MetricsService::SetExecutionPhase(MetricsService::STARTUP_TIMEBOMB_ARM,
- g_browser_process->local_state());
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::STARTUP_TIMEBOMB_ARM,
+ g_browser_process->local_state());
startup_watcher_->Arm(base::TimeDelta::FromSeconds(300));
// On mobile, need for clean shutdown arises only when the application comes
@@ -1417,7 +1419,8 @@
// http://crbug.com/179143
#if !defined(OS_ANDROID)
// Start watching for a hang.
- MetricsService::LogNeedForCleanShutdown(g_browser_process->local_state());
+ metrics::MetricsService::LogNeedForCleanShutdown(
+ g_browser_process->local_state());
#endif
#if defined(ENABLE_FULL_PRINTING)
@@ -1431,8 +1434,9 @@
#endif
// Start watching all browser threads for responsiveness.
- MetricsService::SetExecutionPhase(MetricsService::THREAD_WATCHER_START,
- g_browser_process->local_state());
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::THREAD_WATCHER_START,
+ g_browser_process->local_state());
ThreadWatcherList::StartWatchingAll(parsed_command_line());
#if defined(OS_ANDROID)
@@ -1594,8 +1598,9 @@
performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle();
- MetricsService::SetExecutionPhase(MetricsService::MAIN_MESSAGE_LOOP_RUN,
- g_browser_process->local_state());
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN,
+ g_browser_process->local_state());
run_loop.Run();
return true;
@@ -1612,8 +1617,9 @@
// Start watching for jank during shutdown. It gets disarmed when
// |shutdown_watcher_| object is destructed.
- MetricsService::SetExecutionPhase(MetricsService::SHUTDOWN_TIMEBOMB_ARM,
- g_browser_process->local_state());
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::SHUTDOWN_TIMEBOMB_ARM,
+ g_browser_process->local_state());
shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300));
// Disarm the startup hang detector time bomb if it is still Arm'ed.
@@ -1659,7 +1665,7 @@
// a higher level on the stack, so that it is impossible for an early return
// to bypass this code. Perhaps we need a *final* hook that is called on all
// paths from content/browser/browser_main.
- CHECK(MetricsService::UmaMetricsProperlyShutdown());
+ CHECK(metrics::MetricsService::UmaMetricsProperlyShutdown());
#if defined(OS_CHROMEOS)
chromeos::CrosSettings::Shutdown();
diff --git a/chrome/browser/chrome_browser_metrics_service_observer.h b/chrome/browser/chrome_browser_metrics_service_observer.h
index 111cca7..d8e20da0 100644
--- a/chrome/browser/chrome_browser_metrics_service_observer.h
+++ b/chrome/browser/chrome_browser_metrics_service_observer.h
@@ -9,7 +9,8 @@
// ChromeBrowserMetricsServiceObserver receives notifications when the metrics
// service creates a new metrics log.
-class ChromeBrowserMetricsServiceObserver : public MetricsServiceObserver {
+class ChromeBrowserMetricsServiceObserver
+ : public metrics::MetricsServiceObserver {
public:
ChromeBrowserMetricsServiceObserver();
virtual ~ChromeBrowserMetricsServiceObserver();
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc
index b8d0ac4..173f622 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.cc
+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc
@@ -156,7 +156,7 @@
registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0);
registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0);
- MetricsService::RegisterPrefs(registry);
+ metrics::MetricsService::RegisterPrefs(registry);
ChromeStabilityMetricsProvider::RegisterPrefs(registry);
#if defined(OS_ANDROID)
@@ -280,7 +280,7 @@
}
void ChromeMetricsServiceClient::Initialize() {
- metrics_service_.reset(new MetricsService(
+ metrics_service_.reset(new metrics::MetricsService(
metrics_state_manager_, this, g_browser_process->local_state()));
// Register metrics providers.
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.h b/chrome/browser/metrics/chrome_metrics_service_client.h
index bc3c14a..e98b3133 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.h
+++ b/chrome/browser/metrics/chrome_metrics_service_client.h
@@ -21,7 +21,6 @@
class ChromeOSMetricsProvider;
class GoogleUpdateMetricsProviderWin;
-class MetricsService;
class PluginMetricsProvider;
class PrefRegistrySimple;
class ProfilerMetricsProvider;
@@ -35,6 +34,7 @@
}
namespace metrics {
+class MetricsService;
class MetricsStateManager;
}
@@ -72,7 +72,7 @@
const std::string& mime_type,
const base::Callback<void(int)>& on_upload_complete) OVERRIDE;
- MetricsService* metrics_service() { return metrics_service_.get(); }
+ metrics::MetricsService* metrics_service() { return metrics_service_.get(); }
void LogPluginLoadingError(const base::FilePath& plugin_path);
@@ -131,7 +131,7 @@
metrics::MetricsStateManager* metrics_state_manager_;
// The MetricsService that |this| is a client of.
- scoped_ptr<MetricsService> metrics_service_;
+ scoped_ptr<metrics::MetricsService> metrics_service_;
content::NotificationRegistrar registrar_;
diff --git a/chrome/browser/metrics/extensions_metrics_provider.cc b/chrome/browser/metrics/extensions_metrics_provider.cc
index 41f1359..62b4b9a3 100644
--- a/chrome/browser/metrics/extensions_metrics_provider.cc
+++ b/chrome/browser/metrics/extensions_metrics_provider.cc
@@ -4,7 +4,9 @@
#include "chrome/browser/metrics/extensions_metrics_provider.h"
+#include <algorithm>
#include <set>
+#include <vector>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -167,7 +169,7 @@
// TODO(blundell): Create a MetricsLog::ClientIDAsInt() API and call it
// here as well as in MetricsLog's population of the client_id field of
// the uma_proto.
- return MetricsLog::Hash(metrics_state_manager_->client_id());
+ return metrics::MetricsLog::Hash(metrics_state_manager_->client_id());
}
void ExtensionsMetricsProvider::ProvideSystemProfileMetrics(
diff --git a/chrome/browser/metrics/extensions_metrics_provider_unittest.cc b/chrome/browser/metrics/extensions_metrics_provider_unittest.cc
index 451facd..d73fccfc 100644
--- a/chrome/browser/metrics/extensions_metrics_provider_unittest.cc
+++ b/chrome/browser/metrics/extensions_metrics_provider_unittest.cc
@@ -103,7 +103,7 @@
TEST(ExtensionsMetricsProvider, SystemProtoEncoding) {
metrics::SystemProfileProto system_profile;
TestingPrefServiceSimple local_state;
- MetricsService::RegisterPrefs(local_state.registry());
+ metrics::MetricsService::RegisterPrefs(local_state.registry());
scoped_ptr<metrics::MetricsStateManager> metrics_state_manager(
metrics::MetricsStateManager::Create(
&local_state,
diff --git a/chrome/browser/metrics/metrics_reporting_state.cc b/chrome/browser/metrics/metrics_reporting_state.cc
index a3a6bec..6c72ba6 100644
--- a/chrome/browser/metrics/metrics_reporting_state.cc
+++ b/chrome/browser/metrics/metrics_reporting_state.cc
@@ -24,7 +24,7 @@
// succeeds.
enabled = update_pref;
- MetricsService* metrics = g_browser_process->metrics_service();
+ metrics::MetricsService* metrics = g_browser_process->metrics_service();
if (metrics) {
if (enabled)
metrics->Start();
diff --git a/chrome/browser/metrics/metrics_service_accessor.cc b/chrome/browser/metrics/metrics_service_accessor.cc
index ec83ff3..94c0e88 100644
--- a/chrome/browser/metrics/metrics_service_accessor.cc
+++ b/chrome/browser/metrics/metrics_service_accessor.cc
@@ -8,6 +8,11 @@
#include "components/metrics/metrics_service.h"
#include "components/metrics/metrics_service_observer.h"
+// TODO(asvitkine): Remove when this class is moved to metrics namespace.
+using metrics::MetricsService;
+using metrics::MetricsServiceObserver;
+using metrics::SyntheticTrialGroup;
+
// static
void MetricsServiceAccessor::AddMetricsServiceObserver(
MetricsServiceObserver* observer) {
diff --git a/chrome/browser/metrics/metrics_service_accessor.h b/chrome/browser/metrics/metrics_service_accessor.h
index 7883f73..df2f3e0f 100644
--- a/chrome/browser/metrics/metrics_service_accessor.h
+++ b/chrome/browser/metrics/metrics_service_accessor.h
@@ -10,30 +10,35 @@
#include "base/macros.h"
+namespace metrics {
class MetricsService;
class MetricsServiceObserver;
+}
// This class limits and documents access to metrics service helper methods.
// These methods are protected so each user has to inherit own program-specific
// specialization and enable access there by declaring friends.
class MetricsServiceAccessor {
protected:
- // Constructor declared as protected to enable inheritance. Decendants should
+ // Constructor declared as protected to enable inheritance. Descendants should
// disallow instantiation.
MetricsServiceAccessor() {}
// Registers/unregisters |observer| to receive MetricsLog notifications
// from metrics service.
- static void AddMetricsServiceObserver(MetricsServiceObserver* observer);
- static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer);
+ static void AddMetricsServiceObserver(
+ metrics::MetricsServiceObserver* observer);
+ static void RemoveMetricsServiceObserver(
+ metrics::MetricsServiceObserver* observer);
// Registers the specified synthetic field trial (identified by a hash of the
// trial name and group name) with |metrics_service|, if the service is not
// NULL, returning true on success.
// See the comment on MetricsService::RegisterSyntheticFieldTrial for details.
- static bool RegisterSyntheticFieldTrial(MetricsService* metrics_service,
- uint32_t trial_name_hash,
- uint32_t group_name_hash);
+ static bool RegisterSyntheticFieldTrial(
+ metrics::MetricsService* metrics_service,
+ uint32_t trial_name_hash,
+ uint32_t group_name_hash);
private:
DISALLOW_COPY_AND_ASSIGN(MetricsServiceAccessor);
diff --git a/chrome/browser/metrics/metrics_services_manager.cc b/chrome/browser/metrics/metrics_services_manager.cc
index 74d37107..186bfde7 100644
--- a/chrome/browser/metrics/metrics_services_manager.cc
+++ b/chrome/browser/metrics/metrics_services_manager.cc
@@ -30,7 +30,7 @@
MetricsServicesManager::~MetricsServicesManager() {
}
-MetricsService* MetricsServicesManager::GetMetricsService() {
+metrics::MetricsService* MetricsServicesManager::GetMetricsService() {
DCHECK(thread_checker_.CalledOnValidThread());
return GetChromeMetricsServiceClient()->metrics_service();
}
diff --git a/chrome/browser/metrics/metrics_services_manager.h b/chrome/browser/metrics/metrics_services_manager.h
index 24fc1d5..a2f38ba 100644
--- a/chrome/browser/metrics/metrics_services_manager.h
+++ b/chrome/browser/metrics/metrics_services_manager.h
@@ -10,7 +10,6 @@
#include "base/threading/thread_checker.h"
class ChromeMetricsServiceClient;
-class MetricsService;
class PrefService;
namespace base {
@@ -18,6 +17,7 @@
}
namespace metrics {
+class MetricsService;
class MetricsStateManager;
}
@@ -40,7 +40,7 @@
// Returns the MetricsService, creating it if it hasn't been created yet (and
// additionally creating the ChromeMetricsServiceClient in that case).
- MetricsService* GetMetricsService();
+ metrics::MetricsService* GetMetricsService();
// Returns the GetRapporService, creating it if it hasn't been created yet.
rappor::RapporService* GetRapporService();
diff --git a/chrome/browser/metrics/omnibox_metrics_provider.cc b/chrome/browser/metrics/omnibox_metrics_provider.cc
index 6b43ea7..b578e80 100644
--- a/chrome/browser/metrics/omnibox_metrics_provider.cc
+++ b/chrome/browser/metrics/omnibox_metrics_provider.cc
@@ -113,7 +113,7 @@
static_cast<int>(Tokenize(log.text, base::kWhitespaceUTF16, &terms));
OmniboxEventProto* omnibox_event = omnibox_events_cache.add_omnibox_event();
- omnibox_event->set_time(MetricsLog::GetCurrentTime());
+ omnibox_event->set_time(metrics::MetricsLog::GetCurrentTime());
if (log.tab_id != -1) {
// If we know what tab the autocomplete URL was opened in, log it.
omnibox_event->set_tab_id(log.tab_id);
diff --git a/chrome/browser/metrics/profiler_metrics_provider.cc b/chrome/browser/metrics/profiler_metrics_provider.cc
index a843a4d4..4ba80a0 100644
--- a/chrome/browser/metrics/profiler_metrics_provider.cc
+++ b/chrome/browser/metrics/profiler_metrics_provider.cc
@@ -86,13 +86,14 @@
ProfilerEventProto::TrackedObject* tracked_object =
performance_profile->add_tracked_object();
tracked_object->set_birth_thread_name_hash(
- MetricsLog::Hash(MapThreadName(it->birth.thread_name)));
+ metrics::MetricsLog::Hash(MapThreadName(it->birth.thread_name)));
tracked_object->set_exec_thread_name_hash(
- MetricsLog::Hash(MapThreadName(it->death_thread_name)));
+ metrics::MetricsLog::Hash(MapThreadName(it->death_thread_name)));
tracked_object->set_source_file_name_hash(
- MetricsLog::Hash(NormalizeFileName(it->birth.location.file_name)));
+ metrics::MetricsLog::Hash(NormalizeFileName(
+ it->birth.location.file_name)));
tracked_object->set_source_function_name_hash(
- MetricsLog::Hash(it->birth.location.function_name));
+ metrics::MetricsLog::Hash(it->birth.location.function_name));
tracked_object->set_source_line_number(it->birth.location.line_number);
tracked_object->set_exec_count(death_data.count);
tracked_object->set_exec_time_total(death_data.run_duration_sum);
diff --git a/chrome/browser/safe_browsing/ui_manager.cc b/chrome/browser/safe_browsing/ui_manager.cc
index 1f6a7cd..2c58e798 100644
--- a/chrome/browser/safe_browsing/ui_manager.cc
+++ b/chrome/browser/safe_browsing/ui_manager.cc
@@ -69,7 +69,7 @@
// Only report SafeBrowsing related stats when UMA is enabled. User must also
// ensure that safe browsing is enabled from the calling profile.
bool SafeBrowsingUIManager::CanReportStats() const {
- const MetricsService* metrics = g_browser_process->metrics_service();
+ const metrics::MetricsService* metrics = g_browser_process->metrics_service();
return metrics && metrics->reporting_active();
}
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index f7042801..598f693 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -104,7 +104,7 @@
return NULL;
}
-MetricsService* TestingBrowserProcess::metrics_service() {
+metrics::MetricsService* TestingBrowserProcess::metrics_service() {
return NULL;
}
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index b12410a2..54323e0 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -61,7 +61,7 @@
virtual void ResourceDispatcherHostCreated() OVERRIDE;
virtual void EndSession() OVERRIDE;
virtual MetricsServicesManager* GetMetricsServicesManager() OVERRIDE;
- virtual MetricsService* metrics_service() OVERRIDE;
+ virtual metrics::MetricsService* metrics_service() OVERRIDE;
virtual rappor::RapporService* rappor_service() OVERRIDE;
virtual IOThread* io_thread() OVERRIDE;
virtual WatchDogThread* watchdog_thread() OVERRIDE;
diff --git a/components/metrics/metrics_log.cc b/components/metrics/metrics_log.cc
index 6076f88..314200d 100644
--- a/components/metrics/metrics_log.cc
+++ b/components/metrics/metrics_log.cc
@@ -43,12 +43,10 @@
#endif
using base::SampleCountIterator;
-using metrics::HistogramEventProto;
-using metrics::ProfilerEventProto;
-using metrics::SystemProfileProto;
-using metrics::UserActionEventProto;
typedef variations::ActiveGroupId ActiveGroupId;
+namespace metrics {
+
namespace {
// Any id less than 16 bytes is considered to be a testing id.
@@ -435,3 +433,5 @@
DCHECK(closed_);
uma_proto_.SerializeToString(encoded_log);
}
+
+} // namespace metrics
diff --git a/components/metrics/metrics_log.h b/components/metrics/metrics_log.h
index 2d0519e9..53b30e6 100644
--- a/components/metrics/metrics_log.h
+++ b/components/metrics/metrics_log.h
@@ -27,11 +27,6 @@
struct WebPluginInfo;
}
-namespace metrics {
-class MetricsProvider;
-class MetricsServiceClient;
-}
-
namespace tracked_objects {
struct ProcessDataSnapshot;
}
@@ -40,6 +35,11 @@
struct ActiveGroupId;
}
+namespace metrics {
+
+class MetricsProvider;
+class MetricsServiceClient;
+
class MetricsLog {
public:
enum LogType {
@@ -58,7 +58,7 @@
MetricsLog(const std::string& client_id,
int session_id,
LogType log_type,
- metrics::MetricsServiceClient* client,
+ MetricsServiceClient* client,
PrefService* local_state);
virtual ~MetricsLog();
@@ -95,7 +95,7 @@
// example, a pref may be mapped to a synthetic trial such that the group
// is determined by the pref value.
void RecordEnvironment(
- const std::vector<metrics::MetricsProvider*>& metrics_providers,
+ const std::vector<MetricsProvider*>& metrics_providers,
const std::vector<variations::ActiveGroupId>& synthetic_trials,
int64 install_date);
@@ -114,13 +114,13 @@
// as number of incomplete shutdowns as well as extra breakpad and debugger
// stats.
void RecordStabilityMetrics(
- const std::vector<metrics::MetricsProvider*>& metrics_providers,
+ const std::vector<MetricsProvider*>& metrics_providers,
base::TimeDelta incremental_uptime,
base::TimeDelta uptime);
// Records general metrics based on the specified |metrics_providers|.
void RecordGeneralMetrics(
- const std::vector<metrics::MetricsProvider*>& metrics_providers);
+ const std::vector<MetricsProvider*>& metrics_providers);
// Stop writing to this record and generate the encoded representation.
// None of the Record* methods can be called after this is called.
@@ -149,8 +149,8 @@
virtual void GetFieldTrialIds(
std::vector<variations::ActiveGroupId>* field_trial_ids) const;
- metrics::ChromeUserMetricsExtension* uma_proto() { return &uma_proto_; }
- const metrics::ChromeUserMetricsExtension* uma_proto() const {
+ ChromeUserMetricsExtension* uma_proto() { return &uma_proto_; }
+ const ChromeUserMetricsExtension* uma_proto() const {
return &uma_proto_;
}
@@ -182,11 +182,11 @@
const LogType log_type_;
// Stores the protocol buffer representation for this log.
- metrics::ChromeUserMetricsExtension uma_proto_;
+ ChromeUserMetricsExtension uma_proto_;
// Used to interact with the embedder. Weak pointer; must outlive |this|
// instance.
- metrics::MetricsServiceClient* const client_;
+ MetricsServiceClient* const client_;
// The time when the current log was created.
const base::TimeTicks creation_time_;
@@ -196,4 +196,6 @@
DISALLOW_COPY_AND_ASSIGN(MetricsLog);
};
+} // namespace metrics
+
#endif // COMPONENTS_METRICS_METRICS_LOG_H_
diff --git a/components/metrics/metrics_reporting_scheduler.cc b/components/metrics/metrics_reporting_scheduler.cc
index 4b67271b2..614ac21 100644
--- a/components/metrics/metrics_reporting_scheduler.cc
+++ b/components/metrics/metrics_reporting_scheduler.cc
@@ -9,6 +9,8 @@
using base::TimeDelta;
+namespace metrics {
+
namespace {
// The delay, in seconds, after startup before sending the first log message.
@@ -158,3 +160,5 @@
upload_interval_ = max_interval;
}
}
+
+} // namespace metrics
diff --git a/components/metrics/metrics_reporting_scheduler.h b/components/metrics/metrics_reporting_scheduler.h
index 7cdfad82..3e58aaa 100644
--- a/components/metrics/metrics_reporting_scheduler.h
+++ b/components/metrics/metrics_reporting_scheduler.h
@@ -11,6 +11,8 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
+namespace metrics {
+
// Scheduler task to drive a MetricsService object's uploading.
class MetricsReportingScheduler {
public:
@@ -75,4 +77,6 @@
DISALLOW_COPY_AND_ASSIGN(MetricsReportingScheduler);
};
+} // namespace metrics
+
#endif // COMPONENTS_METRICS_METRICS_REPORTING_SCHEDULER_H_
diff --git a/components/metrics/metrics_reporting_scheduler_unittest.cc b/components/metrics/metrics_reporting_scheduler_unittest.cc
index f7a3d081..2a13c1b 100644
--- a/components/metrics/metrics_reporting_scheduler_unittest.cc
+++ b/components/metrics/metrics_reporting_scheduler_unittest.cc
@@ -10,6 +10,8 @@
#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace metrics {
+
class MetricsReportingSchedulerTest : public testing::Test {
public:
MetricsReportingSchedulerTest() : callback_call_count_(0) {}
@@ -56,3 +58,5 @@
scheduler.InitTaskComplete();
EXPECT_EQ(1, callback_call_count());
}
+
+} // namespace metrics
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
index 3c499c1..ca9fef4 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -191,8 +191,7 @@
#include "components/metrics/metrics_state_manager.h"
#include "components/variations/entropy_provider.h"
-using base::Time;
-using metrics::MetricsLogManager;
+namespace metrics {
namespace {
@@ -613,7 +612,7 @@
// them. metrics::prefs::kStabilityLastTimestampSec may also be useless now.
// TODO(jar): Delete these if they have no uses.
local_state_->SetInt64(metrics::prefs::kStabilityLaunchTimeSec,
- Time::Now().ToTimeT());
+ base::Time::Now().ToTimeT());
// Bookkeeping for the uninstall metrics.
IncrementLongPrefsValue(metrics::prefs::kUninstallLaunchCount);
@@ -1190,5 +1189,7 @@
void MetricsService::RecordCurrentState(PrefService* pref) {
pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec,
- Time::Now().ToTimeT());
+ base::Time::Now().ToTimeT());
}
+
+} // namespace metrics
diff --git a/components/metrics/metrics_service.h b/components/metrics/metrics_service.h
index 7a9e08d..3952fb3 100644
--- a/components/metrics/metrics_service.h
+++ b/components/metrics/metrics_service.h
@@ -31,7 +31,7 @@
#include "components/metrics/metrics_service_observer.h"
#include "components/variations/active_field_trials.h"
-class MetricsReportingScheduler;
+class MetricsServiceAccessor;
class PrefService;
class PrefRegistrySimple;
@@ -46,16 +46,17 @@
struct ActiveGroupId;
}
-namespace metrics {
-class MetricsLogUploader;
-class MetricsServiceClient;
-class MetricsStateManager;
-}
-
namespace net {
class URLFetcher;
}
+namespace metrics {
+
+class MetricsLogUploader;
+class MetricsReportingScheduler;
+class MetricsServiceClient;
+class MetricsStateManager;
+
// 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.
@@ -68,7 +69,7 @@
private:
// Synthetic field trial users:
- friend class MetricsServiceAccessor;
+ friend class ::MetricsServiceAccessor;
friend class MetricsService;
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial);
@@ -97,8 +98,8 @@
// |local_state|. Does not take ownership of the paramaters; instead stores
// a weak pointer to each. Caller should ensure that the parameters are valid
// for the lifetime of this class.
- MetricsService(metrics::MetricsStateManager* state_manager,
- metrics::MetricsServiceClient* client,
+ MetricsService(MetricsStateManager* state_manager,
+ MetricsServiceClient* client,
PrefService* local_state);
virtual ~MetricsService();
@@ -215,7 +216,7 @@
// Register the specified |provider| to provide additional metrics into the
// UMA log. Should be called during MetricsService initialization only.
- void RegisterMetricsProvider(scoped_ptr<metrics::MetricsProvider> provider);
+ void RegisterMetricsProvider(scoped_ptr<MetricsProvider> provider);
// Check if this install was cloned or imaged from another machine. If a
// clone is detected, reset the client id and low entropy source. This
@@ -225,7 +226,7 @@
protected:
// Exposed for testing.
- metrics::MetricsLogManager* log_manager() { return &log_manager_; }
+ MetricsLogManager* log_manager() { return &log_manager_; }
private:
// The MetricsService has a lifecycle that is stored as a state.
@@ -373,21 +374,21 @@
void RecordCurrentStabilityHistograms();
// Manager for the various in-flight logs.
- metrics::MetricsLogManager log_manager_;
+ MetricsLogManager log_manager_;
// |histogram_snapshot_manager_| prepares histogram deltas for transmission.
base::HistogramSnapshotManager histogram_snapshot_manager_;
// Used to manage various metrics reporting state prefs, such as client id,
// low entropy source and whether metrics reporting is enabled. Weak pointer.
- metrics::MetricsStateManager* const state_manager_;
+ MetricsStateManager* const state_manager_;
// Used to interact with the embedder. Weak pointer; must outlive |this|
// instance.
- metrics::MetricsServiceClient* const client_;
+ MetricsServiceClient* const client_;
// Registered metrics providers.
- ScopedVector<metrics::MetricsProvider> metrics_providers_;
+ ScopedVector<MetricsProvider> metrics_providers_;
PrefService* local_state_;
@@ -416,7 +417,7 @@
scoped_ptr<MetricsLog> initial_metrics_log_;
// Instance of the helper class for uploading logs.
- scoped_ptr<metrics::MetricsLogUploader> log_uploader_;
+ scoped_ptr<MetricsLogUploader> log_uploader_;
// Whether there is a current log upload in progress.
bool log_upload_in_progress_;
@@ -460,7 +461,7 @@
// Confirms single-threaded access to |observers_| in debug builds.
base::ThreadChecker thread_checker_;
- friend class MetricsServiceAccessor;
+ friend class ::MetricsServiceAccessor;
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess);
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver);
@@ -471,4 +472,6 @@
DISALLOW_COPY_AND_ASSIGN(MetricsService);
};
+} // namespace metrics
+
#endif // COMPONENTS_METRICS_METRICS_SERVICE_H_
diff --git a/components/metrics/metrics_service_observer.cc b/components/metrics/metrics_service_observer.cc
index 576ca3b35..e7116f8 100644
--- a/components/metrics/metrics_service_observer.cc
+++ b/components/metrics/metrics_service_observer.cc
@@ -4,8 +4,12 @@
#include "components/metrics/metrics_service_observer.h"
+namespace metrics {
+
MetricsServiceObserver::MetricsServiceObserver() {
}
MetricsServiceObserver::~MetricsServiceObserver() {
}
+
+} // namespace metrics
diff --git a/components/metrics/metrics_service_observer.h b/components/metrics/metrics_service_observer.h
index 510487e..a0efb84 100644
--- a/components/metrics/metrics_service_observer.h
+++ b/components/metrics/metrics_service_observer.h
@@ -7,6 +7,8 @@
#include "base/macros.h"
+namespace metrics {
+
// MetricsServiceObserver receives notifications from MetricsService.
// An observer must be added, removed, and notified on the same thread.
class MetricsServiceObserver {
@@ -22,4 +24,6 @@
DISALLOW_COPY_AND_ASSIGN(MetricsServiceObserver);
};
+} // namespace metrics
+
#endif // COMPONENTS_METRICS_METRICS_SERVICE_OBSERVER_H_
diff --git a/components/metrics/metrics_service_unittest.cc b/components/metrics/metrics_service_unittest.cc
index c580287..2ee7e1d 100644
--- a/components/metrics/metrics_service_unittest.cc
+++ b/components/metrics/metrics_service_unittest.cc
@@ -21,21 +21,21 @@
#include "components/variations/metrics_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace metrics {
+
namespace {
-using metrics::MetricsLogManager;
-
-void StoreNoClientInfoBackup(const metrics::ClientInfo& /* client_info */) {
+void StoreNoClientInfoBackup(const ClientInfo& /* client_info */) {
}
-scoped_ptr<metrics::ClientInfo> ReturnNoBackup() {
- return scoped_ptr<metrics::ClientInfo>();
+scoped_ptr<ClientInfo> ReturnNoBackup() {
+ return scoped_ptr<ClientInfo>();
}
class TestMetricsService : public MetricsService {
public:
- TestMetricsService(metrics::MetricsStateManager* state_manager,
- metrics::MetricsServiceClient* client,
+ TestMetricsService(MetricsStateManager* state_manager,
+ MetricsServiceClient* client,
PrefService* local_state)
: MetricsService(state_manager, client, local_state) {}
virtual ~TestMetricsService() {}
@@ -50,7 +50,7 @@
public:
TestMetricsLog(const std::string& client_id,
int session_id,
- metrics::MetricsServiceClient* client,
+ MetricsServiceClient* client,
PrefService* local_state)
: MetricsLog(client_id,
session_id,
@@ -68,7 +68,7 @@
public:
MetricsServiceTest() : is_metrics_reporting_enabled_(false) {
MetricsService::RegisterPrefs(testing_local_state_.registry());
- metrics_state_manager_ = metrics::MetricsStateManager::Create(
+ metrics_state_manager_ = MetricsStateManager::Create(
GetLocalState(),
base::Bind(&MetricsServiceTest::is_metrics_reporting_enabled,
base::Unretained(this)),
@@ -81,7 +81,7 @@
GetLocalState());
}
- metrics::MetricsStateManager* GetMetricsStateManager() {
+ MetricsStateManager* GetMetricsStateManager() {
return metrics_state_manager_.get();
}
@@ -106,8 +106,8 @@
const std::vector<variations::ActiveGroupId>& synthetic_trials,
const std::string& trial_name,
const std::string& trial_group) {
- uint32 trial_name_hash = metrics::HashName(trial_name);
- uint32 trial_group_hash = metrics::HashName(trial_group);
+ uint32 trial_name_hash = HashName(trial_name);
+ uint32 trial_group_hash = HashName(trial_group);
for (std::vector<variations::ActiveGroupId>::const_iterator it =
synthetic_trials.begin();
it != synthetic_trials.end(); ++it) {
@@ -124,7 +124,7 @@
bool is_metrics_reporting_enabled_;
TestingPrefServiceSimple testing_local_state_;
- scoped_ptr<metrics::MetricsStateManager> metrics_state_manager_;
+ scoped_ptr<MetricsStateManager> metrics_state_manager_;
base::MessageLoop message_loop;
DISALLOW_COPY_AND_ASSIGN(MetricsServiceTest);
@@ -150,9 +150,9 @@
TEST_F(MetricsServiceTest, InitialStabilityLogAfterCleanShutDown) {
EnableMetricsReporting();
- GetLocalState()->SetBoolean(metrics::prefs::kStabilityExitedCleanly, true);
+ GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, true);
- metrics::TestMetricsServiceClient client;
+ TestMetricsServiceClient client;
TestMetricsService service(
GetMetricsStateManager(), &client, GetLocalState());
service.InitializeMetricsRecordingState();
@@ -163,26 +163,26 @@
TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) {
EnableMetricsReporting();
- GetLocalState()->ClearPref(metrics::prefs::kStabilityExitedCleanly);
+ GetLocalState()->ClearPref(prefs::kStabilityExitedCleanly);
// Set up prefs to simulate restarting after a crash.
// Save an existing system profile to prefs, to correspond to what would be
// saved from a previous session.
- metrics::TestMetricsServiceClient client;
+ TestMetricsServiceClient client;
TestMetricsLog log("client", 1, &client, GetLocalState());
- log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(),
+ log.RecordEnvironment(std::vector<MetricsProvider*>(),
std::vector<variations::ActiveGroupId>(),
0);
// Record stability build time and version from previous session, so that
// stability metrics (including exited cleanly flag) won't be cleared.
- GetLocalState()->SetInt64(metrics::prefs::kStabilityStatsBuildTime,
- MetricsLog::GetBuildTime());
- GetLocalState()->SetString(metrics::prefs::kStabilityStatsVersion,
- client.GetVersionString());
+ GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime,
+ MetricsLog::GetBuildTime());
+ GetLocalState()->SetString(prefs::kStabilityStatsVersion,
+ client.GetVersionString());
- GetLocalState()->SetBoolean(metrics::prefs::kStabilityExitedCleanly, false);
+ GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, false);
TestMetricsService service(
GetMetricsStateManager(), &client, GetLocalState());
@@ -314,3 +314,5 @@
service.RemoveObserver(&observer2);
}
+
+} // namespace metrics