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

Side by Side Diff: tools/ipc_fuzzer/dump/message_dump.cc

Issue 975903002: Add a flag to dump IPC messages sent from the renderer to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete a leftover comment Created 5 years, 9 months 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
OLDNEW
(Empty)
1 // Copyright (c) 2015 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 #include "base/files/file_path.h"
6 #include "base/process/process.h"
7 #include "base/strings/string_number_conversions.h"
8 #include "ipc/ipc_channel_proxy.h"
9 #include "tools/ipc_fuzzer/message_lib/message_file.h"
10
11 #if defined(OS_WIN)
12 #define IntToStringType base::IntToString16
13 #else
14 #define IntToStringType base::IntToString
15 #endif
16
17 namespace ipc_fuzzer {
18
19 class IPCDump : public IPC::ChannelProxy::OutgoingMessageFilter {
20 public:
21 ~IPCDump() {
22 base::FilePath::StringType pid_string =
23 IntToStringType(base::Process::Current().Pid());
inferno 2015/03/05 22:11:59 base::Process::Current().Pid() is base::ProcessId.
24 base::FilePath output_file_path =
25 dump_directory().Append(pid_string + FILE_PATH_LITERAL(".ipcdump"));
26
27 MessageFile::Write(output_file_path, messages_);
28 }
29
30 IPC::Message* Rewrite(IPC::Message* message) override {
31 messages_.push_back(new IPC::Message(*message));
32 return message;
33 }
34
35 base::FilePath dump_directory() const { return dump_directory_; }
36
37 void set_dump_directory(const base::FilePath& dump_directory) {
38 dump_directory_ = dump_directory;
39 }
40
41 private:
42 MessageVector messages_;
43 base::FilePath dump_directory_;
44 };
45
46 IPCDump g_ipcdump;
47
48 } // namespace ipc_fuzzer
49
50 // Entry point avoiding mangled names.
51 extern "C" {
52 IPC_EXPORT IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void);
53 IPC_EXPORT void SetDumpDirectory(const base::FilePath& dump_directory);
54 }
55
56 IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void) {
57 return &ipc_fuzzer::g_ipcdump;
58 }
59
60 void SetDumpDirectory(const base::FilePath& dump_directory) {
61 ipc_fuzzer::g_ipcdump.set_dump_directory(dump_directory);
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698