[email protected] | 70934f6 | 2010-11-30 10:43:10 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | cd1adc2 | 2009-01-16 01:29:22 | [diff] [blame] | 5 | #include "chrome/browser/metrics/user_metrics.h" |
[email protected] | ca59d8a | 2010-12-23 01:22:04 | [diff] [blame^] | 6 | |
| 7 | #include "chrome/browser/browser_thread.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 8 | #include "chrome/browser/profiles/profile.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 9 | #include "chrome/common/notification_service.h" |
| 10 | |
[email protected] | 89622004 | 2010-03-23 18:14:28 | [diff] [blame] | 11 | void UserMetrics::RecordAction(const UserMetricsAction& action, |
| 12 | Profile* profile) { |
| 13 | Record(action.str_, profile); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 14 | } |
| 15 | |
[email protected] | afe3a167 | 2009-11-17 19:04:12 | [diff] [blame] | 16 | void UserMetrics::RecordComputedAction(const std::string& action, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 17 | Profile* profile) { |
[email protected] | 89622004 | 2010-03-23 18:14:28 | [diff] [blame] | 18 | Record(action.c_str(), profile); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 19 | } |
[email protected] | 89622004 | 2010-03-23 18:14:28 | [diff] [blame] | 20 | |
| 21 | void UserMetrics::Record(const char *action, Profile *profile) { |
[email protected] | 29cf1677 | 2010-04-21 15:13:47 | [diff] [blame] | 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) { |
[email protected] | ca59d8a | 2010-12-23 01:22:04 | [diff] [blame^] | 34 | if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 35 | BrowserThread::PostTask( |
| 36 | BrowserThread::UI, FROM_HERE, |
| 37 | NewRunnableFunction(&UserMetrics::CallRecordOnUI, action)); |
| 38 | return; |
| 39 | } |
| 40 | |
[email protected] | 89622004 | 2010-03-23 18:14:28 | [diff] [blame] | 41 | NotificationService::current()->Notify(NotificationType::USER_ACTION, |
[email protected] | 29cf1677 | 2010-04-21 15:13:47 | [diff] [blame] | 42 | NotificationService::AllSources(), |
[email protected] | 89622004 | 2010-03-23 18:14:28 | [diff] [blame] | 43 | Details<const char*>(&action)); |
| 44 | } |
| 45 | |
[email protected] | ca59d8a | 2010-12-23 01:22:04 | [diff] [blame^] | 46 | void UserMetrics::CallRecordOnUI(const std::string& action) { |
| 47 | Record(action.c_str()); |
| 48 | } |