Chromium Code Reviews| 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..28dc89980750ba8166deb31460cac737ff0f11fa |
| --- /dev/null |
| +++ b/components/data_use_measurement/core/data_use_user_data.h |
| @@ -0,0 +1,45 @@ |
| +// 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 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 { |
|
mmenke
2015/09/01 17:52:37
UrlRequestSourceInfo?
amohammadkhan
2015/09/01 19:38:15
I think if I don't make changes regarding your oth
|
| + 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/01 17:52:37
Maybe rename to "source" and add a label for "OTHE
amohammadkhan
2015/09/01 19:38:15
It is very good that we can get rid of ResourceReq
|
| + NOT_TAGGED, |
| + SUGGESTIONS, |
| + }; |
| + explicit DataUseUserData(ServiceType service_type); |
| + ~DataUseUserData() override; |
| + |
| + ServiceType service_type() const { return service_type_; } |
| + |
| + // The key for retrieving back this type of user data. |
| + static const void* kUserDataKey; |
| + |
| + private: |
| + ServiceType service_type_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DataUseUserData); |
| +}; |
| + |
| +// Helper function to create DataUseUserData. The caller takes the ownership of |
| +// the returned object. |
| +base::SupportsUserData::Data* CreateDataUseUserData( |
| + DataUseUserData::ServiceType service); |
|
mmenke
2015/09/01 17:52:37
Rather than exposing the details of how this works
amohammadkhan
2015/09/01 19:38:15
Good idea. I made the second function and used it
|
| + |
| +const char* GetServiceName(DataUseUserData::ServiceType service); |
| + |
| +} // data_use_measurement namespace |
| +#endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ |