diff options
author | asvitkine <asvitkine@chromium.org> | 2014-10-24 09:19:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-24 16:20:06 +0000 |
commit | a63d19ef4e8e279552b41b5561d3f17b41cbc7ce (patch) | |
tree | 0db2475066ffa38a5fd59a95264e82482e06c9db /components/metrics | |
parent | d3ba46bfe646262a08822ae2456e38080a7023f5 (diff) | |
download | chromium_src-a63d19ef4e8e279552b41b5561d3f17b41cbc7ce.zip chromium_src-a63d19ef4e8e279552b41b5561d3f17b41cbc7ce.tar.gz chromium_src-a63d19ef4e8e279552b41b5561d3f17b41cbc7ce.tar.bz2 |
Make remaining parts of components/metrics use metrics namespace.
Cleans up various unnecessary namespace declarations and also fixes
some lint errors. Code is reformatted using git cl format.
BUG=374763
Review URL: https://codereview.chromium.org/636363004
Cr-Commit-Position: refs/heads/master@{#301118}
Diffstat (limited to 'components/metrics')
15 files changed, 114 insertions, 108 deletions
diff --git a/components/metrics/clean_exit_beacon.cc b/components/metrics/clean_exit_beacon.cc index 595d05c..422a110 100644 --- a/components/metrics/clean_exit_beacon.cc +++ b/components/metrics/clean_exit_beacon.cc @@ -19,8 +19,7 @@ namespace metrics { CleanExitBeacon::CleanExitBeacon(const base::string16& backup_registry_key, PrefService* local_state) : local_state_(local_state), - initial_value_( - local_state->GetBoolean(metrics::prefs::kStabilityExitedCleanly)), + initial_value_(local_state->GetBoolean(prefs::kStabilityExitedCleanly)), backup_registry_key_(backup_registry_key) { DCHECK_NE(PrefService::INITIALIZATION_STATUS_WAITING, local_state_->GetInitializationStatus()); @@ -44,8 +43,8 @@ CleanExitBeacon::CleanExitBeacon(const base::string16& backup_registry_key, backup_registry_key_.c_str(), KEY_ALL_ACCESS) == ERROR_SUCCESS && regkey.ReadValueDW( - base::ASCIIToUTF16(metrics::prefs::kStabilityExitedCleanly).c_str(), - &value) == ERROR_SUCCESS) { + base::ASCIIToUTF16(prefs::kStabilityExitedCleanly).c_str(), &value) == + ERROR_SUCCESS) { if (value) consistency = initial_value_ ? CLEAN_CLEAN : CLEAN_DIRTY; else @@ -63,7 +62,7 @@ CleanExitBeacon::~CleanExitBeacon() { } void CleanExitBeacon::WriteBeaconValue(bool value) { - local_state_->SetBoolean(metrics::prefs::kStabilityExitedCleanly, value); + local_state_->SetBoolean(prefs::kStabilityExitedCleanly, value); #if defined(OS_WIN) base::win::RegKey regkey; @@ -71,7 +70,7 @@ void CleanExitBeacon::WriteBeaconValue(bool value) { backup_registry_key_.c_str(), KEY_ALL_ACCESS) == ERROR_SUCCESS) { regkey.WriteValue( - base::ASCIIToUTF16(metrics::prefs::kStabilityExitedCleanly).c_str(), + base::ASCIIToUTF16(prefs::kStabilityExitedCleanly).c_str(), value ? 1u : 0u); } #endif diff --git a/components/metrics/cloned_install_detector.cc b/components/metrics/cloned_install_detector.cc index b93e6e6..be89bb9 100644 --- a/components/metrics/cloned_install_detector.cc +++ b/components/metrics/cloned_install_detector.cc @@ -4,6 +4,8 @@ #include "components/metrics/cloned_install_detector.h" +#include <string> + #include "base/bind.h" #include "base/location.h" #include "base/metrics/histogram.h" @@ -11,7 +13,6 @@ #include "base/prefs/pref_service.h" #include "base/single_thread_task_runner.h" #include "base/task_runner_util.h" -#include "components/metrics/cloned_install_detector.h" #include "components/metrics/machine_id_provider.h" #include "components/metrics/metrics_hashes.h" #include "components/metrics/metrics_pref_names.h" @@ -21,7 +22,7 @@ namespace metrics { namespace { uint32 HashRawId(const std::string& value) { - uint64 hash = metrics::HashMetricName(value); + uint64 hash = HashMetricName(value); // Only use 24 bits from the 64-bit hash. return hash & ((1 << 24) - 1); @@ -57,8 +58,8 @@ void ClonedInstallDetector::CheckForClonedInstall( base::PostTaskAndReplyWithResult( task_runner.get(), FROM_HERE, - base::Bind(&metrics::MachineIdProvider::GetMachineId, raw_id_provider_), - base::Bind(&metrics::ClonedInstallDetector::SaveMachineId, + base::Bind(&MachineIdProvider::GetMachineId, raw_id_provider_), + base::Bind(&ClonedInstallDetector::SaveMachineId, weak_ptr_factory_.GetWeakPtr(), local_state)); } diff --git a/components/metrics/daily_event_unittest.cc b/components/metrics/daily_event_unittest.cc index d15def1..c600ee9 100644 --- a/components/metrics/daily_event_unittest.cc +++ b/components/metrics/daily_event_unittest.cc @@ -38,8 +38,7 @@ class DailyEventTest : public testing::Test { DailyEventTest() : event_(&prefs_, kTestPrefName, kTestMetricName) { DailyEvent::RegisterPref(prefs_.registry(), kTestPrefName); observer_ = new TestDailyObserver(); - scoped_ptr<metrics::DailyEvent::Observer> p(observer_); - event_.AddObserver(p.Pass()); + event_.AddObserver(make_scoped_ptr(observer_)); } protected: diff --git a/components/metrics/gpu/gpu_metrics_provider_unittest.cc b/components/metrics/gpu/gpu_metrics_provider_unittest.cc index 6624922..64f9579 100644 --- a/components/metrics/gpu/gpu_metrics_provider_unittest.cc +++ b/components/metrics/gpu/gpu_metrics_provider_unittest.cc @@ -50,12 +50,12 @@ class GPUMetricsProviderTest : public testing::Test { TEST_F(GPUMetricsProviderTest, ProvideSystemProfileMetrics) { TestGPUMetricsProvider provider; - metrics::ChromeUserMetricsExtension uma_proto; + ChromeUserMetricsExtension uma_proto; provider.ProvideSystemProfileMetrics(uma_proto.mutable_system_profile()); // Check that the system profile has the correct values set. - const metrics::SystemProfileProto::Hardware& hardware = + const SystemProfileProto::Hardware& hardware = uma_proto.system_profile().hardware(); EXPECT_EQ(kScreenWidth, hardware.primary_screen_width()); EXPECT_EQ(kScreenHeight, hardware.primary_screen_height()); diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc index c8315f0..4db3bb5 100644 --- a/components/metrics/metrics_service.cc +++ b/components/metrics/metrics_service.cc @@ -262,7 +262,7 @@ bool NewInitialMetricsTimingEnabled() { void MarkAppCleanShutdownAndCommit(CleanExitBeacon* clean_exit_beacon, PrefService* local_state) { clean_exit_beacon->WriteBeaconValue(true); - local_state->SetInteger(metrics::prefs::kStabilityExecutionPhase, + local_state->SetInteger(prefs::kStabilityExecutionPhase, MetricsService::SHUTDOWN_COMPLETE); // Start writing right away (write happens on a different thread). local_state->CommitPendingWrite(); @@ -289,32 +289,30 @@ MetricsService::ExecutionPhase MetricsService::execution_phase_ = // static void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { DCHECK(IsSingleThreaded()); - metrics::MetricsStateManager::RegisterPrefs(registry); + MetricsStateManager::RegisterPrefs(registry); MetricsLog::RegisterPrefs(registry); - registry->RegisterInt64Pref(metrics::prefs::kInstallDate, 0); + registry->RegisterInt64Pref(prefs::kInstallDate, 0); - 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, + 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, UNINITIALIZED_PHASE); - registry->RegisterBooleanPref(metrics::prefs::kStabilitySessionEndCompleted, - true); - registry->RegisterIntegerPref(metrics::prefs::kMetricsSessionID, -1); + registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); + registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1); - registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs); - registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs); + registry->RegisterListPref(prefs::kMetricsInitialLogs); + registry->RegisterListPref(prefs::kMetricsOngoingLogs); - registry->RegisterInt64Pref(metrics::prefs::kUninstallLaunchCount, 0); - registry->RegisterInt64Pref(metrics::prefs::kUninstallMetricsUptimeSec, 0); + registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); + registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); } -MetricsService::MetricsService(metrics::MetricsStateManager* state_manager, - metrics::MetricsServiceClient* client, +MetricsService::MetricsService(MetricsStateManager* state_manager, + MetricsServiceClient* client, PrefService* local_state) : log_manager_(local_state, kUploadLogAvoidRetransmitSize), histogram_snapshot_manager_(this), @@ -338,11 +336,9 @@ MetricsService::MetricsService(metrics::MetricsStateManager* state_manager, DCHECK(local_state_); // Set the install date if this is our first run. - int64 install_date = local_state_->GetInt64(metrics::prefs::kInstallDate); - if (install_date == 0) { - local_state_->SetInt64(metrics::prefs::kInstallDate, - base::Time::Now().ToTimeT()); - } + int64 install_date = local_state_->GetInt64(prefs::kInstallDate); + if (install_date == 0) + local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT()); } MetricsService::~MetricsService() { @@ -398,7 +394,7 @@ std::string MetricsService::GetClientId() { } int64 MetricsService::GetInstallDate() { - return local_state_->GetInt64(metrics::prefs::kInstallDate); + return local_state_->GetInt64(prefs::kInstallDate); } scoped_ptr<const base::FieldTrial::EntropyProvider> @@ -493,12 +489,12 @@ void MetricsService::OnApplicationNotIdle() { void MetricsService::RecordStartOfSessionEnd() { LogCleanShutdown(); - RecordBooleanPrefValue(metrics::prefs::kStabilitySessionEndCompleted, false); + RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, false); } void MetricsService::RecordCompletedSessionEnd() { LogCleanShutdown(); - RecordBooleanPrefValue(metrics::prefs::kStabilitySessionEndCompleted, true); + RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, true); } #if defined(OS_ANDROID) || defined(OS_IOS) @@ -536,22 +532,21 @@ void MetricsService::LogNeedForCleanShutdown() { void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase, PrefService* local_state) { execution_phase_ = execution_phase; - local_state->SetInteger(metrics::prefs::kStabilityExecutionPhase, - execution_phase_); + local_state->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_); } void MetricsService::RecordBreakpadRegistration(bool success) { if (!success) - IncrementPrefValue(metrics::prefs::kStabilityBreakpadRegistrationFail); + IncrementPrefValue(prefs::kStabilityBreakpadRegistrationFail); else - IncrementPrefValue(metrics::prefs::kStabilityBreakpadRegistrationSuccess); + IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess); } void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { if (!has_debugger) - IncrementPrefValue(metrics::prefs::kStabilityDebuggerNotPresent); + IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); else - IncrementPrefValue(metrics::prefs::kStabilityDebuggerPresent); + IncrementPrefValue(prefs::kStabilityDebuggerPresent); } //------------------------------------------------------------------------------ @@ -568,17 +563,17 @@ void MetricsService::InitializeMetricsState() { bool version_changed = false; if (local_state_->GetInt64(prefs::kStabilityStatsBuildTime) != buildtime || local_state_->GetString(prefs::kStabilityStatsVersion) != version) { - local_state_->SetString(metrics::prefs::kStabilityStatsVersion, version); - local_state_->SetInt64(metrics::prefs::kStabilityStatsBuildTime, buildtime); + local_state_->SetString(prefs::kStabilityStatsVersion, version); + local_state_->SetInt64(prefs::kStabilityStatsBuildTime, buildtime); version_changed = true; } log_manager_.LoadPersistedUnsentLogs(); - session_id_ = local_state_->GetInteger(metrics::prefs::kMetricsSessionID); + session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); if (!clean_exit_beacon_.exited_cleanly()) { - IncrementPrefValue(metrics::prefs::kStabilityCrashCount); + IncrementPrefValue(prefs::kStabilityCrashCount); // Reset flag, and wait until we call LogNeedForCleanShutdown() before // monitoring. clean_exit_beacon_.WriteBeaconValue(true); @@ -588,7 +583,7 @@ void MetricsService::InitializeMetricsState() { // TODO(rtenneti): On windows, consider saving/getting execution_phase from // the registry. int execution_phase = - local_state_->GetInteger(metrics::prefs::kStabilityExecutionPhase); + local_state_->GetInteger(prefs::kStabilityExecutionPhase); UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", execution_phase); @@ -620,20 +615,18 @@ void MetricsService::InitializeMetricsState() { // Update session ID. ++session_id_; - local_state_->SetInteger(metrics::prefs::kMetricsSessionID, session_id_); + local_state_->SetInteger(prefs::kMetricsSessionID, session_id_); // Stability bookkeeping - IncrementPrefValue(metrics::prefs::kStabilityLaunchCount); + IncrementPrefValue(prefs::kStabilityLaunchCount); DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); SetExecutionPhase(START_METRICS_RECORDING, local_state_); - if (!local_state_->GetBoolean( - metrics::prefs::kStabilitySessionEndCompleted)) { - IncrementPrefValue(metrics::prefs::kStabilityIncompleteSessionEndCount); + if (!local_state_->GetBoolean(prefs::kStabilitySessionEndCompleted)) { + IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); // This is marked false when we get a WM_ENDSESSION. - local_state_->SetBoolean(metrics::prefs::kStabilitySessionEndCompleted, - true); + local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true); } // Call GetUptimes() for the first time, thus allowing all later calls @@ -643,13 +636,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. metrics::prefs::kStabilityLastTimestampSec may also be useless now. + // them. prefs::kStabilityLastTimestampSec may also be useless now. // TODO(jar): Delete these if they have no uses. - local_state_->SetInt64(metrics::prefs::kStabilityLaunchTimeSec, + local_state_->SetInt64(prefs::kStabilityLaunchTimeSec, base::Time::Now().ToTimeT()); // Bookkeeping for the uninstall metrics. - IncrementLongPrefsValue(metrics::prefs::kUninstallLaunchCount); + IncrementLongPrefsValue(prefs::kUninstallLaunchCount); // Kick off the process of saving the state (so the uptime numbers keep // getting updated) every n minutes. @@ -693,10 +686,9 @@ void MetricsService::GetUptimes(PrefService* pref, const int64 incremental_time_secs = incremental_uptime->InSeconds(); if (incremental_time_secs > 0) { - int64 metrics_uptime = - pref->GetInt64(metrics::prefs::kUninstallMetricsUptimeSec); + int64 metrics_uptime = pref->GetInt64(prefs::kUninstallMetricsUptimeSec); metrics_uptime += incremental_time_secs; - pref->SetInt64(metrics::prefs::kUninstallMetricsUptimeSec, metrics_uptime); + pref->SetInt64(prefs::kUninstallMetricsUptimeSec, metrics_uptime); } } @@ -1164,7 +1156,7 @@ void MetricsService::RegisterSyntheticFieldTrial( } void MetricsService::RegisterMetricsProvider( - scoped_ptr<metrics::MetricsProvider> provider) { + scoped_ptr<MetricsProvider> provider) { DCHECK_EQ(INITIALIZED, state_); metrics_providers_.push_back(provider.release()); } @@ -1224,7 +1216,7 @@ void MetricsService::LogCleanShutdown() { clean_exit_beacon_.WriteBeaconValue(true); RecordCurrentState(local_state_); - local_state_->SetInteger(metrics::prefs::kStabilityExecutionPhase, + local_state_->SetInteger(prefs::kStabilityExecutionPhase, MetricsService::SHUTDOWN_COMPLETE); } @@ -1242,7 +1234,7 @@ void MetricsService::RecordBooleanPrefValue(const char* path, bool value) { } void MetricsService::RecordCurrentState(PrefService* pref) { - pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, + pref->SetInt64(prefs::kStabilityLastTimestampSec, base::Time::Now().ToTimeT()); } diff --git a/components/metrics/metrics_service_unittest.cc b/components/metrics/metrics_service_unittest.cc index 2389060..0c5d6ea 100644 --- a/components/metrics/metrics_service_unittest.cc +++ b/components/metrics/metrics_service_unittest.cc @@ -31,7 +31,7 @@ scoped_ptr<ClientInfo> ReturnNoBackup() { return scoped_ptr<ClientInfo>(); } -class TestMetricsProvider : public metrics::MetricsProvider { +class TestMetricsProvider : public MetricsProvider { public: explicit TestMetricsProvider(bool has_stability_metrics) : has_stability_metrics_(has_stability_metrics), @@ -164,8 +164,7 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAfterCleanShutDown) { GetMetricsStateManager(), &client, GetLocalState()); TestMetricsProvider* test_provider = new TestMetricsProvider(false); - service.RegisterMetricsProvider( - scoped_ptr<metrics::MetricsProvider>(test_provider)); + service.RegisterMetricsProvider(scoped_ptr<MetricsProvider>(test_provider)); service.InitializeMetricsRecordingState(); // No initial stability log should be generated. @@ -184,7 +183,7 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAtProviderRequest) { // saved from a previous session. TestMetricsServiceClient client; TestMetricsLog log("client", 1, &client, GetLocalState()); - log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), + log.RecordEnvironment(std::vector<MetricsProvider*>(), std::vector<variations::ActiveGroupId>(), 0); @@ -278,10 +277,9 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { EXPECT_TRUE(log_manager->has_staged_log()); std::string uncompressed_log; - EXPECT_TRUE(metrics::GzipUncompress(log_manager->staged_log(), - &uncompressed_log)); + EXPECT_TRUE(GzipUncompress(log_manager->staged_log(), &uncompressed_log)); - metrics::ChromeUserMetricsExtension uma_log; + ChromeUserMetricsExtension uma_log; EXPECT_TRUE(uma_log.ParseFromString(uncompressed_log)); EXPECT_TRUE(uma_log.has_client_id()); @@ -297,16 +295,14 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { } TEST_F(MetricsServiceTest, RegisterSyntheticTrial) { - metrics::TestMetricsServiceClient client; + TestMetricsServiceClient client; MetricsService service(GetMetricsStateManager(), &client, GetLocalState()); // Add two synthetic trials and confirm that they show up in the list. - SyntheticTrialGroup trial1(metrics::HashName("TestTrial1"), - metrics::HashName("Group1")); + SyntheticTrialGroup trial1(HashName("TestTrial1"), HashName("Group1")); service.RegisterSyntheticFieldTrial(trial1); - SyntheticTrialGroup trial2(metrics::HashName("TestTrial2"), - metrics::HashName("Group2")); + SyntheticTrialGroup trial2(HashName("TestTrial2"), HashName("Group2")); service.RegisterSyntheticFieldTrial(trial2); // Ensure that time has advanced by at least a tick before proceeding. WaitUntilTimeChanges(base::TimeTicks::Now()); @@ -332,16 +328,14 @@ TEST_F(MetricsServiceTest, RegisterSyntheticTrial) { WaitUntilTimeChanges(begin_log_time); // Change the group for the first trial after the log started. - SyntheticTrialGroup trial3(metrics::HashName("TestTrial1"), - metrics::HashName("Group2")); + SyntheticTrialGroup trial3(HashName("TestTrial1"), HashName("Group2")); service.RegisterSyntheticFieldTrial(trial3); service.GetCurrentSyntheticFieldTrials(&synthetic_trials); EXPECT_EQ(1U, synthetic_trials.size()); EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); // Add a new trial after the log started and confirm that it doesn't show up. - SyntheticTrialGroup trial4(metrics::HashName("TestTrial3"), - metrics::HashName("Group3")); + SyntheticTrialGroup trial4(HashName("TestTrial3"), HashName("Group3")); service.RegisterSyntheticFieldTrial(trial4); service.GetCurrentSyntheticFieldTrials(&synthetic_trials); EXPECT_EQ(1U, synthetic_trials.size()); diff --git a/components/metrics/metrics_state_manager.cc b/components/metrics/metrics_state_manager.cc index 7f7b8e5..ae15823 100644 --- a/components/metrics/metrics_state_manager.cc +++ b/components/metrics/metrics_state_manager.cc @@ -231,7 +231,7 @@ void MetricsStateManager::BackUpCurrentClientInfo() { } scoped_ptr<ClientInfo> MetricsStateManager::LoadClientInfoAndMaybeMigrate() { - scoped_ptr<metrics::ClientInfo> client_info = load_client_info_.Run(); + scoped_ptr<ClientInfo> client_info = load_client_info_.Run(); // Prior to 2014-07, the client ID was stripped of its dashes before being // saved. Migrate back to a proper GUID if this is the case. This migration diff --git a/components/metrics/net/network_metrics_provider.cc b/components/metrics/net/network_metrics_provider.cc index c0b38d7..e845cde 100644 --- a/components/metrics/net/network_metrics_provider.cc +++ b/components/metrics/net/network_metrics_provider.cc @@ -15,9 +15,9 @@ #if defined(OS_CHROMEOS) #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h" -#endif // OS_CHROMEOS +#endif // OS_CHROMEOS -using metrics::SystemProfileProto; +namespace metrics { NetworkMetricsProvider::NetworkMetricsProvider( base::TaskRunner* io_task_runner) @@ -62,7 +62,7 @@ void NetworkMetricsProvider::ProvideSystemProfileMetrics( #else wifi_access_point_info_provider_.reset( new WifiAccessPointInfoProvider()); -#endif // OS_CHROMEOS +#endif // OS_CHROMEOS } // Connected wifi access point information. @@ -226,3 +226,5 @@ void NetworkMetricsProvider::WriteWifiAccessPointProto( NOTREACHED(); } } + +} // namespace metrics diff --git a/components/metrics/net/network_metrics_provider.h b/components/metrics/net/network_metrics_provider.h index 9ddb3f8..412ef67 100644 --- a/components/metrics/net/network_metrics_provider.h +++ b/components/metrics/net/network_metrics_provider.h @@ -14,10 +14,12 @@ #include "net/base/net_util.h" #include "net/base/network_change_notifier.h" +namespace metrics { + // Registers as observer with net::NetworkChangeNotifier and keeps track of // the network environment. class NetworkMetricsProvider - : public metrics::MetricsProvider, + : public MetricsProvider, public net::NetworkChangeNotifier::ConnectionTypeObserver { public: // Creates a NetworkMetricsProvider, where |io_task_runner| is used to post @@ -26,19 +28,17 @@ class NetworkMetricsProvider ~NetworkMetricsProvider() override; private: - // metrics::MetricsProvider: + // MetricsProvider: void OnDidCreateMetricsLog() override; - void ProvideSystemProfileMetrics( - metrics::SystemProfileProto* system_profile) override; + void ProvideSystemProfileMetrics(SystemProfileProto* system_profile) override; // ConnectionTypeObserver: void OnConnectionTypeChanged( net::NetworkChangeNotifier::ConnectionType type) override; - metrics::SystemProfileProto::Network::ConnectionType - GetConnectionType() const; - metrics::SystemProfileProto::Network::WifiPHYLayerProtocol - GetWifiPHYLayerProtocol() const; + SystemProfileProto::Network::ConnectionType GetConnectionType() const; + SystemProfileProto::Network::WifiPHYLayerProtocol GetWifiPHYLayerProtocol() + const; // Posts a call to net::GetWifiPHYLayerProtocol on the blocking pool. void ProbeWifiPHYLayerProtocol(); @@ -50,7 +50,7 @@ class NetworkMetricsProvider // connected to. void WriteWifiAccessPointProto( const WifiAccessPointInfoProvider::WifiAccessPointInfo& info, - metrics::SystemProfileProto::Network* network_proto); + SystemProfileProto::Network* network_proto); // Task runner used for blocking file I/O. base::TaskRunner* io_task_runner_; @@ -74,4 +74,6 @@ class NetworkMetricsProvider DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider); }; +} // namespace metrics + #endif // COMPONENTS_METRICS_NET_NETWORK_METRICS_PROVIDER_H_ diff --git a/components/metrics/net/wifi_access_point_info_provider.cc b/components/metrics/net/wifi_access_point_info_provider.cc index c8f07a4..21e04b1 100644 --- a/components/metrics/net/wifi_access_point_info_provider.cc +++ b/components/metrics/net/wifi_access_point_info_provider.cc @@ -4,6 +4,8 @@ #include "components/metrics/net/wifi_access_point_info_provider.h" +namespace metrics { + WifiAccessPointInfoProvider::WifiAccessPointInfo::WifiAccessPointInfo() { } @@ -19,3 +21,5 @@ WifiAccessPointInfoProvider::~WifiAccessPointInfoProvider() { bool WifiAccessPointInfoProvider::GetInfo(WifiAccessPointInfo *info) { return false; } + +} // namespace metrics diff --git a/components/metrics/net/wifi_access_point_info_provider.h b/components/metrics/net/wifi_access_point_info_provider.h index 5d74c3c..3493756 100644 --- a/components/metrics/net/wifi_access_point_info_provider.h +++ b/components/metrics/net/wifi_access_point_info_provider.h @@ -8,6 +8,8 @@ #include <string> #include "base/basictypes.h" +namespace metrics { + // Interface for accessing connected wireless access point information. class WifiAccessPointInfoProvider { public: @@ -46,4 +48,6 @@ class WifiAccessPointInfoProvider { DISALLOW_COPY_AND_ASSIGN(WifiAccessPointInfoProvider); }; +} // namespace metrics + #endif // COMPONENTS_METRICS_NET_WIFI_ACCESS_POINT_INFO_PROVIDER_H_ diff --git a/components/metrics/net/wifi_access_point_info_provider_chromeos.cc b/components/metrics/net/wifi_access_point_info_provider_chromeos.cc index c05829b..314ddc5 100644 --- a/components/metrics/net/wifi_access_point_info_provider_chromeos.cc +++ b/components/metrics/net/wifi_access_point_info_provider_chromeos.cc @@ -16,6 +16,8 @@ using chromeos::NetworkHandler; +namespace metrics { + WifiAccessPointInfoProviderChromeos::WifiAccessPointInfoProviderChromeos() { NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); @@ -116,3 +118,5 @@ void WifiAccessPointInfoProviderChromeos::ParseInfo( vendor_dict->GetStringWithoutPathExpansion(shill::kVendorOUIListProperty, &wifi_access_point_info_.oui_list); } + +} // namespace metrics diff --git a/components/metrics/net/wifi_access_point_info_provider_chromeos.h b/components/metrics/net/wifi_access_point_info_provider_chromeos.h index 520cedd..c6980ec 100644 --- a/components/metrics/net/wifi_access_point_info_provider_chromeos.h +++ b/components/metrics/net/wifi_access_point_info_provider_chromeos.h @@ -5,12 +5,16 @@ #ifndef COMPONENTS_METRICS_NET_WIFI_ACCESS_POINT_INFO_PROVIDER_CHROMEOS_H_ #define COMPONENTS_METRICS_NET_WIFI_ACCESS_POINT_INFO_PROVIDER_CHROMEOS_H_ +#include <string> + #include "base/basictypes.h" #include "base/memory/weak_ptr.h" #include "base/values.h" #include "chromeos/network/network_state_handler_observer.h" #include "components/metrics/net/wifi_access_point_info_provider.h" +namespace metrics { + // WifiAccessPointInfoProviderChromeos provides the connected wifi // acccess point information for chromeos. class WifiAccessPointInfoProviderChromeos @@ -21,11 +25,11 @@ class WifiAccessPointInfoProviderChromeos WifiAccessPointInfoProviderChromeos(); virtual ~WifiAccessPointInfoProviderChromeos(); - // WifiAccessPointInfoProvider - virtual bool GetInfo(WifiAccessPointInfo* info) override; + // WifiAccessPointInfoProvider: + bool GetInfo(WifiAccessPointInfo* info) override; - // NetworkStateHandlerObserver overrides. - virtual void DefaultNetworkChanged( + // NetworkStateHandlerObserver: + void DefaultNetworkChanged( const chromeos::NetworkState* default_network) override; private: @@ -39,4 +43,6 @@ class WifiAccessPointInfoProviderChromeos DISALLOW_COPY_AND_ASSIGN(WifiAccessPointInfoProviderChromeos); }; +} // namespace metrics + #endif // COMPONENTS_METRICS_NET_WIFI_ACCESS_POINT_INFO_PROVIDER_CHROMEOS_H_ diff --git a/components/metrics/profiler/tracking_synchronizer.cc b/components/metrics/profiler/tracking_synchronizer.cc index a6ed609..0935f314 100644 --- a/components/metrics/profiler/tracking_synchronizer.cc +++ b/components/metrics/profiler/tracking_synchronizer.cc @@ -16,6 +16,8 @@ using base::TimeTicks; using content::BrowserThread; +namespace metrics { + namespace { // Negative numbers are never used as sequence numbers. We explicitly pick a @@ -30,12 +32,9 @@ const int kNeverUsableSequenceNumber = -2; // calls. This object is created on the UI thread, and it is destroyed after // all the other threads have gone away. As a result, it is ok to call it // from the UI thread, or for about:profiler. -static metrics::TrackingSynchronizer* g_tracking_synchronizer = - NULL; +static TrackingSynchronizer* g_tracking_synchronizer = NULL; -} // anonymous namespace - -namespace metrics { +} // namespace // The "RequestContext" structure describes an individual request received // from the UI. All methods are accessible on UI thread. diff --git a/components/metrics/serialization/serialization_utils.cc b/components/metrics/serialization/serialization_utils.cc index 30c2675..d57b51b 100644 --- a/components/metrics/serialization/serialization_utils.cc +++ b/components/metrics/serialization/serialization_utils.cc @@ -56,7 +56,7 @@ bool ReadMessage(int fd, std::string* message) { // kMessageMaxLength applies to the entire message: the 4-byte // length field and the content. - if (message_size > metrics::SerializationUtils::kMessageMaxLength) { + if (message_size > SerializationUtils::kMessageMaxLength) { DLOG(ERROR) << "message too long : " << message_size; if (HANDLE_EINTR(lseek(fd, message_size - 4, SEEK_CUR)) == -1) { DLOG(ERROR) << "error while skipping message. abort"; @@ -69,7 +69,7 @@ bool ReadMessage(int fd, std::string* message) { } message_size -= sizeof(message_size); // The message size includes itself. - char buffer[metrics::SerializationUtils::kMessageMaxLength]; + char buffer[SerializationUtils::kMessageMaxLength]; if (!base::ReadFromFD(fd, buffer, message_size)) { DPLOG(ERROR) << "reading metrics message body"; return false; |