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

Side by Side Diff: chrome/browser/extensions/api/metrics_private/metrics_private_api.cc

Issue 22382006: Use experimentation framework parameters for location sensitivity (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/extensions/api/metrics_private/metrics_private_api.h" 5 #include "chrome/browser/extensions/api/metrics_private/metrics_private_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/common/extensions/api/metrics_private.h" 13 #include "chrome/common/extensions/api/metrics_private.h"
14 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/common/metrics/variations/variations_associated_data.h"
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "content/public/browser/user_metrics.h" 17 #include "content/public/browser/user_metrics.h"
17 18
18 #if defined(OS_CHROMEOS) 19 #if defined(OS_CHROMEOS)
19 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
20 #endif // OS_CHROMEOS 21 #endif // OS_CHROMEOS
21 22
22 namespace extensions { 23 namespace extensions {
23 24
24 namespace GetIsCrashReportingEnabled = 25 namespace GetIsCrashReportingEnabled =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 70 }
70 71
71 bool MetricsPrivateGetFieldTrialFunction::RunImpl() { 72 bool MetricsPrivateGetFieldTrialFunction::RunImpl() {
72 std::string name; 73 std::string name;
73 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &name)); 74 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &name));
74 75
75 SetResult(new base::StringValue(base::FieldTrialList::FindFullName(name))); 76 SetResult(new base::StringValue(base::FieldTrialList::FindFullName(name)));
76 return true; 77 return true;
77 } 78 }
78 79
80 bool MetricsPrivateGetVariationParamsFunction::RunImpl() {
81 std::string name;
82 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &name));
not at google - send to devlin 2013/08/09 18:09:22 prefer using generated code here even if it's simp
vadimt 2013/08/09 19:30:19 Done.
83
84 std::map<std::string, std::string> params;
85 if (chrome_variations::GetVariationParams(name, &params)) {
not at google - send to devlin 2013/08/09 18:09:22 early return here, and set an error message on fai
vadimt 2013/08/09 19:30:19 Done.
86 scoped_ptr<DictionaryValue> settings(new DictionaryValue());
87
88 for (std::map<std::string, std::string>::const_iterator it = params.begin();
89 it != params.end();
90 ++it ) {
91 settings->SetWithoutPathExpansion(
not at google - send to devlin 2013/08/09 18:09:22 SetStringWithoutPathExpansion
vadimt 2013/08/09 19:30:19 Done.
92 it->first, new base::StringValue(it->second));
93 }
94
95 SetResult(settings.release());
96 return true;
97 } else {
98 return false;
99 }
100 }
101
79 bool MetricsPrivateRecordUserActionFunction::RunImpl() { 102 bool MetricsPrivateRecordUserActionFunction::RunImpl() {
80 scoped_ptr<RecordUserAction::Params> params( 103 scoped_ptr<RecordUserAction::Params> params(
81 RecordUserAction::Params::Create(*args_)); 104 RecordUserAction::Params::Create(*args_));
82 EXTENSION_FUNCTION_VALIDATE(params.get()); 105 EXTENSION_FUNCTION_VALIDATE(params.get());
83 106
84 content::RecordComputedAction(params->name); 107 content::RecordComputedAction(params->name);
85 return true; 108 return true;
86 } 109 }
87 110
88 bool MetricsHistogramHelperFunction::GetNameAndSample(std::string* name, 111 bool MetricsHistogramHelperFunction::GetNameAndSample(std::string* name,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 bool MetricsPrivateRecordLongTimeFunction::RunImpl() { 214 bool MetricsPrivateRecordLongTimeFunction::RunImpl() {
192 scoped_ptr<RecordLongTime::Params> params( 215 scoped_ptr<RecordLongTime::Params> params(
193 RecordLongTime::Params::Create(*args_)); 216 RecordLongTime::Params::Create(*args_));
194 EXTENSION_FUNCTION_VALIDATE(params.get()); 217 EXTENSION_FUNCTION_VALIDATE(params.get());
195 static const int kOneHourMs = 60 * 60 * 1000; 218 static const int kOneHourMs = 60 * 60 * 1000;
196 return RecordValue(params->metric_name, base::HISTOGRAM, 219 return RecordValue(params->metric_name, base::HISTOGRAM,
197 1, kOneHourMs, 50, params->value); 220 1, kOneHourMs, 50, params->value);
198 } 221 }
199 222
200 } // namespace extensions 223 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698