blob: e0b719d2692c552077fcf3da0e00f9b6c34129fb [file] [log] [blame]
[email protected]70934f62010-11-30 10:43:101// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]cd1adc22009-01-16 01:29:225#include "chrome/browser/metrics/user_metrics.h"
[email protected]ca59d8a2010-12-23 01:22:046
7#include "chrome/browser/browser_thread.h"
[email protected]8ecad5e2010-12-02 21:18:338#include "chrome/browser/profiles/profile.h"
initial.commit09911bf2008-07-26 23:55:299#include "chrome/common/notification_service.h"
10
[email protected]896220042010-03-23 18:14:2811void UserMetrics::RecordAction(const UserMetricsAction& action,
12 Profile* profile) {
13 Record(action.str_, profile);
initial.commit09911bf2008-07-26 23:55:2914}
15
[email protected]afe3a1672009-11-17 19:04:1216void UserMetrics::RecordComputedAction(const std::string& action,
initial.commit09911bf2008-07-26 23:55:2917 Profile* profile) {
[email protected]896220042010-03-23 18:14:2818 Record(action.c_str(), profile);
initial.commit09911bf2008-07-26 23:55:2919}
[email protected]896220042010-03-23 18:14:2820
21void UserMetrics::Record(const char *action, Profile *profile) {
[email protected]29cf16772010-04-21 15:13:4722 Record(action);
23}
24
25void UserMetrics::RecordAction(const UserMetricsAction& action) {
26 Record(action.str_);
27}
28
29void UserMetrics::RecordComputedAction(const std::string& action) {
30 Record(action.c_str());
31}
32
33void UserMetrics::Record(const char *action) {
[email protected]ca59d8a2010-12-23 01:22:0434 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
35 BrowserThread::PostTask(
36 BrowserThread::UI, FROM_HERE,
37 NewRunnableFunction(&UserMetrics::CallRecordOnUI, action));
38 return;
39 }
40
[email protected]896220042010-03-23 18:14:2841 NotificationService::current()->Notify(NotificationType::USER_ACTION,
[email protected]29cf16772010-04-21 15:13:4742 NotificationService::AllSources(),
[email protected]896220042010-03-23 18:14:2843 Details<const char*>(&action));
44}
45
[email protected]ca59d8a2010-12-23 01:22:0446void UserMetrics::CallRecordOnUI(const std::string& action) {
47 Record(action.c_str());
48}