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

Side by Side Diff: mojo/system/dispatcher_unittest.cc

Issue 169463012: Mojo: Add Dispatcher::{DuplicateBufferHandle,MapBuffer} methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « mojo/system/dispatcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "mojo/system/dispatcher.h" 5 #include "mojo/system/dispatcher.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 enum DispatcherOp { 97 enum DispatcherOp {
98 CLOSE = 0, 98 CLOSE = 0,
99 WRITE_MESSAGE, 99 WRITE_MESSAGE,
100 READ_MESSAGE, 100 READ_MESSAGE,
101 WRITE_DATA, 101 WRITE_DATA,
102 BEGIN_WRITE_DATA, 102 BEGIN_WRITE_DATA,
103 END_WRITE_DATA, 103 END_WRITE_DATA,
104 READ_DATA, 104 READ_DATA,
105 BEGIN_READ_DATA, 105 BEGIN_READ_DATA,
106 END_READ_DATA, 106 END_READ_DATA,
107 DUPLICATE_BUFFER_HANDLE,
108 MAP_BUFFER,
107 ADD_WAITER, 109 ADD_WAITER,
108 REMOVE_WAITER, 110 REMOVE_WAITER,
109 111
110 DISPATCHER_OP_COUNT 112 DISPATCHER_OP_COUNT
111 }; 113 };
112 114
113 ThreadSafetyStressThread(base::WaitableEvent* event, 115 ThreadSafetyStressThread(base::WaitableEvent* event,
114 scoped_refptr<Dispatcher> dispatcher, 116 scoped_refptr<Dispatcher> dispatcher,
115 DispatcherOp op) 117 DispatcherOp op)
116 : base::SimpleThread("thread_safety_stress_thread"), 118 : base::SimpleThread("thread_safety_stress_thread"),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 break; 169 break;
168 case BEGIN_READ_DATA: 170 case BEGIN_READ_DATA:
169 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 171 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
170 dispatcher_->BeginReadData(NULL, NULL, 172 dispatcher_->BeginReadData(NULL, NULL,
171 MOJO_READ_DATA_FLAG_NONE)); 173 MOJO_READ_DATA_FLAG_NONE));
172 break; 174 break;
173 case END_READ_DATA: 175 case END_READ_DATA:
174 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 176 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
175 dispatcher_->EndReadData(0)); 177 dispatcher_->EndReadData(0));
176 break; 178 break;
179 case DUPLICATE_BUFFER_HANDLE: {
180 scoped_refptr<Dispatcher> unused;
181 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
182 dispatcher_->DuplicateBufferHandle(NULL, &unused));
183 break;
184 }
185 case MAP_BUFFER:
186 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
187 dispatcher_->MapBuffer(0u, 0u, NULL,
188 MOJO_MAP_BUFFER_FLAG_NONE));
189 break;
177 case ADD_WAITER: { 190 case ADD_WAITER: {
178 MojoResult r = dispatcher_->AddWaiter(&waiter_, 191 MojoResult r = dispatcher_->AddWaiter(&waiter_,
179 MOJO_WAIT_FLAG_EVERYTHING, 0); 192 MOJO_WAIT_FLAG_EVERYTHING, 0);
180 EXPECT_TRUE(r == MOJO_RESULT_FAILED_PRECONDITION || 193 EXPECT_TRUE(r == MOJO_RESULT_FAILED_PRECONDITION ||
181 r == MOJO_RESULT_INVALID_ARGUMENT); 194 r == MOJO_RESULT_INVALID_ARGUMENT);
182 break; 195 break;
183 } 196 }
184 case REMOVE_WAITER: 197 case REMOVE_WAITER:
185 dispatcher_->RemoveWaiter(&waiter_); 198 dispatcher_->RemoveWaiter(&waiter_);
186 break; 199 break;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 event.Signal(); // Kicks off real work on the threads. 262 event.Signal(); // Kicks off real work on the threads.
250 } // Joins all the threads. 263 } // Joins all the threads.
251 264
252 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); 265 EXPECT_EQ(MOJO_RESULT_OK, d->Close());
253 } 266 }
254 } 267 }
255 268
256 } // namespace 269 } // namespace
257 } // namespace system 270 } // namespace system
258 } // namespace mojo 271 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698