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

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

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: Addressed comments and rebased. 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.h
diff --git a/components/data_use_measurement/core/data_use_user_data.h b/components/data_use_measurement/core/data_use_user_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..55bdd1f351142e345c93b75e3e901d779fc1c63a
--- /dev/null
+++ b/components/data_use_measurement/core/data_use_user_data.h
@@ -0,0 +1,60 @@
+// 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.
+
+#ifndef COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_
+#define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/supports_user_data.h"
+
+namespace net {
+class URLFetcher;
+}
+
+namespace data_use_measurement {
+
+// Used to annotate URLRequests with the service name if the URLRequest is used
+// by a service.
+class DataUseUserData : public base::SupportsUserData::Data {
+ public:
+ // This enum should be synced with DataUseServices enum in histograms.xml.
+ // Please keep them synced after any updates. Also add service name to
+ // GetServiceNameAsString function.
+ enum ServiceName {
+ NOT_TAGGED,
+ SUGGESTIONS,
+ };
+
+ explicit DataUseUserData(ServiceName service_name);
+ ~DataUseUserData() override;
+
+ // Helper function to create DataUseUserData. The caller takes the ownership
+ // of the returned object.
+ static base::SupportsUserData::Data* Create(
+ DataUseUserData::ServiceName service);
+
+ // Return the service name of the ServiceName enum.
+ static std::string GetServiceNameAsString(ServiceName service);
+
+ // Services should use this function to attach their |service_name| to the
+ // URLFethcer serving them.
+ static void AttachToFetcher(net::URLFetcher* fetcher,
+ ServiceName service_name);
+
+ ServiceName service_name() const { return service_name_; }
+
+ // The key for retrieving back this type of user data.
+ static const void* kUserDataKey;
+
+ private:
+ const ServiceName service_name_;
+
+ DISALLOW_COPY_AND_ASSIGN(DataUseUserData);
+};
+
+} // data_use_measurement namespace
+
+#endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_
« no previous file with comments | « components/data_use_measurement/core/DEPS ('k') | components/data_use_measurement/core/data_use_user_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698