• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/metrics/user_metrics.h"
6 
7 #include "chrome/browser/profiles/profile.h"
8 #include "content/browser/browser_thread.h"
9 #include "content/common/notification_service.h"
10 
RecordAction(const UserMetricsAction & action,Profile * profile)11 void UserMetrics::RecordAction(const UserMetricsAction& action,
12                                Profile* profile) {
13   Record(action.str_, profile);
14 }
15 
RecordComputedAction(const std::string & action,Profile * profile)16 void UserMetrics::RecordComputedAction(const std::string& action,
17                                        Profile* profile) {
18   Record(action.c_str(), profile);
19 }
20 
Record(const char * action,Profile * profile)21 void UserMetrics::Record(const char *action, Profile *profile) {
22   Record(action);
23 }
24 
RecordAction(const UserMetricsAction & action)25 void UserMetrics::RecordAction(const UserMetricsAction& action) {
26   Record(action.str_);
27 }
28 
RecordComputedAction(const std::string & action)29 void UserMetrics::RecordComputedAction(const std::string& action) {
30   Record(action.c_str());
31 }
32 
Record(const char * action)33 void UserMetrics::Record(const char *action) {
34   if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
35     BrowserThread::PostTask(
36         BrowserThread::UI, FROM_HERE,
37         NewRunnableFunction(&UserMetrics::CallRecordOnUI, action));
38     return;
39   }
40 
41   NotificationService::current()->Notify(NotificationType::USER_ACTION,
42                                          NotificationService::AllSources(),
43                                          Details<const char*>(&action));
44 }
45 
CallRecordOnUI(const std::string & action)46 void UserMetrics::CallRecordOnUI(const std::string& action) {
47   Record(action.c_str());
48 }
49