Chromium Code Reviews| Index: chromecast/browser/metrics/cast_metrics_service_client.cc |
| diff --git a/chromecast/browser/metrics/cast_metrics_service_client.cc b/chromecast/browser/metrics/cast_metrics_service_client.cc |
| index d3f2f595ca8374ae490e09eec28bd821f7e5fed9..3beff732b4e98bd11b917bb9cd949f21b1992cc1 100644 |
| --- a/chromecast/browser/metrics/cast_metrics_service_client.cc |
| +++ b/chromecast/browser/metrics/cast_metrics_service_client.cc |
| @@ -16,8 +16,9 @@ |
| #include "chromecast/base/chromecast_switches.h" |
| #include "chromecast/base/path_utils.h" |
| #include "chromecast/base/version.h" |
| +#include "chromecast/browser/cast_browser_process.h" |
| +#include "chromecast/browser/cast_content_browser_client.h" |
| #include "chromecast/browser/metrics/cast_stability_metrics_provider.h" |
| -#include "chromecast/browser/metrics/platform_metrics_providers.h" |
| #include "chromecast/common/pref_names.h" |
| #include "chromecast/public/cast_sys_info.h" |
| #include "components/metrics/client_info.h" |
| @@ -94,7 +95,8 @@ void CastMetricsServiceClient::SetMetricsClientId( |
| const std::string& client_id) { |
| client_id_ = client_id; |
| LOG(INFO) << "Metrics client ID set: " << client_id; |
| - PlatformSetClientID(cast_service_, client_id); |
| + shell::CastBrowserProcess::GetInstance()->browser_client()-> |
| + SetMetricsClientId(client_id); |
| } |
| void CastMetricsServiceClient::OnRecordingDisabled() { |
| @@ -110,6 +112,7 @@ void CastMetricsServiceClient::StoreClientInfo( |
| scoped_ptr< ::metrics::ClientInfo> CastMetricsServiceClient::LoadClientInfo() { |
| scoped_ptr< ::metrics::ClientInfo> client_info(new ::metrics::ClientInfo); |
| + client_info_loaded_ = true; |
| // kMetricsIsNewClientID would be missing if either the device was just |
| // FDR'ed, or it is on pre-v1.2 build. |
| @@ -125,16 +128,17 @@ scoped_ptr< ::metrics::ClientInfo> CastMetricsServiceClient::LoadClientInfo() { |
| // else the device was just FDR'ed, pass through. |
| } |
| - const std::string client_id(GetPlatformClientID(cast_service_)); |
| - if (!client_id.empty() && base::IsValidGUID(client_id)) { |
| - client_info->client_id = client_id; |
| + if (!persisted_client_id_.empty() && |
| + base::IsValidGUID(persisted_client_id_)) { |
| + client_info->client_id = persisted_client_id_; |
| return client_info.Pass(); |
| } else { |
|
byungchul
2015/08/19 21:11:20
no else after return.
gunsch
2015/08/19 21:23:12
Done.
|
| - if (client_id.empty()) { |
| + if (persisted_client_id_.empty()) { |
| LOG(WARNING) << "Empty client id from platform," |
| << " assuming this is the first boot up of a new device."; |
| } else { |
| - LOG(ERROR) << "Invalid client id " << client_id << " from platform."; |
| + LOG(ERROR) << "Invalid client id from platform: " << persisted_client_id_ |
| + << " from platform."; |
| } |
| return scoped_ptr< ::metrics::ClientInfo>(); |
| } |
| @@ -258,6 +262,7 @@ CastMetricsServiceClient::CastMetricsServiceClient( |
| : io_task_runner_(io_task_runner), |
| pref_service_(pref_service), |
| cast_service_(nullptr), |
| + client_info_loaded_(false), |
| #if defined(OS_LINUX) |
| external_metrics_(nullptr), |
| platform_metrics_(nullptr), |
| @@ -273,6 +278,13 @@ CastMetricsServiceClient::~CastMetricsServiceClient() { |
| #endif // defined(OS_LINUX) |
| } |
| +void CastMetricsServiceClient::SetPersistedClientId( |
| + const std::string& client_id) { |
| + DCHECK(!client_info_loaded_) |
| + << "Persisted client ID must be set before client info is loaded."; |
| + persisted_client_id_ = client_id; |
| +} |
| + |
| void CastMetricsServiceClient::Initialize(CastService* cast_service) { |
| DCHECK(cast_service); |
| DCHECK(!cast_service_); |
| @@ -315,7 +327,8 @@ void CastMetricsServiceClient::Initialize(CastService* cast_service) { |
| metrics_service_->RegisterMetricsProvider( |
| scoped_ptr< ::metrics::MetricsProvider>( |
| new ::metrics::ProfilerMetricsProvider)); |
| - RegisterPlatformMetricsProviders(metrics_service_.get(), cast_service_); |
| + shell::CastBrowserProcess::GetInstance()->browser_client()-> |
| + RegisterMetricsProviders(metrics_service_.get()); |
| metrics_service_->InitializeMetricsRecordingState(); |
| #if !defined(OS_ANDROID) |