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

Side by Side Diff: base/test/user_action_tester.cc

Issue 1859213002: Move the thread hop for UMA user actions from content:: to base::. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initializing in content. Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/test/user_action_tester.h" 5 #include "base/test/user_action_tester.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/test/test_simple_task_runner.h"
9 10
10 namespace base { 11 namespace base {
11 12
12 UserActionTester::UserActionTester() 13 UserActionTester::UserActionTester()
13 : action_callback_( 14 : task_runner_(new base::TestSimpleTaskRunner),
15 action_callback_(
14 base::Bind(&UserActionTester::OnUserAction, base::Unretained(this))) { 16 base::Bind(&UserActionTester::OnUserAction, base::Unretained(this))) {
17 base::SetRecordActionTaskRunner(task_runner_);
15 base::AddActionCallback(action_callback_); 18 base::AddActionCallback(action_callback_);
16 } 19 }
17 20
18 UserActionTester::~UserActionTester() { 21 UserActionTester::~UserActionTester() {
19 base::RemoveActionCallback(action_callback_); 22 base::RemoveActionCallback(action_callback_);
20 } 23 }
21 24
22 int UserActionTester::GetActionCount(const std::string& user_action) const { 25 int UserActionTester::GetActionCount(const std::string& user_action) const {
23 UserActionCountMap::const_iterator iter = count_map_.find(user_action); 26 UserActionCountMap::const_iterator iter = count_map_.find(user_action);
24 return iter == count_map_.end() ? 0 : iter->second; 27 return iter == count_map_.end() ? 0 : iter->second;
25 } 28 }
26 29
27 void UserActionTester::ResetCounts() { 30 void UserActionTester::ResetCounts() {
28 count_map_.clear(); 31 count_map_.clear();
29 } 32 }
30 33
31 void UserActionTester::OnUserAction(const std::string& user_action) { 34 void UserActionTester::OnUserAction(const std::string& user_action) {
32 ++(count_map_[user_action]); 35 ++(count_map_[user_action]);
33 } 36 }
34 37
35 } // namespace base 38 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698