Home | History | Annotate | Download | only in metrics
      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 
     11 void UserMetrics::RecordAction(const UserMetricsAction& action,
     12                                Profile* profile) {
     13   Record(action.str_, profile);
     14 }
     15 
     16 void UserMetrics::RecordComputedAction(const std::string& action,
     17                                        Profile* profile) {
     18   Record(action.c_str(), profile);
     19 }
     20 
     21 void UserMetrics::Record(const char *action, Profile *profile) {
     22   Record(action);
     23 }
     24 
     25 void UserMetrics::RecordAction(const UserMetricsAction& action) {
     26   Record(action.str_);
     27 }
     28 
     29 void UserMetrics::RecordComputedAction(const std::string& action) {
     30   Record(action.c_str());
     31 }
     32 
     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 
     46 void UserMetrics::CallRecordOnUI(const std::string& action) {
     47   Record(action.c_str());
     48 }
     49