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

Unified Diff: base/metrics/user_metrics.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/user_metrics.h ('k') | base/metrics/user_metrics_action.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/user_metrics.cc
diff --git a/base/metrics/user_metrics.cc b/base/metrics/user_metrics.cc
deleted file mode 100644
index 9db5840ab57052746537bb223a8f6445735d53d9..0000000000000000000000000000000000000000
--- a/base/metrics/user_metrics.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/metrics/user_metrics.h"
-
-#include <vector>
-
-#include "base/lazy_instance.h"
-#include "base/threading/thread_checker.h"
-
-namespace base {
-namespace {
-
-// A helper class for tracking callbacks and ensuring thread-safety.
-class Callbacks {
- public:
- Callbacks() {}
-
- // Records the |action|.
- void Record(const std::string& action) {
- DCHECK(thread_checker_.CalledOnValidThread());
- for (size_t i = 0; i < callbacks_.size(); ++i) {
- callbacks_[i].Run(action);
- }
- }
-
- // Adds |callback| to the list of |callbacks_|.
- void AddCallback(const ActionCallback& callback) {
- DCHECK(thread_checker_.CalledOnValidThread());
- callbacks_.push_back(callback);
- }
-
- // Removes the first instance of |callback| from the list of |callbacks_|, if
- // there is one.
- void RemoveCallback(const ActionCallback& callback) {
- DCHECK(thread_checker_.CalledOnValidThread());
- for (size_t i = 0; i < callbacks_.size(); ++i) {
- if (callbacks_[i].Equals(callback)) {
- callbacks_.erase(callbacks_.begin() + i);
- return;
- }
- }
- }
-
- private:
- base::ThreadChecker thread_checker_;
- std::vector<ActionCallback> callbacks_;
-
- DISALLOW_COPY_AND_ASSIGN(Callbacks);
-};
-
-base::LazyInstance<Callbacks> g_callbacks = LAZY_INSTANCE_INITIALIZER;
-
-} // namespace
-
-void RecordAction(const UserMetricsAction& action) {
- g_callbacks.Get().Record(action.str_);
-}
-
-void RecordComputedAction(const std::string& action) {
- g_callbacks.Get().Record(action);
-}
-
-void AddActionCallback(const ActionCallback& callback) {
- g_callbacks.Get().AddCallback(callback);
-}
-
-void RemoveActionCallback(const ActionCallback& callback) {
- g_callbacks.Get().RemoveCallback(callback);
-
-}
-
-} // namespace base
« no previous file with comments | « base/metrics/user_metrics.h ('k') | base/metrics/user_metrics_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698