Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: components/variations/variations_http_header_provider.cc

Issue 387393002: [Variations] Renaming ChromeVariations to ClientVariations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "components/variations/variations_http_header_provider.h" 5 #include "components/variations/variations_http_header_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "components/google/core/browser/google_util.h" 15 #include "components/google/core/browser/google_util.h"
16 #include "components/variations/proto/chrome_experiments.pb.h" 16 #include "components/variations/proto/client_variations.pb.h"
17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
18 #include "net/http/http_request_headers.h" 18 #include "net/http/http_request_headers.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 // TODO(mathp): Once the move to variations namespace is complete, remove these. 21 // TODO(mathp): Once the move to variations namespace is complete, remove these.
22 using chrome_variations::EMPTY_ID; 22 using chrome_variations::EMPTY_ID;
23 using chrome_variations::GOOGLE_WEB_PROPERTIES; 23 using chrome_variations::GOOGLE_WEB_PROPERTIES;
24 using chrome_variations::GOOGLE_WEB_PROPERTIES_TRIGGER; 24 using chrome_variations::GOOGLE_WEB_PROPERTIES_TRIGGER;
25 using chrome_variations::VariationID; 25 using chrome_variations::VariationID;
26 26
(...skipping 19 matching lines...) Expand all
46 46
47 VariationsHttpHeaderProvider* VariationsHttpHeaderProvider::GetInstance() { 47 VariationsHttpHeaderProvider* VariationsHttpHeaderProvider::GetInstance() {
48 return Singleton<VariationsHttpHeaderProvider>::get(); 48 return Singleton<VariationsHttpHeaderProvider>::get();
49 } 49 }
50 50
51 void VariationsHttpHeaderProvider::AppendHeaders( 51 void VariationsHttpHeaderProvider::AppendHeaders(
52 const GURL& url, 52 const GURL& url,
53 bool incognito, 53 bool incognito,
54 bool uma_enabled, 54 bool uma_enabled,
55 net::HttpRequestHeaders* headers) { 55 net::HttpRequestHeaders* headers) {
56 // Note the criteria for attaching Chrome experiment headers: 56 // Note the criteria for attaching client experiment headers:
57 // 1. We only transmit to Google owned domains which can evaluate experiments. 57 // 1. We only transmit to Google owned domains which can evaluate experiments.
58 // 1a. These include hosts which have a standard postfix such as: 58 // 1a. These include hosts which have a standard postfix such as:
59 // *.doubleclick.net or *.googlesyndication.com or 59 // *.doubleclick.net or *.googlesyndication.com or
60 // exactly www.googleadservices.com or 60 // exactly www.googleadservices.com or
61 // international TLD domains *.google.<TLD> or *.youtube.<TLD>. 61 // international TLD domains *.google.<TLD> or *.youtube.<TLD>.
62 // 2. Only transmit for non-Incognito profiles. 62 // 2. Only transmit for non-Incognito profiles.
63 // 3. For the X-Chrome-UMA-Enabled bit, only set it if UMA is in fact enabled 63 // 3. For the X-Chrome-UMA-Enabled bit, only set it if UMA is in fact enabled
64 // for this install of Chrome. 64 // for this install of Chrome.
65 // 4. For the X-Client-Data header, only include non-empty variation IDs. 65 // 4. For the X-Client-Data header, only include non-empty variation IDs.
66 if (incognito || !ShouldAppendHeaders(url)) 66 if (incognito || !ShouldAppendHeaders(url))
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 DCHECK_LE(total_id_count, 10U); 204 DCHECK_LE(total_id_count, 10U);
205 if (total_id_count > 20) 205 if (total_id_count > 20)
206 return; 206 return;
207 207
208 // Merge the two sets of experiment ids. 208 // Merge the two sets of experiment ids.
209 std::set<VariationID> all_variation_ids_set = default_variation_ids_set_; 209 std::set<VariationID> all_variation_ids_set = default_variation_ids_set_;
210 for (std::set<VariationID>::const_iterator it = variation_ids_set_.begin(); 210 for (std::set<VariationID>::const_iterator it = variation_ids_set_.begin();
211 it != variation_ids_set_.end(); ++it) { 211 it != variation_ids_set_.end(); ++it) {
212 all_variation_ids_set.insert(*it); 212 all_variation_ids_set.insert(*it);
213 } 213 }
214 metrics::ChromeVariations proto; 214 variations::ClientVariations proto;
Alexei Svitkine (slow) 2014/07/14 19:43:20 Nit: No need for namespace decl here.
Mathieu 2014/07/14 19:50:16 Done.
215 for (std::set<VariationID>::const_iterator it = all_variation_ids_set.begin(); 215 for (std::set<VariationID>::const_iterator it = all_variation_ids_set.begin();
216 it != all_variation_ids_set.end(); ++it) { 216 it != all_variation_ids_set.end(); ++it) {
217 proto.add_variation_id(*it); 217 proto.add_variation_id(*it);
218 } 218 }
219 219
220 std::set<VariationID> all_trigger_ids_set = default_trigger_id_set_; 220 std::set<VariationID> all_trigger_ids_set = default_trigger_id_set_;
221 for (std::set<VariationID>::const_iterator it = 221 for (std::set<VariationID>::const_iterator it =
222 variation_trigger_ids_set_.begin(); 222 variation_trigger_ids_set_.begin();
223 it != variation_trigger_ids_set_.end(); ++it) { 223 it != variation_trigger_ids_set_.end(); ++it) {
224 all_trigger_ids_set.insert(*it); 224 all_trigger_ids_set.insert(*it);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 for (size_t i = 0; i < arraysize(kSuffixesToSetHeadersFor); ++i) { 256 for (size_t i = 0; i < arraysize(kSuffixesToSetHeadersFor); ++i) {
257 if (EndsWith(host, kSuffixesToSetHeadersFor[i], false)) 257 if (EndsWith(host, kSuffixesToSetHeadersFor[i], false))
258 return true; 258 return true;
259 } 259 }
260 260
261 return google_util::IsYoutubeDomainUrl(url, google_util::ALLOW_SUBDOMAIN, 261 return google_util::IsYoutubeDomainUrl(url, google_util::ALLOW_SUBDOMAIN,
262 google_util::ALLOW_NON_STANDARD_PORTS); 262 google_util::ALLOW_NON_STANDARD_PORTS);
263 } 263 }
264 264
265 } // namespace variations 265 } // namespace variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698