Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: ipc/ipc_fuzzing_tests.cc

Issue 666493005: Standardize usage of virtual/override/final in ipc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_forwarding_message_filter.h ('k') | ipc/ipc_message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « ipc/ipc_forwarding_message_filter.h ('k') | ipc/ipc_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698