OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_ | 5 #ifndef COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_ |
6 #define COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_ | 6 #define COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "components/metrics/metrics_service.h" | 16 #include "components/metrics/metrics_service.h" |
17 #include "components/variations/variations_associated_data.h" | 17 #include "components/variations/variations_associated_data.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class ResourceContext; | 20 class ResourceContext; |
21 } | 21 } |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 class HttpRequestHeaders; | 24 class HttpRequestHeaders; |
25 } | 25 } |
26 | 26 |
27 class GURL; | 27 class GURL; |
28 | 28 |
| 29 namespace base { |
29 template <typename T> struct DefaultSingletonTraits; | 30 template <typename T> struct DefaultSingletonTraits; |
| 31 } |
30 | 32 |
31 namespace variations { | 33 namespace variations { |
32 | 34 |
33 // A helper class for maintaining client experiments and metrics state | 35 // A helper class for maintaining client experiments and metrics state |
34 // transmitted in custom HTTP request headers. | 36 // transmitted in custom HTTP request headers. |
35 // This class is a thread-safe singleton. | 37 // This class is a thread-safe singleton. |
36 class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer, | 38 class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer, |
37 public metrics::SyntheticTrialObserver { | 39 public metrics::SyntheticTrialObserver { |
38 public: | 40 public: |
39 static VariationsHttpHeaderProvider* GetInstance(); | 41 static VariationsHttpHeaderProvider* GetInstance(); |
(...skipping 14 matching lines...) Expand all Loading... |
54 // with "t" it will be treated as a trigger experiment id. | 56 // with "t" it will be treated as a trigger experiment id. |
55 bool SetDefaultVariationIds(const std::string& variation_ids); | 57 bool SetDefaultVariationIds(const std::string& variation_ids); |
56 | 58 |
57 // Returns the HTTP header names which are added in this class. | 59 // Returns the HTTP header names which are added in this class. |
58 std::set<std::string> GetVariationHeaderNames() const; | 60 std::set<std::string> GetVariationHeaderNames() const; |
59 | 61 |
60 // Resets any cached state for tests. | 62 // Resets any cached state for tests. |
61 void ResetForTesting(); | 63 void ResetForTesting(); |
62 | 64 |
63 private: | 65 private: |
64 friend struct DefaultSingletonTraits<VariationsHttpHeaderProvider>; | 66 friend struct base::DefaultSingletonTraits<VariationsHttpHeaderProvider>; |
65 | 67 |
66 FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, | 68 FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, |
67 ShouldAppendHeaders); | 69 ShouldAppendHeaders); |
68 FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, | 70 FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, |
69 SetDefaultVariationIds_Valid); | 71 SetDefaultVariationIds_Valid); |
70 FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, | 72 FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, |
71 SetDefaultVariationIds_Invalid); | 73 SetDefaultVariationIds_Invalid); |
72 FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, | 74 FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, |
73 OnFieldTrialGroupFinalized); | 75 OnFieldTrialGroupFinalized); |
74 | 76 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 std::set<VariationID> synthetic_variation_ids_set_; | 121 std::set<VariationID> synthetic_variation_ids_set_; |
120 | 122 |
121 std::string variation_ids_header_; | 123 std::string variation_ids_header_; |
122 | 124 |
123 DISALLOW_COPY_AND_ASSIGN(VariationsHttpHeaderProvider); | 125 DISALLOW_COPY_AND_ASSIGN(VariationsHttpHeaderProvider); |
124 }; | 126 }; |
125 | 127 |
126 } // namespace variations | 128 } // namespace variations |
127 | 129 |
128 #endif // COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_ | 130 #endif // COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_ |
OLD | NEW |