OLD | NEW |
---|---|
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/public/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 | 11 |
12 namespace content { | |
12 namespace { | 13 namespace { |
13 | 14 |
14 using content::BrowserThread; | |
15 using content::UserMetricsAction; | |
16 | |
17 // Forward declare because of circular dependency. | 15 // Forward declare because of circular dependency. |
18 void CallRecordOnUI(const std::string& action); | 16 void CallRecordOnUI(const std::string& action); |
19 | 17 |
20 void Record(const char *action) { | 18 void Record(const char *action) { |
21 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 19 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
22 BrowserThread::PostTask( | 20 BrowserThread::PostTask( |
23 BrowserThread::UI, | 21 BrowserThread::UI, |
24 FROM_HERE, | 22 FROM_HERE, |
25 base::Bind(&CallRecordOnUI, action)); | 23 base::Bind(&CallRecordOnUI, action)); |
26 return; | 24 return; |
27 } | 25 } |
28 | 26 |
29 content::NotificationService::current()->Notify( | 27 NotificationService::current()->Notify( |
30 content::NOTIFICATION_USER_ACTION, | 28 NOTIFICATION_USER_ACTION, |
tfarina
2012/10/30 21:59:50
I bet this fits above now.
| |
31 content::NotificationService::AllSources(), | 29 NotificationService::AllSources(), |
32 content::Details<const char*>(&action)); | 30 Details<const char*>(&action)); |
33 } | 31 } |
34 | 32 |
35 void CallRecordOnUI(const std::string& action) { | 33 void CallRecordOnUI(const std::string& action) { |
36 Record(action.c_str()); | 34 Record(action.c_str()); |
37 } | 35 } |
38 | 36 |
39 } // namespace | 37 } // namespace |
40 | 38 |
41 namespace content { | |
42 | |
43 void RecordAction(const UserMetricsAction& action) { | 39 void RecordAction(const UserMetricsAction& action) { |
44 Record(action.str_); | 40 Record(action.str_); |
45 } | 41 } |
46 | 42 |
47 void RecordComputedAction(const std::string& action) { | 43 void RecordComputedAction(const std::string& action) { |
48 Record(action.c_str()); | 44 Record(action.c_str()); |
49 } | 45 } |
50 | 46 |
51 } // namespace content | 47 } // namespace content |
OLD | NEW |