| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/ipc_fuzzer/message_replay/replay_process.h" | 5 #include "tools/ipc_fuzzer/message_replay/replay_process.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/posix/global_descriptors.h" | 14 #include "base/posix/global_descriptors.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/mojo_channel_switches.h" | 18 #include "content/public/common/mojo_channel_switches.h" |
| 19 #include "ipc/ipc_descriptors.h" | 19 #include "ipc/ipc_descriptors.h" |
| 20 #include "ipc/ipc_switches.h" | 20 #include "ipc/ipc_switches.h" |
| 21 #include "ipc/mojo/ipc_channel_mojo.h" | 21 #include "ipc/mojo/ipc_channel_mojo.h" |
| 22 #include "mojo/edk/embedder/embedder.h" | 22 #include "mojo/edk/embedder/embedder.h" |
| 23 #include "mojo/edk/embedder/platform_channel_pair.h" | 23 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 24 #include "mojo/edk/embedder/scoped_ipc_support.h" |
| 24 | 25 |
| 25 #if defined(OS_POSIX) | 26 #if defined(OS_POSIX) |
| 26 #include "content/public/common/content_descriptors.h" | 27 #include "content/public/common/content_descriptors.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 namespace ipc_fuzzer { | 30 namespace ipc_fuzzer { |
| 30 | 31 |
| 31 void InitializeMojo() { | 32 void InitializeMojo() { |
| 32 mojo::edk::SetMaxMessageSize(64 * 1024 * 1024); | 33 mojo::edk::SetMaxMessageSize(64 * 1024 * 1024); |
| 33 mojo::edk::Init(); | 34 mojo::edk::Init(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 87 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 87 | 88 |
| 88 #if defined(OS_POSIX) | 89 #if defined(OS_POSIX) |
| 89 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); | 90 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); |
| 90 g_fds->Set(kPrimaryIPCChannel, | 91 g_fds->Set(kPrimaryIPCChannel, |
| 91 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor); | 92 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor); |
| 92 g_fds->Set(kMojoIPCChannel, | 93 g_fds->Set(kMojoIPCChannel, |
| 93 kMojoIPCChannel + base::GlobalDescriptors::kBaseDescriptor); | 94 kMojoIPCChannel + base::GlobalDescriptors::kBaseDescriptor); |
| 94 #endif | 95 #endif |
| 95 | 96 |
| 96 mojo_ipc_support_.reset(new IPC::ScopedIPCSupport(io_thread_.task_runner())); | 97 mojo_ipc_support_.reset( |
| 98 new mojo::edk::ScopedIPCSupport(io_thread_.task_runner())); |
| 97 InitializeMojoIPCChannel(); | 99 InitializeMojoIPCChannel(); |
| 98 | 100 |
| 99 return true; | 101 return true; |
| 100 } | 102 } |
| 101 | 103 |
| 102 void ReplayProcess::OpenChannel() { | 104 void ReplayProcess::OpenChannel() { |
| 103 // TODO(morrita): As the adoption of ChannelMojo spreads, this | 105 // TODO(morrita): As the adoption of ChannelMojo spreads, this |
| 104 // criteria has to be updated. | 106 // criteria has to be updated. |
| 105 std::string process_type = | 107 std::string process_type = |
| 106 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 108 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 return true; | 164 return true; |
| 163 } | 165 } |
| 164 | 166 |
| 165 void ReplayProcess::OnChannelError() { | 167 void ReplayProcess::OnChannelError() { |
| 166 LOG(ERROR) << "Channel error, quitting after " | 168 LOG(ERROR) << "Channel error, quitting after " |
| 167 << message_index_ << " messages"; | 169 << message_index_ << " messages"; |
| 168 base::MessageLoop::current()->QuitWhenIdle(); | 170 base::MessageLoop::current()->QuitWhenIdle(); |
| 169 } | 171 } |
| 170 | 172 |
| 171 } // namespace ipc_fuzzer | 173 } // namespace ipc_fuzzer |
| OLD | NEW |