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..533803185f3a9a3c019fa4a2e34b32b93c8d6154 |
--- /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 "net/url_request/url_fetcher.h" |
+ |
+namespace data_use_measurement { |
+ |
+DataUseUserData::DataUseUserData(ServiceName service_type) |
+ : service_type_(service_type) {} |
+ |
+DataUseUserData::~DataUseUserData() {} |
+ |
+// static |
+const void* DataUseUserData::kUserDataKey = |
+ static_cast<const void*>(&DataUseUserData::kUserDataKey); |
+ |
+// static |
+base::SupportsUserData::Data* DataUseUserData::Create( |
+ ServiceName service_type) { |
+ return new DataUseUserData(service_type); |
+} |
+ |
+// static |
+const char* DataUseUserData::GetServiceNameAsString( |
+ DataUseUserData::ServiceName service_type) { |
+ switch (service_type) { |
+ case SUGGESTIONS: |
+ return "Suggestions"; |
+ case NOT_TAGGED: |
+ return "NotTagged"; |
+ } |
+ NOTREACHED() << "Unknown service type in DataUseUserData"; |
+ return "INVALID"; |
+} |
+ |
+// static |
+void DataUseUserData::AttachToFetcher(net::URLFetcher* fetcher, |
+ ServiceName service_type) { |
+ fetcher->SetURLRequestUserData(kUserDataKey, |
+ base::Bind(&Create, service_type)); |
+} |
+ |
+} // namespace data_use_measurement |