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

Unified 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: Cleanup in external_ipc_dumper.cc Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: tools/ipc_fuzzer/dump/message_dump.cc
diff --git a/tools/ipc_fuzzer/dump/message_dump.cc b/tools/ipc_fuzzer/dump/message_dump.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dcbc7d79d7569fa9b6794d9b47127adf30c38a6b
--- /dev/null
+++ b/tools/ipc_fuzzer/dump/message_dump.cc
@@ -0,0 +1,58 @@
+#include "base/files/file_path.h"
inferno 2015/03/05 18:46:48 Missing copyright notice.
+#include "base/process/process.h"
+#include "base/strings/string_number_conversions.h"
+#include "ipc/ipc_channel_proxy.h"
+#include "tools/ipc_fuzzer/message_lib/message_file.h"
+
+#if defined(OS_WIN)
+#define IntToStringType base::IntToString16
+#define MESSAGE_DUMP_EXPORT __declspec(dllexport)
inferno 2015/03/05 18:46:48 Can you use IPC_EXPORT or similar ?
+#else
+#define IntToStringType base::IntToString
+#define MESSAGE_DUMP_EXPORT __attribute__((visibility("default")))
+#endif
+
+namespace ipc_fuzzer {
+
+class IPCDump : public IPC::ChannelProxy::OutgoingMessageFilter {
+ public:
inferno 2015/03/05 18:46:48 2 spaces indent, not 1
+ ~IPCDump() {
+ base::FilePath::StringType pid_string =
+ IntToStringType(base::Process::Current().Pid());
+ base::FilePath output_file_path =
+ 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
+
+ MessageFile::Write(output_file_path, messages_);
+ }
+
+ IPC::Message* Rewrite(IPC::Message* message) override {
+ messages_.push_back(new IPC::Message(*message));
+ return message;
+ }
+
+ void set_dump_directory(base::FilePath& dump_directory) {
+ dump_directory_ = dump_directory;
+ }
+
+ private:
+ MessageVector messages_;
inferno 2015/03/05 18:46:48 indents issue.
+ base::FilePath dump_directory_;
+};
+
+IPCDump g_ipcdump;
+
+} // namespace ipc_fuzzer
+
+// Entry point avoiding mangled names.
+extern "C" {
+MESSAGE_DUMP_EXPORT IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void);
+MESSAGE_DUMP_EXPORT void SetDumpDirectory(base::FilePath& dump_directory);
+}
+
+IPC::ChannelProxy::OutgoingMessageFilter* GetFilter(void) {
+ return &ipc_fuzzer::g_ipcdump;
+}
+
+void SetDumpDirectory(base::FilePath& dump_directory) {
+ ipc_fuzzer::g_ipcdump.set_dump_directory(dump_directory);
+}

Powered by Google App Engine
This is Rietveld 408576698