OLD | NEW |
---|---|
(Empty) | |
1 #include "base/files/file_path.h" | |
inferno
2015/03/05 18:46:48
Missing copyright notice.
| |
2 #include "base/process/process.h" | |
3 #include "base/strings/string_number_conversions.h" | |
4 #include "ipc/ipc_channel_proxy.h" | |
5 #include "tools/ipc_fuzzer/message_lib/message_file.h" | |
6 | |
7 #if defined(OS_WIN) | |
8 #define IntToStringType base::IntToString16 | |
9 #define MESSAGE_DUMP_EXPORT __declspec(dllexport) | |
inferno
2015/03/05 18:46:48
Can you use IPC_EXPORT or similar ?
| |
10 #else | |
11 #define IntToStringType base::IntToString | |
12 #define MESSAGE_DUMP_EXPORT __attribute__((visibility("default"))) | |
13 #endif | |
14 | |
15 namespace ipc_fuzzer { | |
16 | |
17 class IPCDump : public IPC::ChannelProxy::OutgoingMessageFilter { | |
18 public: | |
inferno
2015/03/05 18:46:48
2 spaces indent, not 1
| |
19 ~IPCDump() { | |
20 base::FilePath::StringType pid_string = | |
21 IntToStringType(base::Process::Current().Pid()); | |
22 base::FilePath output_file_path = | |
23 dump_directory_.Append(pid_string + FILE_PATH_LITERAL(".ipcdump")); | |
inferno
2015/03/05 18:46:48
please use a getter for dump_directory_, like dump
| |
24 | |
25 MessageFile::Write(output_file_path, messages_); | |
26 } | |
27 | |
28 IPC::Message* Rewrite(IPC::Message* message) override { | |
29 messages_.push_back(new IPC::Message(*message)); | |
30 return message; | |
31 } | |
32 | |
33 void set_dump_directory(base::FilePath& dump_directory) { | |
34 dump_directory_ = dump_directory; | |
35 } | |
36 | |
37 private: | |
38 MessageVector messages_; | |
inferno
2015/03/05 18:46:48
indents issue.
| |
39 base::FilePath dump_directory_; | |
40 }; | |
41 | |
42 IPCDump g_ipcdump; | |
43 | |
44 } // namespace ipc_fuzzer | |
45 | |
46 // Entry point avoiding mangled names. | |
47 extern "C" { | |
48 MESSAGE_DUMP_EXPORT IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void); | |
49 MESSAGE_DUMP_EXPORT void SetDumpDirectory(base::FilePath& dump_directory); | |
50 } | |
51 | |
52 IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void) { | |
53 return &ipc_fuzzer::g_ipcdump; | |
54 } | |
55 | |
56 void SetDumpDirectory(base::FilePath& dump_directory) { | |
57 ipc_fuzzer::g_ipcdump.set_dump_directory(dump_directory); | |
58 } | |
OLD | NEW |