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