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

Unified Diff: chrome/browser/ipc_fuzzer_host.cc

Issue 18254010: IPC fuzzer child process component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed some files Created 7 years, 5 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: chrome/browser/ipc_fuzzer_host.cc
diff --git a/chrome/browser/ipc_fuzzer_host.cc b/chrome/browser/ipc_fuzzer_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4641924dc1ae160e01d853a270ffc9f1fe9457c0
--- /dev/null
+++ b/chrome/browser/ipc_fuzzer_host.cc
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ipc_fuzzer_host.h"
+
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/platform_file.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/ipc_fuzzer_messages.h"
+#include "content/public/browser/render_process_host.h"
+#include "ipc/ipc_platform_file.h"
+
+namespace chrome {
Tom Sepez 2013/07/12 18:47:20 ditto here for ifdef
+
+void SendTestcaseToIpcFuzzer(content::RenderProcessHost* host) {
+ const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
+
+ if (!browser_command_line.HasSwitch(switches::kIpcFuzzerTestcase))
+ return;
+
+ base::FilePath testcase_path =
+ browser_command_line.GetSwitchValuePath(switches::kIpcFuzzerTestcase);
+
+ base::PlatformFileError error_code;
+ base::PlatformFile testcase_file;
+ testcase_file = base::CreatePlatformFile(
+ testcase_path,
+ base::PLATFORM_FILE_OPEN |
+ base::PLATFORM_FILE_READ,
+ NULL,
+ &error_code);
+
+ if (error_code != base::PLATFORM_FILE_OK) {
+ LOG(ERROR) << "Failed to open IPC fuzzer testcase: "
+ << testcase_path.value();
+ return;
+ }
+
+ IPC::PlatformFileForTransit file = IPC::GetFileHandleForProcess(
+ testcase_file,
+ host->GetHandle(),
+ true);
+
+ host->Send(new IpcFuzzerMsg_RunTestcase(file));
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698