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

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

Issue 67413003: Mojo: Implement plumbing to support passing handles over MessagePipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: old chunk mismatch Created 7 years, 1 month 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
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/core_test_base.h" 5 #include "mojo/system/core_test_base.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "mojo/system/core_impl.h" 12 #include "mojo/system/core_impl.h"
13 #include "mojo/system/dispatcher.h" 13 #include "mojo/system/dispatcher.h"
14 #include "mojo/system/limits.h"
14 #include "mojo/system/memory.h" 15 #include "mojo/system/memory.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace system { 18 namespace system {
18 namespace test { 19 namespace test {
19 20
20 namespace { 21 namespace {
21 22
22 // MockDispatcher -------------------------------------------------------------- 23 // MockDispatcher --------------------------------------------------------------
23 24
(...skipping 14 matching lines...) Expand all
38 // |Dispatcher| implementation/overrides: 39 // |Dispatcher| implementation/overrides:
39 virtual MojoResult CloseImplNoLock() OVERRIDE { 40 virtual MojoResult CloseImplNoLock() OVERRIDE {
40 info_->IncrementCloseCallCount(); 41 info_->IncrementCloseCallCount();
41 lock().AssertAcquired(); 42 lock().AssertAcquired();
42 return MOJO_RESULT_OK; 43 return MOJO_RESULT_OK;
43 } 44 }
44 45
45 virtual MojoResult WriteMessageImplNoLock( 46 virtual MojoResult WriteMessageImplNoLock(
46 const void* bytes, 47 const void* bytes,
47 uint32_t num_bytes, 48 uint32_t num_bytes,
48 const MojoHandle* handles, 49 const std::vector<Dispatcher*>* dispatchers,
49 uint32_t num_handles,
50 MojoWriteMessageFlags /*flags*/) OVERRIDE { 50 MojoWriteMessageFlags /*flags*/) OVERRIDE {
51 info_->IncrementWriteMessageCallCount(); 51 info_->IncrementWriteMessageCallCount();
52 lock().AssertAcquired(); 52 lock().AssertAcquired();
53 53
54 if (!VerifyUserPointer<void>(bytes, num_bytes)) 54 if (!VerifyUserPointer<void>(bytes, num_bytes))
55 return MOJO_RESULT_INVALID_ARGUMENT; 55 return MOJO_RESULT_INVALID_ARGUMENT;
56 if (!VerifyUserPointer<MojoHandle>(handles, num_handles)) 56 if (num_bytes > kMaxMessageNumBytes)
57 return MOJO_RESULT_INVALID_ARGUMENT; 57 return MOJO_RESULT_RESOURCE_EXHAUSTED;
58
59 if (dispatchers)
60 return MOJO_RESULT_UNIMPLEMENTED;
58 61
59 return MOJO_RESULT_OK; 62 return MOJO_RESULT_OK;
60 } 63 }
61 64
62 virtual MojoResult ReadMessageImplNoLock( 65 virtual MojoResult ReadMessageImplNoLock(
63 void* bytes, 66 void* bytes, uint32_t* num_bytes,
64 uint32_t* num_bytes, 67 uint32_t /*max_num_dispatchers*/,
65 MojoHandle* handles, 68 std::vector<scoped_refptr<Dispatcher> >* /*dispatchers*/,
66 uint32_t* num_handles,
67 MojoReadMessageFlags /*flags*/) OVERRIDE { 69 MojoReadMessageFlags /*flags*/) OVERRIDE {
68 info_->IncrementReadMessageCallCount(); 70 info_->IncrementReadMessageCallCount();
69 lock().AssertAcquired(); 71 lock().AssertAcquired();
70 72
71 if (num_bytes && !VerifyUserPointer<void>(bytes, *num_bytes)) 73 if (num_bytes && !VerifyUserPointer<void>(bytes, *num_bytes))
72 return MOJO_RESULT_INVALID_ARGUMENT; 74 return MOJO_RESULT_INVALID_ARGUMENT;
73 if (num_handles &&
74 !VerifyUserPointer<MojoHandle>(handles, *num_handles))
75 return MOJO_RESULT_INVALID_ARGUMENT;
76 75
77 return MOJO_RESULT_OK; 76 return MOJO_RESULT_OK;
78 } 77 }
79 78
80 virtual MojoResult AddWaiterImplNoLock(Waiter* /*waiter*/, 79 virtual MojoResult AddWaiterImplNoLock(Waiter* /*waiter*/,
81 MojoWaitFlags /*flags*/, 80 MojoWaitFlags /*flags*/,
82 MojoResult /*wake_result*/) OVERRIDE { 81 MojoResult /*wake_result*/) OVERRIDE {
83 info_->IncrementAddWaiterCallCount(); 82 info_->IncrementAddWaiterCallCount();
84 lock().AssertAcquired(); 83 lock().AssertAcquired();
85 return MOJO_RESULT_FAILED_PRECONDITION; 84 return MOJO_RESULT_FAILED_PRECONDITION;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 217 }
219 218
220 void CoreTestBase_MockHandleInfo::IncrementCancelAllWaitersCallCount() { 219 void CoreTestBase_MockHandleInfo::IncrementCancelAllWaitersCallCount() {
221 base::AutoLock locker(lock_); 220 base::AutoLock locker(lock_);
222 cancel_all_waiters_call_count_++; 221 cancel_all_waiters_call_count_++;
223 } 222 }
224 223
225 } // namespace test 224 } // namespace test
226 } // namespace system 225 } // namespace system
227 } // namespace mojo 226 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698