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

Unified Diff: components/data_use_measurement/core/data_use_user_data.cc

Issue 1279543002: Support needed to measure user and service traffic in Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewHistogram
Patch Set: Minor updates in dep files. Created 5 years, 3 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
Index: components/data_use_measurement/core/data_use_user_data.cc
diff --git a/components/data_use_measurement/core/data_use_user_data.cc b/components/data_use_measurement/core/data_use_user_data.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ce88d60993a81d43f81b787dfd4fc3dc47b9962a
--- /dev/null
+++ b/components/data_use_measurement/core/data_use_user_data.cc
@@ -0,0 +1,46 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/data_use_measurement/core/data_use_user_data.h"
+
+#include "base/strings/stringprintf.h"
+#include "net/url_request/url_fetcher.h"
+
+namespace data_use_measurement {
+
+DataUseUserData::DataUseUserData(ServiceName service_name)
+ : service_name_(service_name) {}
+
+DataUseUserData::~DataUseUserData() {}
+
+// static
+const void* DataUseUserData::kUserDataKey =
+ static_cast<const void*>(&DataUseUserData::kUserDataKey);
+
+// static
+base::SupportsUserData::Data* DataUseUserData::Create(
+ ServiceName service_name) {
+ return new DataUseUserData(service_name);
+}
+
+// static
+std::string DataUseUserData::GetServiceNameAsString(ServiceName service_name,
+ const char* prefix) {
+ switch (service_name) {
+ case SUGGESTIONS:
+ return base::StringPrintf("%s%s", prefix, "Suggestions");
+ case NOT_TAGGED:
+ return base::StringPrintf("%s%s", prefix, "NotTagged");
+ }
+ return base::StringPrintf("%s%s", prefix, "INVALID");
+}
+
+// static
+void DataUseUserData::AttachToFetcher(net::URLFetcher* fetcher,
+ ServiceName service_name) {
+ fetcher->SetURLRequestUserData(kUserDataKey,
+ base::Bind(&Create, service_name));
+}
+
+} // namespace data_use_measurement

Powered by Google App Engine
This is Rietveld 408576698