Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: content/browser/user_metrics.cc

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to content namespace. Update usages. Update extract_actions tool. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/user_metrics.h" 5 #include "content/public/browser/user_metrics.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_types.h" 10 #include "content/public/browser/notification_types.h"
11 #include "content/public/browser/user_metrics.h"
jam 2011/12/14 01:18:38 nit: redundant
12
13 namespace {
11 14
12 using content::BrowserThread; 15 using content::BrowserThread;
16 using content::UserMetricsAction;
13 17
14 void UserMetrics::RecordAction(const UserMetricsAction& action) { 18 // Forward declare because of circular dependency.
15 Record(action.str_); 19 void CallRecordOnUI(const std::string& action);
16 }
17 20
18 void UserMetrics::RecordComputedAction(const std::string& action) { 21 void Record(const char *action) {
19 Record(action.c_str());
20 }
21
22 void UserMetrics::Record(const char *action) {
23 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 22 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
24 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 23 BrowserThread::PostTask(
25 base::Bind(&UserMetrics::CallRecordOnUI, action)); 24 BrowserThread::UI,
25 FROM_HERE,
26 base::Bind(&CallRecordOnUI, action));
26 return; 27 return;
27 } 28 }
28 29
29 content::NotificationService::current()->Notify( 30 content::NotificationService::current()->Notify(
30 content::NOTIFICATION_USER_ACTION, 31 content::NOTIFICATION_USER_ACTION,
31 content::NotificationService::AllSources(), 32 content::NotificationService::AllSources(),
32 content::Details<const char*>(&action)); 33 content::Details<const char*>(&action));
33 } 34 }
34 35
35 void UserMetrics::CallRecordOnUI(const std::string& action) { 36 void CallRecordOnUI(const std::string& action) {
36 Record(action.c_str()); 37 Record(action.c_str());
37 } 38 }
39
40 } // namespace
41
42 namespace content {
43
44 void RecordAction(const UserMetricsAction& action) {
45 Record(action.str_);
46 }
47
48 void RecordComputedAction(const std::string& action) {
49 Record(action.c_str());
50 }
51
52 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698