Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / tools / ipc_fuzzer / message_lib / message_names.h
blob7ad47cc6b565fd3084c8d3f2fb2841865da1e256
1 // Copyright 2013 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.
5 #ifndef TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_
6 #define TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_
8 #include <map>
9 #include <string>
10 #include "base/basictypes.h"
11 #include "base/logging.h"
13 namespace ipc_fuzzer {
15 class MessageNames {
16 public:
17 MessageNames();
18 ~MessageNames();
19 static MessageNames* GetInstance();
21 void Add(uint32 type, const std::string& name) {
22 name_map_[type] = name;
23 type_map_[name] = type;
26 bool TypeExists(uint32 type) {
27 return name_map_.find(type) != name_map_.end();
30 bool NameExists(const std::string& name) {
31 return type_map_.find(name) != type_map_.end();
34 const std::string& TypeToName(uint32 type) {
35 TypeToNameMap::iterator it = name_map_.find(type);
36 CHECK(it != name_map_.end());
37 return it->second;
40 uint32 NameToType(const std::string& name) {
41 NameToTypeMap::iterator it = type_map_.find(name);
42 CHECK(it != type_map_.end());
43 return it->second;
46 private:
47 typedef std::map<uint32, std::string> TypeToNameMap;
48 typedef std::map<std::string, uint32> NameToTypeMap;
49 TypeToNameMap name_map_;
50 NameToTypeMap type_map_;
52 static MessageNames* all_names_;
54 DISALLOW_COPY_AND_ASSIGN(MessageNames);
57 } // namespace ipc_fuzzer
59 #endif // TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_