[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / content / browser / user_metrics.cc
blob927f3977d6b589f3363ca1c3d9b4a594d48c36ff
1 // Copyright (c) 2011 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.
5 #include "content/public/browser/user_metrics.h"
7 #include "base/bind.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_types.h"
12 namespace content {
13 namespace {
15 // Forward declare because of circular dependency.
16 void CallRecordOnUI(const std::string& action);
18 void Record(const char *action) {
19 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
20 BrowserThread::PostTask(
21 BrowserThread::UI,
22 FROM_HERE,
23 base::Bind(&CallRecordOnUI, action));
24 return;
27 NotificationService::current()->Notify(
28 NOTIFICATION_USER_ACTION,
29 NotificationService::AllSources(),
30 Details<const char*>(&action));
33 void CallRecordOnUI(const std::string& action) {
34 Record(action.c_str());
37 } // namespace
39 void RecordAction(const UserMetricsAction& action) {
40 Record(action.str_);
43 void RecordComputedAction(const std::string& action) {
44 Record(action.c_str());
47 } // namespace content