OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_ | 5 #ifndef TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_ |
6 #define TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_ | 6 #define TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <unordered_map> | 11 #include <unordered_map> |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 | 14 |
15 namespace ipc_fuzzer { | 15 namespace ipc_fuzzer { |
16 | 16 |
17 class MessageNames { | 17 class MessageNames { |
18 public: | 18 public: |
19 MessageNames(); | 19 MessageNames(); |
20 ~MessageNames(); | 20 ~MessageNames(); |
21 static MessageNames* GetInstance(); | 21 static MessageNames* GetInstance(); |
22 | 22 |
23 void Add(uint32_t type, const std::string& name) { | 23 void Add(uint32_t type, const char* name) { |
24 name_map_[type] = name; | 24 name_map_[type] = name; |
25 type_map_[name] = type; | 25 type_map_[name] = type; |
26 } | 26 } |
27 | 27 |
28 bool TypeExists(uint32_t type) { | 28 bool TypeExists(uint32_t type) { |
29 return name_map_.find(type) != name_map_.end(); | 29 return name_map_.find(type) != name_map_.end(); |
30 } | 30 } |
31 | 31 |
32 bool NameExists(const std::string& name) { | 32 bool NameExists(const std::string& name) { |
33 return type_map_.find(name) != type_map_.end(); | 33 return type_map_.find(name) != type_map_.end(); |
(...skipping 18 matching lines...) Expand all Loading... |
52 NameToTypeMap type_map_; | 52 NameToTypeMap type_map_; |
53 | 53 |
54 static MessageNames* all_names_; | 54 static MessageNames* all_names_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(MessageNames); | 56 DISALLOW_COPY_AND_ASSIGN(MessageNames); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace ipc_fuzzer | 59 } // namespace ipc_fuzzer |
60 | 60 |
61 #endif // TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_ | 61 #endif // TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_ |
OLD | NEW |