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" |
11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
| 12 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/metrics/metrics_service.h" | 13 #include "chrome/browser/metrics/metrics_service.h" |
13 #include "chrome/common/extensions/api/metrics_private.h" | 14 #include "chrome/common/extensions/api/metrics_private.h" |
14 #include "components/variations/variations_associated_data.h" | 15 #include "components/variations/variations_associated_data.h" |
15 #include "content/public/browser/user_metrics.h" | 16 #include "content/public/browser/user_metrics.h" |
16 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
20 namespace GetIsCrashReportingEnabled = | 21 namespace GetIsCrashReportingEnabled = |
21 api::metrics_private::GetIsCrashReportingEnabled; | 22 api::metrics_private::GetIsCrashReportingEnabled; |
(...skipping 11 matching lines...) Expand all Loading... |
33 namespace RecordLongTime = api::metrics_private::RecordLongTime; | 34 namespace RecordLongTime = api::metrics_private::RecordLongTime; |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 const size_t kMaxBuckets = 10000; // We don't ever want more than these many | 38 const size_t kMaxBuckets = 10000; // We don't ever want more than these many |
38 // buckets; there is no real need for them | 39 // buckets; there is no real need for them |
39 // and would cause crazy memory usage | 40 // and would cause crazy memory usage |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 bool MetricsPrivateGetIsCrashReportingEnabledFunction::RunSync() { | 43 bool MetricsPrivateGetIsCrashReportingEnabledFunction::RunSync() { |
43 SetResult(new base::FundamentalValue( | 44 SetResult( |
44 MetricsServiceHelper::IsCrashReportingEnabled())); | 45 new base::FundamentalValue(MetricsServiceHelper::IsCrashReportingEnabled( |
| 46 g_browser_process->local_state()))); |
45 return true; | 47 return true; |
46 } | 48 } |
47 | 49 |
48 bool MetricsPrivateGetFieldTrialFunction::RunSync() { | 50 bool MetricsPrivateGetFieldTrialFunction::RunSync() { |
49 std::string name; | 51 std::string name; |
50 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &name)); | 52 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &name)); |
51 | 53 |
52 SetResult(new base::StringValue(base::FieldTrialList::FindFullName(name))); | 54 SetResult(new base::StringValue(base::FieldTrialList::FindFullName(name))); |
53 return true; | 55 return true; |
54 } | 56 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool MetricsPrivateRecordLongTimeFunction::RunSync() { | 192 bool MetricsPrivateRecordLongTimeFunction::RunSync() { |
191 scoped_ptr<RecordLongTime::Params> params( | 193 scoped_ptr<RecordLongTime::Params> params( |
192 RecordLongTime::Params::Create(*args_)); | 194 RecordLongTime::Params::Create(*args_)); |
193 EXTENSION_FUNCTION_VALIDATE(params.get()); | 195 EXTENSION_FUNCTION_VALIDATE(params.get()); |
194 static const int kOneHourMs = 60 * 60 * 1000; | 196 static const int kOneHourMs = 60 * 60 * 1000; |
195 return RecordValue(params->metric_name, base::HISTOGRAM, | 197 return RecordValue(params->metric_name, base::HISTOGRAM, |
196 1, kOneHourMs, 50, params->value); | 198 1, kOneHourMs, 50, params->value); |
197 } | 199 } |
198 | 200 |
199 } // namespace extensions | 201 } // namespace extensions |
OLD | NEW |