| 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 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 bool ReplayProcess::OpenTestcase() { | 102 bool ReplayProcess::OpenTestcase() { |
| 103 base::FilePath path = | 103 base::FilePath path = |
| 104 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 104 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 105 switches::kIpcFuzzerTestcase); | 105 switches::kIpcFuzzerTestcase); |
| 106 return MessageFile::Read(path, &messages_); | 106 return MessageFile::Read(path, &messages_); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ReplayProcess::SendNextMessage() { | 109 void ReplayProcess::SendNextMessage() { |
| 110 if (message_index_ >= messages_.size()) { | 110 if (message_index_ >= messages_.size()) { |
| 111 base::MessageLoop::current()->Quit(); | 111 base::MessageLoop::current()->QuitWhenIdle(); |
| 112 return; | 112 return; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Take next message and release it from vector. | 115 // Take next message and release it from vector. |
| 116 IPC::Message* message = messages_[message_index_]; | 116 IPC::Message* message = messages_[message_index_]; |
| 117 messages_[message_index_++] = NULL; | 117 messages_[message_index_++] = NULL; |
| 118 | 118 |
| 119 if (!channel_->Send(message)) { | 119 if (!channel_->Send(message)) { |
| 120 LOG(ERROR) << "ChannelProxy::Send() failed after " | 120 LOG(ERROR) << "ChannelProxy::Send() failed after " |
| 121 << message_index_ << " messages"; | 121 << message_index_ << " messages"; |
| 122 base::MessageLoop::current()->Quit(); | 122 base::MessageLoop::current()->QuitWhenIdle(); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 void ReplayProcess::Run() { | 126 void ReplayProcess::Run() { |
| 127 timer_.reset(new base::Timer(false, true)); | 127 timer_.reset(new base::Timer(false, true)); |
| 128 timer_->Start(FROM_HERE, | 128 timer_->Start(FROM_HERE, |
| 129 base::TimeDelta::FromMilliseconds(1), | 129 base::TimeDelta::FromMilliseconds(1), |
| 130 base::Bind(&ReplayProcess::SendNextMessage, | 130 base::Bind(&ReplayProcess::SendNextMessage, |
| 131 base::Unretained(this))); | 131 base::Unretained(this))); |
| 132 base::MessageLoop::current()->Run(); | 132 base::MessageLoop::current()->Run(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 bool ReplayProcess::OnMessageReceived(const IPC::Message& msg) { | 135 bool ReplayProcess::OnMessageReceived(const IPC::Message& msg) { |
| 136 return true; | 136 return true; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void ReplayProcess::OnChannelError() { | 139 void ReplayProcess::OnChannelError() { |
| 140 LOG(ERROR) << "Channel error, quitting after " | 140 LOG(ERROR) << "Channel error, quitting after " |
| 141 << message_index_ << " messages"; | 141 << message_index_ << " messages"; |
| 142 base::MessageLoop::current()->Quit(); | 142 base::MessageLoop::current()->QuitWhenIdle(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace ipc_fuzzer | 145 } // namespace ipc_fuzzer |
| OLD | NEW |