Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: components/ukm/ukm_service.cc

Issue 2657083003: Populate a basic SystemProfileProto in UKM. (Closed)
Patch Set: fixes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ukm/ukm_service.h" 5 #include "components/ukm/ukm_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/rand_util.h" 15 #include "base/rand_util.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "components/metrics/metrics_log.h"
18 #include "components/metrics/metrics_log_uploader.h" 19 #include "components/metrics/metrics_log_uploader.h"
19 #include "components/metrics/metrics_service_client.h" 20 #include "components/metrics/metrics_service_client.h"
20 #include "components/metrics/proto/ukm/report.pb.h" 21 #include "components/metrics/proto/ukm/report.pb.h"
21 #include "components/prefs/pref_registry_simple.h" 22 #include "components/prefs/pref_registry_simple.h"
22 #include "components/prefs/pref_service.h" 23 #include "components/prefs/pref_service.h"
23 #include "components/ukm/metrics_reporting_scheduler.h" 24 #include "components/ukm/metrics_reporting_scheduler.h"
24 #include "components/ukm/persisted_logs_metrics_impl.h" 25 #include "components/ukm/persisted_logs_metrics_impl.h"
25 #include "components/ukm/ukm_pref_names.h" 26 #include "components/ukm/ukm_pref_names.h"
26 #include "components/variations/variations_associated_data.h" 27 #include "components/variations/variations_associated_data.h"
27 28
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 prefs::kUkmPersistedLogs, 88 prefs::kUkmPersistedLogs,
88 kMinPersistedLogs, 89 kMinPersistedLogs,
89 kMinPersistedBytes, 90 kMinPersistedBytes,
90 kMaxLogRetransmitSize), 91 kMaxLogRetransmitSize),
91 initialize_started_(false), 92 initialize_started_(false),
92 initialize_complete_(false), 93 initialize_complete_(false),
93 log_upload_in_progress_(false), 94 log_upload_in_progress_(false),
94 self_ptr_factory_(this) { 95 self_ptr_factory_(this) {
95 DCHECK(pref_service_); 96 DCHECK(pref_service_);
96 DCHECK(client_); 97 DCHECK(client_);
98 DVLOG(1) << "UkmService::Constructor";
97 99
98 persisted_logs_.DeserializeLogs(); 100 persisted_logs_.DeserializeLogs();
99 101
100 base::Closure rotate_callback = 102 base::Closure rotate_callback =
101 base::Bind(&UkmService::RotateLog, self_ptr_factory_.GetWeakPtr()); 103 base::Bind(&UkmService::RotateLog, self_ptr_factory_.GetWeakPtr());
102 // MetricsServiceClient outlives UkmService, and 104 // MetricsServiceClient outlives UkmService, and
103 // MetricsReportingScheduler is tied to the lifetime of |this|. 105 // MetricsReportingScheduler is tied to the lifetime of |this|.
104 const base::Callback<base::TimeDelta(void)>& get_upload_interval_callback = 106 const base::Callback<base::TimeDelta(void)>& get_upload_interval_callback =
105 base::Bind(&metrics::MetricsServiceClient::GetStandardUploadInterval, 107 base::Bind(&metrics::MetricsServiceClient::GetStandardUploadInterval,
106 base::Unretained(client_)); 108 base::Unretained(client_));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 BuildAndStoreLog(); 184 BuildAndStoreLog();
183 } 185 }
184 StartScheduledUpload(); 186 StartScheduledUpload();
185 } 187 }
186 188
187 void UkmService::BuildAndStoreLog() { 189 void UkmService::BuildAndStoreLog() {
188 DCHECK(thread_checker_.CalledOnValidThread()); 190 DCHECK(thread_checker_.CalledOnValidThread());
189 DVLOG(1) << "UkmService::BuildAndStoreLog"; 191 DVLOG(1) << "UkmService::BuildAndStoreLog";
190 Report report; 192 Report report;
191 report.set_client_id(client_id_); 193 report.set_client_id(client_id_);
192 // TODO(holte): Populate system_profile. 194 metrics::MetricsLog::RecordCoreSystemProfile(client_,
195 report.mutable_system_profile());
196 // TODO(rkaplow): Populate network information.
193 // TODO(oystein): Populate sources. 197 // TODO(oystein): Populate sources.
194 std::string serialized_log; 198 std::string serialized_log;
195 report.SerializeToString(&serialized_log); 199 report.SerializeToString(&serialized_log);
196 persisted_logs_.StoreLog(serialized_log); 200 persisted_logs_.StoreLog(serialized_log);
197 } 201 }
198 202
199 void UkmService::StartScheduledUpload() { 203 void UkmService::StartScheduledUpload() {
200 DCHECK(thread_checker_.CalledOnValidThread()); 204 DCHECK(thread_checker_.CalledOnValidThread());
201 DCHECK(!log_upload_in_progress_); 205 DCHECK(!log_upload_in_progress_);
202 if (!persisted_logs_.has_staged_log()) 206 if (!persisted_logs_.has_staged_log())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 persisted_logs_.SerializeLogs(); 245 persisted_logs_.SerializeLogs();
242 } 246 }
243 247
244 // Error 400 indicates a problem with the log, not with the server, so 248 // Error 400 indicates a problem with the log, not with the server, so
245 // don't consider that a sign that the server is in trouble. 249 // don't consider that a sign that the server is in trouble.
246 bool server_is_healthy = upload_succeeded || response_code == 400; 250 bool server_is_healthy = upload_succeeded || response_code == 400;
247 scheduler_->UploadFinished(server_is_healthy, !persisted_logs_.empty()); 251 scheduler_->UploadFinished(server_is_healthy, !persisted_logs_.empty());
248 } 252 }
249 253
250 } // namespace ukm 254 } // namespace ukm
OLDNEW
« components/metrics/metrics_log.h ('K') | « components/ukm/ukm_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698