| Index: chrome/browser/metrics/metrics_service.cc
|
| diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
|
| index 19d1808409a1a0bc2506591355e8310712d0d883..5c6be0588ef5f0cbc4aed34948e890f491301e44 100644
|
| --- a/chrome/browser/metrics/metrics_service.cc
|
| +++ b/chrome/browser/metrics/metrics_service.cc
|
| @@ -479,6 +479,21 @@ std::string MetricsService::GetClientId() {
|
| return client_id_;
|
| }
|
|
|
| +std::string MetricsService::GetClientIdNonEmpty() {
|
| + PrefService* pref = g_browser_process->local_state();
|
| + DCHECK(pref);
|
| + std::string client_id = pref->GetString(prefs::kMetricsClientID);
|
| + if (client_id.empty()) {
|
| + client_id = GenerateClientID();
|
| + pref->SetString(prefs::kMetricsClientID, client_id);
|
| +
|
| + // Might as well make a note of how long this ID has existed
|
| + pref->SetString(prefs::kMetricsClientIDTimestamp,
|
| + base::Int64ToString(Time::Now().ToTimeT()));
|
| + }
|
| + return client_id;
|
| +}
|
| +
|
| void MetricsService::SetRecording(bool enabled) {
|
| DCHECK(IsSingleThreaded());
|
|
|
| @@ -487,17 +502,7 @@ void MetricsService::SetRecording(bool enabled) {
|
|
|
| if (enabled) {
|
| if (client_id_.empty()) {
|
| - PrefService* pref = g_browser_process->local_state();
|
| - DCHECK(pref);
|
| - client_id_ = pref->GetString(prefs::kMetricsClientID);
|
| - if (client_id_.empty()) {
|
| - client_id_ = GenerateClientID();
|
| - pref->SetString(prefs::kMetricsClientID, client_id_);
|
| -
|
| - // Might as well make a note of how long this ID has existed
|
| - pref->SetString(prefs::kMetricsClientIDTimestamp,
|
| - base::Int64ToString(Time::Now().ToTimeT()));
|
| - }
|
| + client_id_ = GetClientIdNonEmpty();
|
| }
|
| child_process_logging::SetClientId(client_id_);
|
| StartRecording();
|
|
|