Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: tools/ipc_fuzzer/message_lib/message_names.h

Issue 105083002: IPC fuzzer: create message_lib library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename map_ to mapped_file_. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_
6 #define TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_
7
8 #include <map>
9 #include <string>
10 #include "base/basictypes.h"
11
12 namespace ipc_fuzzer {
13
14 class MessageNames {
15 public:
16 MessageNames();
17 ~MessageNames();
18 static MessageNames& Get();
Tom Sepez 2013/12/06 18:57:16 nit: Usually called GetInstance() in chromium code
aedla 2013/12/09 18:08:32 Done.
19
20 void Add(uint32 type, const std::string& name) {
21 name_map_[type] = name;
22 type_map_[name] = type;
23 }
24
25 bool TypeExists(uint32 type) {
26 return name_map_.find(type) != name_map_.end();
27 }
28
29 bool NameExists(const std::string& name) {
30 return type_map_.find(name) != type_map_.end();
31 }
32
33 const std::string& TypeToName(uint32 type) {
34 return name_map_[type];
35 }
36
37 uint32 NameToType(const std::string& name) {
38 return type_map_[name];
39 }
40
41 private:
42 typedef std::map<uint32, std::string> TypeToNameMap;
43 typedef std::map<std::string, uint32> NameToTypeMap;
44 TypeToNameMap name_map_;
45 NameToTypeMap type_map_;
46
47 static MessageNames* all_names_;
48
49 DISALLOW_COPY_AND_ASSIGN(MessageNames);
50 };
51
52 } // namespace ipc_fuzzer
53
54 #endif // TOOLS_IPC_FUZZER_MESSAGE_LIB_MESSAGE_NAMES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698