| 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 <map> | |
| 11 #include <string> | 10 #include <string> |
| 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(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 return it->second; | 39 return it->second; |
| 40 } | 40 } |
| 41 | 41 |
| 42 uint32_t NameToType(const std::string& name) { | 42 uint32_t NameToType(const std::string& name) { |
| 43 NameToTypeMap::iterator it = type_map_.find(name); | 43 NameToTypeMap::iterator it = type_map_.find(name); |
| 44 CHECK(it != type_map_.end()); | 44 CHECK(it != type_map_.end()); |
| 45 return it->second; | 45 return it->second; |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 typedef std::map<uint32_t, std::string> TypeToNameMap; | 49 typedef std::unordered_map<uint32_t, std::string> TypeToNameMap; |
| 50 typedef std::map<std::string, uint32_t> NameToTypeMap; | 50 typedef std::unordered_map<std::string, uint32_t> NameToTypeMap; |
| 51 TypeToNameMap name_map_; | 51 TypeToNameMap name_map_; |
| 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 |