| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Unit test for SyncChannel. | 5 // Unit test for SyncChannel. |
| 6 | 6 |
| 7 #include "ipc/ipc_sync_channel.h" | 7 #include "ipc/ipc_sync_channel.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 listener_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 189 listener_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 190 this, &Worker::OnListenerThreadShutdown2, listener_event)); | 190 this, &Worker::OnListenerThreadShutdown2, listener_event)); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void OnListenerThreadShutdown2(WaitableEvent* listener_event) { | 193 void OnListenerThreadShutdown2(WaitableEvent* listener_event) { |
| 194 MessageLoop::current()->RunAllPending(); | 194 MessageLoop::current()->RunAllPending(); |
| 195 listener_event->Signal(); | 195 listener_event->Signal(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void OnMessageReceived(const Message& message) { | 198 bool OnMessageReceived(const Message& message) { |
| 199 IPC_BEGIN_MESSAGE_MAP(Worker, message) | 199 IPC_BEGIN_MESSAGE_MAP(Worker, message) |
| 200 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncChannelTestMsg_Double, OnDoubleDelay) | 200 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncChannelTestMsg_Double, OnDoubleDelay) |
| 201 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncChannelTestMsg_AnswerToLife, | 201 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncChannelTestMsg_AnswerToLife, |
| 202 OnAnswerDelay) | 202 OnAnswerDelay) |
| 203 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncChannelNestedTestMsg_String, | 203 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncChannelNestedTestMsg_String, |
| 204 OnNestedTestMsg) | 204 OnNestedTestMsg) |
| 205 IPC_END_MESSAGE_MAP() | 205 IPC_END_MESSAGE_MAP() |
| 206 return true; |
| 206 } | 207 } |
| 207 | 208 |
| 208 void StartThread(base::Thread* thread, MessageLoop::Type type) { | 209 void StartThread(base::Thread* thread, MessageLoop::Type type) { |
| 209 base::Thread::Options options; | 210 base::Thread::Options options; |
| 210 options.message_loop_type = type; | 211 options.message_loop_type = type; |
| 211 thread->StartWithOptions(options); | 212 thread->StartWithOptions(options); |
| 212 } | 213 } |
| 213 | 214 |
| 214 scoped_ptr<WaitableEvent> done_; | 215 scoped_ptr<WaitableEvent> done_; |
| 215 scoped_ptr<WaitableEvent> channel_created_; | 216 scoped_ptr<WaitableEvent> channel_created_; |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 server.done_event()->Wait(); | 1157 server.done_event()->Wait(); |
| 1157 server.done_event()->Reset(); | 1158 server.done_event()->Reset(); |
| 1158 | 1159 |
| 1159 server.SendDummy(); | 1160 server.SendDummy(); |
| 1160 server.done_event()->Wait(); | 1161 server.done_event()->Wait(); |
| 1161 | 1162 |
| 1162 EXPECT_FALSE(server.send_result()); | 1163 EXPECT_FALSE(server.send_result()); |
| 1163 } | 1164 } |
| 1164 | 1165 |
| 1165 | 1166 |
| OLD | NEW |