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 <map> | |
|
Mark Mentovai
2015/04/13 17:30:00
The .h already brought in <map>, <string>, and "ba
bruthig
2015/04/13 19:21:46
Done.
| |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/bind.h" | |
| 11 #include "base/bind_helpers.h" | |
| 12 #include "base/metrics/user_metrics.h" | |
| 13 | |
| 14 namespace base { | |
| 15 | |
| 16 UserActionTester::UserActionTester() | |
| 17 : action_callback_( | |
| 18 base::Bind(&UserActionTester::OnUserAction, base::Unretained(this))) { | |
| 19 base::AddActionCallback(action_callback_); | |
| 20 } | |
| 21 | |
| 22 UserActionTester::~UserActionTester() { | |
| 23 base::RemoveActionCallback(action_callback_); | |
| 24 } | |
| 25 | |
| 26 int UserActionTester::GetActionCount(const std::string& user_action) const { | |
| 27 UserActionCountMap::const_iterator iter = count_map_.find(user_action); | |
| 28 return iter == count_map_.end() ? 0 : iter->second; | |
| 29 } | |
| 30 | |
| 31 void UserActionTester::ResetCounts() { | |
| 32 count_map_.clear(); | |
| 33 } | |
| 34 | |
| 35 void UserActionTester::OnUserAction(const std::string& user_action) { | |
| 36 ++(count_map_[user_action]); | |
| 37 } | |
| 38 | |
| 39 } // namespace base | |
| OLD | NEW |