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

Side by Side Diff: components/rappor/rappor_service.cc

Issue 430703002: Create variations param for RapporRollout to non-UMA users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « components/rappor/rappor_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/rappor/rappor_service.h" 5 #include "components/rappor/rappor_service.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 17 matching lines...) Expand all
28 const int kLogIntervalSeconds = 30 * 60; 28 const int kLogIntervalSeconds = 30 * 60;
29 29
30 const char kMimeType[] = "application/vnd.chrome.rappor"; 30 const char kMimeType[] = "application/vnd.chrome.rappor";
31 31
32 // Constants for the RAPPOR rollout field trial. 32 // Constants for the RAPPOR rollout field trial.
33 const char kRapporRolloutFieldTrialName[] = "RapporRollout"; 33 const char kRapporRolloutFieldTrialName[] = "RapporRollout";
34 34
35 // Constant for the finch parameter name for the server URL 35 // Constant for the finch parameter name for the server URL
36 const char kRapporRolloutServerUrlParam[] = "ServerUrl"; 36 const char kRapporRolloutServerUrlParam[] = "ServerUrl";
37 37
38 // Constant for the finch parameter name for the server URL
39 const char kRapporRolloutRequireUmaParam[] = "RequireUma";
40
38 // The rappor server's URL. 41 // The rappor server's URL.
39 const char kDefaultServerUrl[] = "https://clients4.google.com/rappor"; 42 const char kDefaultServerUrl[] = "https://clients4.google.com/rappor";
40 43
41 GURL GetServerUrl() { 44 GURL GetServerUrl() {
42 std::string server_url = chrome_variations::GetVariationParamValue( 45 std::string server_url = chrome_variations::GetVariationParamValue(
43 kRapporRolloutFieldTrialName, 46 kRapporRolloutFieldTrialName,
44 kRapporRolloutServerUrlParam); 47 kRapporRolloutServerUrlParam);
45 if (!server_url.empty()) 48 if (!server_url.empty())
46 return GURL(server_url); 49 return GURL(server_url);
47 else 50 else
48 return GURL(kDefaultServerUrl); 51 return GURL(kDefaultServerUrl);
49 } 52 }
50 53
51 const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = { 54 const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = {
52 // ETLD_PLUS_ONE_RAPPOR_TYPE 55 // ETLD_PLUS_ONE_RAPPOR_TYPE
53 {128 /* Num cohorts */, 56 {128 /* Num cohorts */,
54 16 /* Bloom filter size bytes */, 57 16 /* Bloom filter size bytes */,
55 2 /* Bloom filter hash count */, 58 2 /* Bloom filter hash count */,
56 rappor::PROBABILITY_50 /* Fake data probability */, 59 rappor::PROBABILITY_50 /* Fake data probability */,
57 rappor::PROBABILITY_50 /* Fake one probability */, 60 rappor::PROBABILITY_50 /* Fake one probability */,
58 rappor::PROBABILITY_75 /* One coin probability */, 61 rappor::PROBABILITY_75 /* One coin probability */,
59 rappor::PROBABILITY_25 /* Zero coin probability */}, 62 rappor::PROBABILITY_25 /* Zero coin probability */},
60 }; 63 };
61 64
65 bool IsRapporEnabled(const GURL& server_url, bool metrics_enabled) {
Alexei Svitkine (slow) 2014/07/30 16:52:51 Can this be part of GetServerUrl() given that alre
Steven Holte 2014/08/05 03:09:36 Done.
66 if (!server_url.is_valid()) {
67 DVLOG(1) << server_url.spec() << " is invalid.";
68 return false;
69 }
70 if (metrics_enabled) {
Alexei Svitkine (slow) 2014/07/30 16:52:51 Nit: No {}'s.
Steven Holte 2014/08/05 03:09:37 Done.
71 return true;
72 }
73 return chrome_variations::GetVariationParamValue(
Alexei Svitkine (slow) 2014/07/30 16:52:51 Nit: Please rebase, this is now in namespace varia
Steven Holte 2014/08/05 03:09:37 Done.
74 kRapporRolloutFieldTrialName,
75 kRapporRolloutRequireUmaParam) == "False";
76 }
77
62 } // namespace 78 } // namespace
63 79
64 RapporService::RapporService() : cohort_(-1) {} 80 RapporService::RapporService() : cohort_(-1) {}
65 81
66 RapporService::~RapporService() { 82 RapporService::~RapporService() {
67 STLDeleteValues(&metrics_map_); 83 STLDeleteValues(&metrics_map_);
68 } 84 }
69 85
70 void RapporService::Start(PrefService* pref_service, 86 void RapporService::Start(PrefService* pref_service,
71 net::URLRequestContextGetter* request_context) { 87 net::URLRequestContextGetter* request_context,
88 bool metrics_enabled) {
72 const GURL server_url = GetServerUrl(); 89 const GURL server_url = GetServerUrl();
73 if (!server_url.is_valid()) { 90 if (!IsRapporEnabled(server_url, metrics_enabled)) {
74 DVLOG(1) << "RapporService not started: " 91 DVLOG(1) << "RapporService not started.";
75 << server_url.spec() << " is invalid.";
76 return; 92 return;
77 } 93 }
78 DVLOG(1) << "RapporService started. Reporting to " << server_url.spec(); 94 DVLOG(1) << "RapporService started. Reporting to " << server_url.spec();
79 DCHECK(!uploader_); 95 DCHECK(!uploader_);
80 LoadSecret(pref_service); 96 LoadSecret(pref_service);
81 LoadCohort(pref_service); 97 LoadCohort(pref_service);
82 uploader_.reset(new LogUploader(server_url, kMimeType, request_context)); 98 uploader_.reset(new LogUploader(server_url, kMimeType, request_context));
83 log_rotation_timer_.Start( 99 log_rotation_timer_.Start(
84 FROM_HERE, 100 FROM_HERE,
85 base::TimeDelta::FromSeconds(kInitialLogIntervalSeconds), 101 base::TimeDelta::FromSeconds(kInitialLogIntervalSeconds),
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 DCHECK_EQ(parameters.ToString(), metric->parameters().ToString()); 219 DCHECK_EQ(parameters.ToString(), metric->parameters().ToString());
204 return metric; 220 return metric;
205 } 221 }
206 222
207 RapporMetric* new_metric = new RapporMetric(metric_name, parameters, cohort_); 223 RapporMetric* new_metric = new RapporMetric(metric_name, parameters, cohort_);
208 metrics_map_[metric_name] = new_metric; 224 metrics_map_[metric_name] = new_metric;
209 return new_metric; 225 return new_metric;
210 } 226 }
211 227
212 } // namespace rappor 228 } // namespace rappor
OLDNEW
« no previous file with comments | « components/rappor/rappor_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698