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 #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" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 SetResult(new base::StringValue(base::FieldTrialList::FindFullName(name))); | 52 SetResult(new base::StringValue(base::FieldTrialList::FindFullName(name))); |
53 return true; | 53 return true; |
54 } | 54 } |
55 | 55 |
56 bool MetricsPrivateGetVariationParamsFunction::RunSync() { | 56 bool MetricsPrivateGetVariationParamsFunction::RunSync() { |
57 scoped_ptr<GetVariationParams::Params> params( | 57 scoped_ptr<GetVariationParams::Params> params( |
58 GetVariationParams::Params::Create(*args_)); | 58 GetVariationParams::Params::Create(*args_)); |
59 EXTENSION_FUNCTION_VALIDATE(params.get()); | 59 EXTENSION_FUNCTION_VALIDATE(params.get()); |
60 | 60 |
61 GetVariationParams::Results::Params result; | 61 GetVariationParams::Results::Params result; |
62 if (!chrome_variations::GetVariationParams( | 62 if (chrome_variations::GetVariationParams( |
63 params->name, &result.additional_properties)) { | 63 params->name, &result.additional_properties)) { |
64 SetError("Variation parameters are unavailable."); | 64 SetResult(result.ToValue().release()); |
65 return false; | |
66 } | 65 } |
67 | |
68 SetResult(result.ToValue().release()); | |
69 return true; | 66 return true; |
70 } | 67 } |
71 | 68 |
72 bool MetricsPrivateRecordUserActionFunction::RunSync() { | 69 bool MetricsPrivateRecordUserActionFunction::RunSync() { |
73 scoped_ptr<RecordUserAction::Params> params( | 70 scoped_ptr<RecordUserAction::Params> params( |
74 RecordUserAction::Params::Create(*args_)); | 71 RecordUserAction::Params::Create(*args_)); |
75 EXTENSION_FUNCTION_VALIDATE(params.get()); | 72 EXTENSION_FUNCTION_VALIDATE(params.get()); |
76 | 73 |
77 content::RecordComputedAction(params->name); | 74 content::RecordComputedAction(params->name); |
78 return true; | 75 return true; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool MetricsPrivateRecordLongTimeFunction::RunSync() { | 187 bool MetricsPrivateRecordLongTimeFunction::RunSync() { |
191 scoped_ptr<RecordLongTime::Params> params( | 188 scoped_ptr<RecordLongTime::Params> params( |
192 RecordLongTime::Params::Create(*args_)); | 189 RecordLongTime::Params::Create(*args_)); |
193 EXTENSION_FUNCTION_VALIDATE(params.get()); | 190 EXTENSION_FUNCTION_VALIDATE(params.get()); |
194 static const int kOneHourMs = 60 * 60 * 1000; | 191 static const int kOneHourMs = 60 * 60 * 1000; |
195 return RecordValue(params->metric_name, base::HISTOGRAM, | 192 return RecordValue(params->metric_name, base::HISTOGRAM, |
196 1, kOneHourMs, 50, params->value); | 193 1, kOneHourMs, 50, params->value); |
197 } | 194 } |
198 | 195 |
199 } // namespace extensions | 196 } // namespace extensions |
OLD | NEW |