diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-23 01:22:04 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-23 01:22:04 +0000 |
commit | ca59d8a58b9452331aa8e1a2d5152c62604d5711 (patch) | |
tree | 9f5551d6d10dc56b140a5e765844ebe368a1fa36 /chrome/browser | |
parent | 481be489436ba5329a247923c02a33ad2e67c2a5 (diff) | |
download | chromium_src-ca59d8a58b9452331aa8e1a2d5152c62604d5711.zip chromium_src-ca59d8a58b9452331aa8e1a2d5152c62604d5711.tar.gz chromium_src-ca59d8a58b9452331aa8e1a2d5152c62604d5711.tar.bz2 |
Allow calling UserMetrics function from any thread.
Review URL: http://codereview.chromium.org/6049003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70016 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/metrics/user_metrics.cc | 14 | ||||
-rw-r--r-- | chrome/browser/metrics/user_metrics.h | 1 |
2 files changed, 13 insertions, 2 deletions
diff --git a/chrome/browser/metrics/user_metrics.cc b/chrome/browser/metrics/user_metrics.cc index 848ab4b..e0b719d 100644 --- a/chrome/browser/metrics/user_metrics.cc +++ b/chrome/browser/metrics/user_metrics.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "chrome/browser/metrics/user_metrics.h" + +#include "chrome/browser/browser_thread.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/notification_service.h" @@ -29,10 +31,18 @@ void UserMetrics::RecordComputedAction(const std::string& action) { } 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()); +} diff --git a/chrome/browser/metrics/user_metrics.h b/chrome/browser/metrics/user_metrics.h index e9addb6..1c992ac 100644 --- a/chrome/browser/metrics/user_metrics.h +++ b/chrome/browser/metrics/user_metrics.h @@ -61,6 +61,7 @@ class UserMetrics { private: static void Record(const char *action, Profile *profile); static void Record(const char *action); + static void CallRecordOnUI(const std::string& action); }; #endif // CHROME_BROWSER_METRICS_USER_METRICS_H_ |