summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/user_metrics.cc
blob: ec71601ddd71fa74f211d98a323fcc51a3075120 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/metrics/user_metrics.h"

#include "chrome/browser/profiles/profile.h"
#include "chrome/common/notification_service.h"
#include "content/browser/browser_thread.h"

void UserMetrics::RecordAction(const UserMetricsAction& action,
                               Profile* profile) {
  Record(action.str_, profile);
}

void UserMetrics::RecordComputedAction(const std::string& action,
                                       Profile* profile) {
  Record(action.c_str(), profile);
}

void UserMetrics::Record(const char *action, Profile *profile) {
  Record(action);
}

void UserMetrics::RecordAction(const UserMetricsAction& action) {
  Record(action.str_);
}

void UserMetrics::RecordComputedAction(const std::string& action) {
  Record(action.c_str());
}

void UserMetrics::Record(const char *action) {
  if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
    BrowserThread::PostTask(
        BrowserThread::UI, FROM_HERE,
        NewRunnableFunction(&UserMetrics::CallRecordOnUI, action));
    return;
  }

  NotificationService::current()->Notify(NotificationType::USER_ACTION,
                                         NotificationService::AllSources(),
                                         Details<const char*>(&action));
}

void UserMetrics::CallRecordOnUI(const std::string& action) {
  Record(action.c_str());
}