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..80d310e0ade12ae9a8da8e049d71f752603b701c |
--- /dev/null |
+++ b/components/data_use_measurement/core/data_use_user_data.h |
@@ -0,0 +1,57 @@ |
+// 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 "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 |
+ // GetServiceName function. |
+ enum ServiceType { |
mmenke
2015/09/04 20:51:46
nit: ServiceName?
amohammadkhan
2015/09/05 00:58:02
Done.
|
+ NOT_TAGGED, |
+ SUGGESTIONS, |
+ }; |
+ |
+ explicit DataUseUserData(ServiceType service_type); |
+ ~DataUseUserData() override; |
+ |
+ // Helper function to create DataUseUserData. The caller takes the ownership |
+ // of |
+ // the returned object. |
+ static base::SupportsUserData::Data* Create( |
+ DataUseUserData::ServiceType service); |
+ |
+ // Return the service name of the ServiceType enum. |
+ static const char* GetServiceName(ServiceType service); |
mmenke
2015/09/04 20:51:46
GetServiceNameAsString?
amohammadkhan
2015/09/05 00:58:03
Done.
|
+ |
+ // Services should use this function to attach their |service_type| to the |
+ // URLFethcer serving them. |
+ static void AttachToFetcher(net::URLFetcher* fetcher, |
+ ServiceType service_type); |
+ |
+ ServiceType service_type() const { return service_type_; } |
+ |
+ // The key for retrieving back this type of user data. |
+ static const void* kUserDataKey; |
+ |
+ private: |
+ const ServiceType service_type_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DataUseUserData); |
+}; |
+ |
+} // data_use_measurement namespace |
+#endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ |
mmenke
2015/09/04 20:51:46
nit: Blank line before #endif.
amohammadkhan
2015/09/05 00:58:03
Done.
|