user_metrics.cc revision dc0f95d653279beabeb9817299e2902918ba123e
1// Copyright (c) 2010 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 "chrome/common/notification_service.h" 9#include "content/browser/browser_thread.h" 10 11void UserMetrics::RecordAction(const UserMetricsAction& action, 12 Profile* profile) { 13 Record(action.str_, profile); 14} 15 16void UserMetrics::RecordComputedAction(const std::string& action, 17 Profile* profile) { 18 Record(action.c_str(), profile); 19} 20 21void UserMetrics::Record(const char *action, Profile *profile) { 22 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) { 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 46void UserMetrics::CallRecordOnUI(const std::string& action) { 47 Record(action.c_str()); 48} 49