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

Side by Side Diff: chrome/browser/chromeos/external_metrics.cc

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). Created 9 years 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
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/chromeos/locale_change_guard.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 16 #include <string>
17 17
18 #include "base/basictypes.h"
18 #include "base/bind.h" 19 #include "base/bind.h"
19 #include "base/basictypes.h"
20 #include "base/eintr_wrapper.h" 20 #include "base/eintr_wrapper.h"
21 #include "base/metrics/histogram.h" 21 #include "base/metrics/histogram.h"
22 #include "base/perftimer.h" 22 #include "base/perftimer.h"
23 #include "base/time.h" 23 #include "base/time.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/metrics/metrics_service.h" 25 #include "chrome/browser/metrics/metrics_service.h"
26 #include "content/browser/user_metrics.h"
27 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/user_metrics.h"
28 28
29 using content::BrowserThread; 29 using content::BrowserThread;
30 using content::UserMetricsAction;
30 31
31 namespace chromeos { 32 namespace chromeos {
32 33
33 // The interval between external metrics collections, in milliseconds. 34 // The interval between external metrics collections, in milliseconds.
34 static const int kExternalMetricsCollectionIntervalMs = 30 * 1000; 35 static const int kExternalMetricsCollectionIntervalMs = 30 * 1000;
35 36
36 ExternalMetrics::ExternalMetrics() 37 ExternalMetrics::ExternalMetrics()
37 : test_recorder_(NULL) { 38 : test_recorder_(NULL) {
38 } 39 }
39 40
(...skipping 13 matching lines...) Expand all
53 valid_user_actions_.insert("Accel_BrightnessUp_F7"); 54 valid_user_actions_.insert("Accel_BrightnessUp_F7");
54 valid_user_actions_.insert("Cryptohome.PKCS11InitFail"); 55 valid_user_actions_.insert("Cryptohome.PKCS11InitFail");
55 valid_user_actions_.insert("Updater.ServerCertificateChanged"); 56 valid_user_actions_.insert("Updater.ServerCertificateChanged");
56 valid_user_actions_.insert("Updater.ServerCertificateFailed"); 57 valid_user_actions_.insert("Updater.ServerCertificateFailed");
57 58
58 ScheduleCollector(); 59 ScheduleCollector();
59 } 60 }
60 61
61 void ExternalMetrics::RecordActionUI(std::string action_string) { 62 void ExternalMetrics::RecordActionUI(std::string action_string) {
62 if (valid_user_actions_.count(action_string)) { 63 if (valid_user_actions_.count(action_string)) {
63 UserMetrics::RecordComputedAction(action_string); 64 content::RecordComputedAction(action_string);
64 } else { 65 } else {
65 LOG(ERROR) << "undefined UMA action: " << action_string; 66 LOG(ERROR) << "undefined UMA action: " << action_string;
66 } 67 }
67 } 68 }
68 69
69 void ExternalMetrics::RecordAction(const char* action) { 70 void ExternalMetrics::RecordAction(const char* action) {
70 std::string action_string(action); 71 std::string action_string(action);
71 BrowserThread::PostTask( 72 BrowserThread::PostTask(
72 BrowserThread::UI, FROM_HERE, 73 BrowserThread::UI, FROM_HERE,
73 base::Bind(&ExternalMetrics::RecordActionUI, this, action_string)); 74 base::Bind(&ExternalMetrics::RecordActionUI, this, action_string));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void ExternalMetrics::ScheduleCollector() { 238 void ExternalMetrics::ScheduleCollector() {
238 bool result; 239 bool result;
239 result = BrowserThread::PostDelayedTask( 240 result = BrowserThread::PostDelayedTask(
240 BrowserThread::FILE, FROM_HERE, 241 BrowserThread::FILE, FROM_HERE,
241 base::Bind(&chromeos::ExternalMetrics::CollectEventsAndReschedule, this), 242 base::Bind(&chromeos::ExternalMetrics::CollectEventsAndReschedule, this),
242 kExternalMetricsCollectionIntervalMs); 243 kExternalMetricsCollectionIntervalMs);
243 DCHECK(result); 244 DCHECK(result);
244 } 245 }
245 246
246 } // namespace chromeos 247 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/chromeos/locale_change_guard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698