| 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/chromeos/external_metrics.h" | 5 #include "chrome/browser/chromeos/external_metrics.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 #include <sys/file.h> | 11 #include <sys/file.h> |
| 12 #include <sys/stat.h> | 12 #include <sys/stat.h> |
| 13 #include <sys/types.h> | 13 #include <sys/types.h> |
| 14 #include <unistd.h> | 14 #include <unistd.h> |
| 15 | 15 |
| 16 #include <map> | 16 #include <map> |
| 17 #include <string> | 17 #include <string> |
| 18 | 18 |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "base/bind.h" | 20 #include "base/bind.h" |
| 21 #include "base/file_util.h" | 21 #include "base/file_util.h" |
| 22 #include "base/files/file_path.h" | 22 #include "base/files/file_path.h" |
| 23 #include "base/metrics/field_trial.h" |
| 23 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
| 24 #include "base/metrics/sparse_histogram.h" | 25 #include "base/metrics/sparse_histogram.h" |
| 25 #include "base/metrics/statistics_recorder.h" | 26 #include "base/metrics/statistics_recorder.h" |
| 26 #include "base/posix/eintr_wrapper.h" | 27 #include "base/posix/eintr_wrapper.h" |
| 27 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
| 28 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 29 #include "base/timer/elapsed_timer.h" | 30 #include "base/timer/elapsed_timer.h" |
| 30 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
| 31 #include "chrome/browser/metrics/metrics_service.h" | 32 #include "chrome/browser/metrics/chromeos_metrics_provider.h" |
| 32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
| 34 | 35 |
| 35 using base::UserMetricsAction; | 36 using base::UserMetricsAction; |
| 36 using content::BrowserThread; | 37 using content::BrowserThread; |
| 37 | 38 |
| 38 namespace chromeos { | 39 namespace chromeos { |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 143 } |
| 143 | 144 |
| 144 void ExternalMetrics::RecordAction(const char* action) { | 145 void ExternalMetrics::RecordAction(const char* action) { |
| 145 std::string action_string(action); | 146 std::string action_string(action); |
| 146 BrowserThread::PostTask( | 147 BrowserThread::PostTask( |
| 147 BrowserThread::UI, FROM_HERE, | 148 BrowserThread::UI, FROM_HERE, |
| 148 base::Bind(&ExternalMetrics::RecordActionUI, this, action_string)); | 149 base::Bind(&ExternalMetrics::RecordActionUI, this, action_string)); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void ExternalMetrics::RecordCrashUI(const std::string& crash_kind) { | 152 void ExternalMetrics::RecordCrashUI(const std::string& crash_kind) { |
| 152 if (g_browser_process && g_browser_process->metrics_service()) { | 153 // TODO(blundell): Rename to LogCrash. |
| 153 g_browser_process->metrics_service()->LogChromeOSCrash(crash_kind); | 154 ChromeOSMetricsProvider::LogChromeOSCrash(crash_kind); |
| 154 } | |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ExternalMetrics::RecordCrash(const std::string& crash_kind) { | 157 void ExternalMetrics::RecordCrash(const std::string& crash_kind) { |
| 158 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
| 159 BrowserThread::UI, FROM_HERE, | 159 BrowserThread::UI, FROM_HERE, |
| 160 base::Bind(&ExternalMetrics::RecordCrashUI, this, crash_kind)); | 160 base::Bind(&ExternalMetrics::RecordCrashUI, this, crash_kind)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ExternalMetrics::RecordHistogram(const char* histogram_data) { | 163 void ExternalMetrics::RecordHistogram(const char* histogram_data) { |
| 164 int sample, min, max, nbuckets; | 164 int sample, min, max, nbuckets; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 void ExternalMetrics::SetupFieldTrialsOnFileThread() { | 352 void ExternalMetrics::SetupFieldTrialsOnFileThread() { |
| 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 354 // Field trials that do not read from files can be initialized in | 354 // Field trials that do not read from files can be initialized in |
| 355 // ExternalMetrics::Start() above. | 355 // ExternalMetrics::Start() above. |
| 356 SetupProgressiveScanFieldTrial(); | 356 SetupProgressiveScanFieldTrial(); |
| 357 | 357 |
| 358 ScheduleCollector(); | 358 ScheduleCollector(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace chromeos | 361 } // namespace chromeos |
| OLD | NEW |