OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdio.h> | 5 #include <stdio.h> |
6 #include <string> | 6 #include <string> |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 FUZZER_ROUTING_ID = 5 | 128 FUZZER_ROUTING_ID = 5 |
129 }; | 129 }; |
130 | 130 |
131 // The fuzzer server class. It runs in a child process and expects | 131 // The fuzzer server class. It runs in a child process and expects |
132 // only two IPC calls; after that it exits the message loop which | 132 // only two IPC calls; after that it exits the message loop which |
133 // terminates the child process. | 133 // terminates the child process. |
134 class FuzzerServerListener : public SimpleListener { | 134 class FuzzerServerListener : public SimpleListener { |
135 public: | 135 public: |
136 FuzzerServerListener() : message_count_(2), pending_messages_(0) { | 136 FuzzerServerListener() : message_count_(2), pending_messages_(0) { |
137 } | 137 } |
138 virtual bool OnMessageReceived(const IPC::Message& msg) override { | 138 bool OnMessageReceived(const IPC::Message& msg) override { |
139 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 139 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
140 ++pending_messages_; | 140 ++pending_messages_; |
141 IPC_BEGIN_MESSAGE_MAP(FuzzerServerListener, msg) | 141 IPC_BEGIN_MESSAGE_MAP(FuzzerServerListener, msg) |
142 IPC_MESSAGE_HANDLER(MsgClassIS, OnMsgClassISMessage) | 142 IPC_MESSAGE_HANDLER(MsgClassIS, OnMsgClassISMessage) |
143 IPC_MESSAGE_HANDLER(MsgClassSI, OnMsgClassSIMessage) | 143 IPC_MESSAGE_HANDLER(MsgClassSI, OnMsgClassSIMessage) |
144 IPC_END_MESSAGE_MAP() | 144 IPC_END_MESSAGE_MAP() |
145 if (pending_messages_) { | 145 if (pending_messages_) { |
146 // Probably a problem de-serializing the message. | 146 // Probably a problem de-serializing the message. |
147 ReplyMsgNotHandled(msg.type()); | 147 ReplyMsgNotHandled(msg.type()); |
148 } | 148 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 int message_count_; | 193 int message_count_; |
194 int pending_messages_; | 194 int pending_messages_; |
195 }; | 195 }; |
196 | 196 |
197 class FuzzerClientListener : public SimpleListener { | 197 class FuzzerClientListener : public SimpleListener { |
198 public: | 198 public: |
199 FuzzerClientListener() : last_msg_(NULL) { | 199 FuzzerClientListener() : last_msg_(NULL) { |
200 } | 200 } |
201 | 201 |
202 virtual bool OnMessageReceived(const IPC::Message& msg) override { | 202 bool OnMessageReceived(const IPC::Message& msg) override { |
203 last_msg_ = new IPC::Message(msg); | 203 last_msg_ = new IPC::Message(msg); |
204 base::MessageLoop::current()->Quit(); | 204 base::MessageLoop::current()->Quit(); |
205 return true; | 205 return true; |
206 } | 206 } |
207 | 207 |
208 bool ExpectMessage(int value, uint32 type_id) { | 208 bool ExpectMessage(int value, uint32 type_id) { |
209 if (!MsgHandlerInternal(type_id)) | 209 if (!MsgHandlerInternal(type_id)) |
210 return false; | 210 return false; |
211 int msg_value1 = 0; | 211 int msg_value1 = 0; |
212 int msg_value2 = 0; | 212 int msg_value2 = 0; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 // thrown out of sync by the extra argument. | 339 // thrown out of sync by the extra argument. |
340 msg = new MsgClassIS(3, L"expect three"); | 340 msg = new MsgClassIS(3, L"expect three"); |
341 sender()->Send(msg); | 341 sender()->Send(msg); |
342 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID)); | 342 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID)); |
343 | 343 |
344 EXPECT_TRUE(WaitForClientShutdown()); | 344 EXPECT_TRUE(WaitForClientShutdown()); |
345 DestroyChannel(); | 345 DestroyChannel(); |
346 } | 346 } |
347 | 347 |
348 } // namespace | 348 } // namespace |
OLD | NEW |