OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ |
| 6 #define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/supports_user_data.h" |
| 12 |
| 13 namespace net { |
| 14 class URLFetcher; |
| 15 } |
| 16 |
| 17 namespace data_use_measurement { |
| 18 |
| 19 // Used to annotate URLRequests with the service name if the URLRequest is used |
| 20 // by a service. |
| 21 class DataUseUserData : public base::SupportsUserData::Data { |
| 22 public: |
| 23 // This enum should be synced with DataUseServices enum in histograms.xml. |
| 24 // Please keep them synced after any updates. Also add service name to |
| 25 // GetServiceNameAsString function. |
| 26 enum ServiceName { |
| 27 NOT_TAGGED, |
| 28 SUGGESTIONS, |
| 29 }; |
| 30 |
| 31 explicit DataUseUserData(ServiceName service_name); |
| 32 ~DataUseUserData() override; |
| 33 |
| 34 // Helper function to create DataUseUserData. The caller takes the ownership |
| 35 // of the returned object. |
| 36 static base::SupportsUserData::Data* Create( |
| 37 DataUseUserData::ServiceName service); |
| 38 |
| 39 // Return the service name of the ServiceName enum. |
| 40 static std::string GetServiceNameAsString(ServiceName service); |
| 41 |
| 42 // Services should use this function to attach their |service_name| to the |
| 43 // URLFethcer serving them. |
| 44 static void AttachToFetcher(net::URLFetcher* fetcher, |
| 45 ServiceName service_name); |
| 46 |
| 47 ServiceName service_name() const { return service_name_; } |
| 48 |
| 49 // The key for retrieving back this type of user data. |
| 50 static const void* kUserDataKey; |
| 51 |
| 52 private: |
| 53 const ServiceName service_name_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(DataUseUserData); |
| 56 }; |
| 57 |
| 58 } // data_use_measurement namespace |
| 59 |
| 60 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ |
OLD | NEW |