Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/test/user_action_tester.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/bind_helpers.h" | |
| 9 #include "base/metrics/user_metrics.h" | |
|
Mark Mentovai
2015/04/13 20:08:37
Me too.
| |
| 10 | |
| 11 namespace base { | |
| 12 | |
| 13 UserActionTester::UserActionTester() | |
| 14 : action_callback_( | |
| 15 base::Bind(&UserActionTester::OnUserAction, base::Unretained(this))) { | |
| 16 base::AddActionCallback(action_callback_); | |
| 17 } | |
| 18 | |
| 19 UserActionTester::~UserActionTester() { | |
| 20 base::RemoveActionCallback(action_callback_); | |
| 21 } | |
| 22 | |
| 23 int UserActionTester::GetActionCount(const std::string& user_action) const { | |
| 24 UserActionCountMap::const_iterator iter = count_map_.find(user_action); | |
| 25 return iter == count_map_.end() ? 0 : iter->second; | |
| 26 } | |
| 27 | |
| 28 void UserActionTester::ResetCounts() { | |
| 29 count_map_.clear(); | |
| 30 } | |
| 31 | |
| 32 void UserActionTester::OnUserAction(const std::string& user_action) { | |
| 33 ++(count_map_[user_action]); | |
| 34 } | |
| 35 | |
| 36 } // namespace base | |
| OLD | NEW |