| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_ | 6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/containers/hash_tables.h" |
| 12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 13 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 14 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 15 #include "components/variations/variations_associated_data.h" | 16 #include "components/variations/variations_associated_data.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 class ResourceContext; | 19 class ResourceContext; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // new variation IDs. | 81 // new variation IDs. |
| 81 void InitVariationIDsCacheIfNeeded(); | 82 void InitVariationIDsCacheIfNeeded(); |
| 82 | 83 |
| 83 // Takes whatever is currently in |variation_ids_set_| and recreates | 84 // Takes whatever is currently in |variation_ids_set_| and recreates |
| 84 // |variation_ids_header_| with it. Assumes the the |lock_| is currently | 85 // |variation_ids_header_| with it. Assumes the the |lock_| is currently |
| 85 // held. | 86 // held. |
| 86 void UpdateVariationIDsHeaderValue(); | 87 void UpdateVariationIDsHeaderValue(); |
| 87 | 88 |
| 88 // Checks whether variation headers should be appended to requests to the | 89 // Checks whether variation headers should be appended to requests to the |
| 89 // specified |url|. Returns true for google.<TLD> and youtube.<TLD> URLs. | 90 // specified |url|. Returns true for google.<TLD> and youtube.<TLD> URLs. |
| 90 static bool ShouldAppendHeaders(const GURL& url); | 91 bool ShouldAppendHeaders(const GURL& url); |
| 91 | 92 |
| 92 // Guards |variation_ids_cache_initialized_|, |variation_ids_set_| and | 93 // Guards |variation_ids_cache_initialized_|, |variation_ids_set_| and |
| 93 // |variation_ids_header_|. | 94 // |variation_ids_header_|. |
| 94 base::Lock lock_; | 95 base::Lock lock_; |
| 95 | 96 |
| 96 // Whether or not we've initialized the cache. | 97 // Whether or not we've initialized the cache. |
| 97 bool variation_ids_cache_initialized_; | 98 bool variation_ids_cache_initialized_; |
| 98 | 99 |
| 99 // Keep a cache of variation IDs that are transmitted in headers to Google. | 100 // Keep a cache of variation IDs that are transmitted in headers to Google. |
| 100 // This consists of a list of valid IDs, and the actual transmitted header. | 101 // This consists of a list of valid IDs, and the actual transmitted header. |
| 101 std::set<chrome_variations::VariationID> variation_ids_set_; | 102 std::set<chrome_variations::VariationID> variation_ids_set_; |
| 102 std::set<chrome_variations::VariationID> variation_trigger_ids_set_; | 103 std::set<chrome_variations::VariationID> variation_trigger_ids_set_; |
| 103 | 104 |
| 104 // Provides the google experiment ids forced from command line. | 105 // Provides the google experiment ids forced from command line. |
| 105 std::set<chrome_variations::VariationID> default_variation_ids_set_; | 106 std::set<chrome_variations::VariationID> default_variation_ids_set_; |
| 106 std::set<chrome_variations::VariationID> default_trigger_id_set_; | 107 std::set<chrome_variations::VariationID> default_trigger_id_set_; |
| 107 | 108 |
| 108 std::string variation_ids_header_; | 109 std::string variation_ids_header_; |
| 109 | 110 |
| 111 // Any hostname which ends with one of these suffixes will have |
| 112 // headers transmitted. |
| 113 base::hash_set<std::string> suffixes_to_set_headers_for_; |
| 114 |
| 110 DISALLOW_COPY_AND_ASSIGN(VariationsHttpHeaderProvider); | 115 DISALLOW_COPY_AND_ASSIGN(VariationsHttpHeaderProvider); |
| 111 }; | 116 }; |
| 112 | 117 |
| 113 } // namespace chrome_variations | 118 } // namespace chrome_variations |
| 114 | 119 |
| 115 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_ | 120 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_ |
| OLD | NEW |