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/replay/replay_process.h" | 5 #include "tools/ipc_fuzzer/replay/replay_process.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <string> | 8 #include <string> |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/posix/global_descriptors.h" | 13 #include "base/posix/global_descriptors.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 #include "ipc/ipc_descriptors.h" | 16 #include "ipc/ipc_descriptors.h" |
17 #include "ipc/ipc_switches.h" | 17 #include "ipc/ipc_switches.h" |
18 #include "ipc/mojo/ipc_channel_mojo.h" | 18 #include "ipc/mojo/ipc_channel_mojo.h" |
| 19 #include "third_party/mojo/src/mojo/edk/embedder/configuration.h" |
| 20 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 21 #include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h" |
19 | 22 |
20 namespace ipc_fuzzer { | 23 namespace ipc_fuzzer { |
21 | 24 |
| 25 // TODO(morrita): content::InitializeMojo() should be used once it becomes |
| 26 // a public API. See src/content/app/mojo/mojo_init.cc |
| 27 void InitializeMojo() { |
| 28 mojo::embedder::GetConfiguration()->max_message_num_bytes = |
| 29 64 * 1024 * 1024; |
| 30 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( |
| 31 new mojo::embedder::SimplePlatformSupport())); |
| 32 } |
| 33 |
22 ReplayProcess::ReplayProcess() | 34 ReplayProcess::ReplayProcess() |
23 : io_thread_("Chrome_ChildIOThread"), | 35 : io_thread_("Chrome_ChildIOThread"), |
24 shutdown_event_(true, false), | 36 shutdown_event_(true, false), |
25 message_index_(0) { | 37 message_index_(0) { |
26 } | 38 } |
27 | 39 |
28 ReplayProcess::~ReplayProcess() { | 40 ReplayProcess::~ReplayProcess() { |
29 channel_.reset(); | 41 channel_.reset(); |
30 | 42 |
31 // Signal this event before shutting down the service process. That way all | 43 // Signal this event before shutting down the service process. That way all |
(...skipping 21 matching lines...) Expand all Loading... |
53 | 65 |
54 io_thread_.StartWithOptions( | 66 io_thread_.StartWithOptions( |
55 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 67 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
56 | 68 |
57 #if defined(OS_POSIX) | 69 #if defined(OS_POSIX) |
58 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); | 70 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); |
59 g_fds->Set(kPrimaryIPCChannel, | 71 g_fds->Set(kPrimaryIPCChannel, |
60 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor); | 72 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor); |
61 #endif | 73 #endif |
62 | 74 |
| 75 InitializeMojo(); |
| 76 |
63 return true; | 77 return true; |
64 } | 78 } |
65 | 79 |
66 void ReplayProcess::OpenChannel() { | 80 void ReplayProcess::OpenChannel() { |
67 std::string channel_name = | 81 std::string channel_name = |
68 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 82 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
69 switches::kProcessChannelID); | 83 switches::kProcessChannelID); |
70 | 84 |
71 // TODO(morrita): As the adoption of ChannelMojo spreads, this | 85 // TODO(morrita): As the adoption of ChannelMojo spreads, this |
72 // criteria has to be updated. | 86 // criteria has to be updated. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return true; | 137 return true; |
124 } | 138 } |
125 | 139 |
126 void ReplayProcess::OnChannelError() { | 140 void ReplayProcess::OnChannelError() { |
127 LOG(ERROR) << "Channel error, quitting after " | 141 LOG(ERROR) << "Channel error, quitting after " |
128 << message_index_ << " messages"; | 142 << message_index_ << " messages"; |
129 base::MessageLoop::current()->Quit(); | 143 base::MessageLoop::current()->Quit(); |
130 } | 144 } |
131 | 145 |
132 } // namespace ipc_fuzzer | 146 } // namespace ipc_fuzzer |
OLD | NEW |