Chromium Code Reviews| Index: content/browser/user_metrics.cc |
| diff --git a/content/browser/user_metrics.cc b/content/browser/user_metrics.cc |
| index 927f3977d6b589f3363ca1c3d9b4a594d48c36ff..134e0517241d2091fc9c201cdbef2bb663234938 100644 |
| --- a/content/browser/user_metrics.cc |
| +++ b/content/browser/user_metrics.cc |
| @@ -4,14 +4,18 @@ |
| #include "content/public/browser/user_metrics.h" |
| +#include <vector> |
| + |
| #include "base/bind.h" |
| +#include "base/lazy_instance.h" |
| #include "content/public/browser/browser_thread.h" |
| -#include "content/public/browser/notification_service.h" |
| -#include "content/public/browser/notification_types.h" |
| namespace content { |
| namespace { |
| +base::LazyInstance<std::vector<ActionCallback> > g_action_callbacks = |
| + LAZY_INSTANCE_INITIALIZER; |
| + |
| // Forward declare because of circular dependency. |
| void CallRecordOnUI(const std::string& action); |
| @@ -24,10 +28,12 @@ void Record(const char *action) { |
| return; |
| } |
| - NotificationService::current()->Notify( |
| - NOTIFICATION_USER_ACTION, |
| - NotificationService::AllSources(), |
| - Details<const char*>(&action)); |
| + for (std::vector<ActionCallback>::iterator i = |
|
jam
2013/01/30 17:53:24
nit: size_t is more readable for vectors
Paweł Hajdan Jr.
2013/01/31 14:34:44
Done.
|
| + g_action_callbacks.Get().begin(); |
| + i != g_action_callbacks.Get().end(); |
| + ++i) { |
| + (*i).Run(action); |
| + } |
| } |
| void CallRecordOnUI(const std::string& action) { |
| @@ -44,4 +50,19 @@ void RecordComputedAction(const std::string& action) { |
| Record(action.c_str()); |
| } |
| +void AddActionCallback(const ActionCallback& callback) { |
| + g_action_callbacks.Get().push_back(callback); |
| +} |
| + |
| +void RemoveActionCallback(const ActionCallback& callback) { |
| + for (std::vector<ActionCallback>::iterator i = |
| + g_action_callbacks.Get().begin(); |
| + i != g_action_callbacks.Get().end(); |
| + ++i) { |
| + if ((*i).Equals(callback)) { |
| + i = g_action_callbacks.Get().erase(i); |
| + } |
| + } |
| +} |
| + |
| } // namespace content |