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

Unified Diff: components/ukm/ukm_service.cc

Issue 2649303004: UKM: Added support for navigation sources (Closed)
Patch Set: Missing docs Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ukm/ukm_service.h ('k') | components/ukm/ukm_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ukm/ukm_service.cc
diff --git a/components/ukm/ukm_service.cc b/components/ukm/ukm_service.cc
index 823bff5fb368bbe1278aecd598f42adfab331284..1de9328bf0033df69fd89fb5d32d76c2715e1fc1 100644
--- a/components/ukm/ukm_service.cc
+++ b/components/ukm/ukm_service.cc
@@ -18,11 +18,13 @@
#include "components/metrics/metrics_log_uploader.h"
#include "components/metrics/metrics_service_client.h"
#include "components/metrics/proto/ukm/report.pb.h"
+#include "components/metrics/proto/ukm/source.pb.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/ukm/metrics_reporting_scheduler.h"
#include "components/ukm/persisted_logs_metrics_impl.h"
#include "components/ukm/ukm_pref_names.h"
+#include "components/ukm/ukm_source.h"
#include "components/variations/variations_associated_data.h"
namespace ukm {
@@ -54,6 +56,9 @@ constexpr int kMinPersistedBytes = 300000;
// limit is exceeded.
constexpr size_t kMaxLogRetransmitSize = 100 * 1024;
+// Maximum number of Sources we'll keep around before dropping new ones.
rkaplow 2017/01/25 19:10:14 can you note this will drop the newer sources inst
oystein (OOO til 10th of July) 2017/01/25 21:09:56 Reworded to make this clearer.
+const size_t kMaxSources = 100;
+
std::string GetServerUrl() {
std::string server_url =
variations::GetVariationParamValueByFeature(kUkmFeature, "ServerUrl");
@@ -150,7 +155,7 @@ void UkmService::Flush() {
void UkmService::Purge() {
DVLOG(1) << "UkmService::Purge";
persisted_logs_.Purge();
- // TODO(oystein): Delete any stored sources.
+ sources_.clear();
}
// static
@@ -190,7 +195,12 @@ void UkmService::BuildAndStoreLog() {
Report report;
report.set_client_id(client_id_);
// TODO(holte): Populate system_profile.
- // TODO(oystein): Populate sources.
+ for (const auto& source : sources_) {
rkaplow 2017/01/25 19:10:14 can you add a UMA histogram for how many sources?
oystein (OOO til 10th of July) 2017/01/25 21:09:56 Done.
+ Source* proto_source = report.add_sources();
+ source->PopulateProto(proto_source);
+ }
+ sources_.clear();
+
std::string serialized_log;
report.SerializeToString(&serialized_log);
persisted_logs_.StoreLog(serialized_log);
@@ -247,4 +257,11 @@ void UkmService::OnLogUploadComplete(int response_code) {
scheduler_->UploadFinished(server_is_healthy, !persisted_logs_.empty());
}
+void UkmService::RecordSource(std::unique_ptr<UkmSource> source) {
+ if (sources_.size() >= kMaxSources)
rkaplow 2017/01/25 19:10:14 can you add a UMA histogram here?
oystein (OOO til 10th of July) 2017/01/25 21:09:56 Done.
+ return;
+
+ sources_.push_back(std::move(source));
+}
+
} // namespace ukm
« no previous file with comments | « components/ukm/ukm_service.h ('k') | components/ukm/ukm_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698