OLD | NEW |
---|---|
(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 #include "chrome/browser/ipc_fuzzer_host.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/files/file_path.h" | |
9 #include "base/logging.h" | |
10 #include "base/platform_file.h" | |
11 #include "chrome/common/chrome_switches.h" | |
12 #include "chrome/common/ipc_fuzzer_messages.h" | |
13 #include "content/public/browser/render_process_host.h" | |
14 #include "ipc/ipc_platform_file.h" | |
15 | |
16 namespace chrome { | |
17 | |
18 void SendTestcaseToIpcFuzzer(content::RenderProcessHost* host) { | |
19 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | |
20 | |
21 if (!browser_command_line.HasSwitch(switches::kIpcFuzzerTestcase)) | |
22 return; | |
23 | |
24 base::FilePath testcase_path = | |
25 browser_command_line.GetSwitchValuePath(switches::kIpcFuzzerTestcase); | |
26 | |
27 base::PlatformFileError error_code; | |
28 base::PlatformFile testcase_file; | |
29 testcase_file = base::CreatePlatformFile( | |
30 testcase_path, | |
31 base::PLATFORM_FILE_OPEN | | |
32 base::PLATFORM_FILE_READ, | |
33 NULL, | |
34 &error_code); | |
35 | |
36 if (error_code != base::PLATFORM_FILE_OK) { | |
37 LOG(ERROR) << "Failed to open IPC fuzzer testcase: " | |
38 << testcase_path.value(); | |
39 return; | |
40 } | |
41 | |
42 IPC::PlatformFileForTransit file = IPC::GetFileHandleForProcess( | |
43 testcase_file, | |
44 host->GetHandle(), | |
jochen (gone - plz use gerrit)
2013/07/16 09:07:58
if I'm not mistaken, this won't work on Linux. You
aedla
2013/07/16 20:42:47
Did you mean this won't work on Windows. That coul
| |
45 true); | |
46 | |
47 host->Send(new IpcFuzzerMsg_RunTestcase(file)); | |
48 } | |
49 | |
50 } // namespace chrome | |
OLD | NEW |