OLD | NEW |
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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // MockDispatcher -------------------------------------------------------------- | 24 // MockDispatcher -------------------------------------------------------------- |
25 | 25 |
26 class MockDispatcher : public Dispatcher { | 26 class MockDispatcher : public Dispatcher { |
27 public: | 27 public: |
28 explicit MockDispatcher(CoreTestBase::MockHandleInfo* info) : info_(info) { | 28 explicit MockDispatcher(CoreTestBase::MockHandleInfo* info) : info_(info) { |
29 CHECK(info_); | 29 CHECK(info_); |
30 info_->IncrementCtorCallCount(); | 30 info_->IncrementCtorCallCount(); |
31 } | 31 } |
32 | 32 |
33 // |Dispatcher| private methods: | 33 // |Dispatcher| private methods: |
34 virtual Type GetType() const OVERRIDE { return kTypeUnknown; } | 34 virtual Type GetType() const override { return kTypeUnknown; } |
35 | 35 |
36 private: | 36 private: |
37 virtual ~MockDispatcher() { info_->IncrementDtorCallCount(); } | 37 virtual ~MockDispatcher() { info_->IncrementDtorCallCount(); } |
38 | 38 |
39 // |Dispatcher| protected methods: | 39 // |Dispatcher| protected methods: |
40 virtual void CloseImplNoLock() OVERRIDE { | 40 virtual void CloseImplNoLock() override { |
41 info_->IncrementCloseCallCount(); | 41 info_->IncrementCloseCallCount(); |
42 lock().AssertAcquired(); | 42 lock().AssertAcquired(); |
43 } | 43 } |
44 | 44 |
45 virtual MojoResult WriteMessageImplNoLock( | 45 virtual MojoResult WriteMessageImplNoLock( |
46 UserPointer<const void> bytes, | 46 UserPointer<const void> bytes, |
47 uint32_t num_bytes, | 47 uint32_t num_bytes, |
48 std::vector<DispatcherTransport>* transports, | 48 std::vector<DispatcherTransport>* transports, |
49 MojoWriteMessageFlags /*flags*/) OVERRIDE { | 49 MojoWriteMessageFlags /*flags*/) override { |
50 info_->IncrementWriteMessageCallCount(); | 50 info_->IncrementWriteMessageCallCount(); |
51 lock().AssertAcquired(); | 51 lock().AssertAcquired(); |
52 | 52 |
53 if (num_bytes > kMaxMessageNumBytes) | 53 if (num_bytes > kMaxMessageNumBytes) |
54 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 54 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
55 | 55 |
56 if (transports) | 56 if (transports) |
57 return MOJO_RESULT_UNIMPLEMENTED; | 57 return MOJO_RESULT_UNIMPLEMENTED; |
58 | 58 |
59 return MOJO_RESULT_OK; | 59 return MOJO_RESULT_OK; |
60 } | 60 } |
61 | 61 |
62 virtual MojoResult ReadMessageImplNoLock( | 62 virtual MojoResult ReadMessageImplNoLock( |
63 UserPointer<void> bytes, | 63 UserPointer<void> bytes, |
64 UserPointer<uint32_t> num_bytes, | 64 UserPointer<uint32_t> num_bytes, |
65 DispatcherVector* dispatchers, | 65 DispatcherVector* dispatchers, |
66 uint32_t* num_dispatchers, | 66 uint32_t* num_dispatchers, |
67 MojoReadMessageFlags /*flags*/) OVERRIDE { | 67 MojoReadMessageFlags /*flags*/) override { |
68 info_->IncrementReadMessageCallCount(); | 68 info_->IncrementReadMessageCallCount(); |
69 lock().AssertAcquired(); | 69 lock().AssertAcquired(); |
70 | 70 |
71 if (num_dispatchers) { | 71 if (num_dispatchers) { |
72 *num_dispatchers = 1; | 72 *num_dispatchers = 1; |
73 if (dispatchers) { | 73 if (dispatchers) { |
74 // Okay to leave an invalid dispatcher. | 74 // Okay to leave an invalid dispatcher. |
75 dispatchers->resize(1); | 75 dispatchers->resize(1); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 return MOJO_RESULT_OK; | 79 return MOJO_RESULT_OK; |
80 } | 80 } |
81 | 81 |
82 virtual MojoResult WriteDataImplNoLock( | 82 virtual MojoResult WriteDataImplNoLock( |
83 UserPointer<const void> /*elements*/, | 83 UserPointer<const void> /*elements*/, |
84 UserPointer<uint32_t> /*num_bytes*/, | 84 UserPointer<uint32_t> /*num_bytes*/, |
85 MojoWriteDataFlags /*flags*/) OVERRIDE { | 85 MojoWriteDataFlags /*flags*/) override { |
86 info_->IncrementWriteDataCallCount(); | 86 info_->IncrementWriteDataCallCount(); |
87 lock().AssertAcquired(); | 87 lock().AssertAcquired(); |
88 return MOJO_RESULT_UNIMPLEMENTED; | 88 return MOJO_RESULT_UNIMPLEMENTED; |
89 } | 89 } |
90 | 90 |
91 virtual MojoResult BeginWriteDataImplNoLock( | 91 virtual MojoResult BeginWriteDataImplNoLock( |
92 UserPointer<void*> /*buffer*/, | 92 UserPointer<void*> /*buffer*/, |
93 UserPointer<uint32_t> /*buffer_num_bytes*/, | 93 UserPointer<uint32_t> /*buffer_num_bytes*/, |
94 MojoWriteDataFlags /*flags*/) OVERRIDE { | 94 MojoWriteDataFlags /*flags*/) override { |
95 info_->IncrementBeginWriteDataCallCount(); | 95 info_->IncrementBeginWriteDataCallCount(); |
96 lock().AssertAcquired(); | 96 lock().AssertAcquired(); |
97 return MOJO_RESULT_UNIMPLEMENTED; | 97 return MOJO_RESULT_UNIMPLEMENTED; |
98 } | 98 } |
99 | 99 |
100 virtual MojoResult EndWriteDataImplNoLock( | 100 virtual MojoResult EndWriteDataImplNoLock( |
101 uint32_t /*num_bytes_written*/) OVERRIDE { | 101 uint32_t /*num_bytes_written*/) override { |
102 info_->IncrementEndWriteDataCallCount(); | 102 info_->IncrementEndWriteDataCallCount(); |
103 lock().AssertAcquired(); | 103 lock().AssertAcquired(); |
104 return MOJO_RESULT_UNIMPLEMENTED; | 104 return MOJO_RESULT_UNIMPLEMENTED; |
105 } | 105 } |
106 | 106 |
107 virtual MojoResult ReadDataImplNoLock(UserPointer<void> /*elements*/, | 107 virtual MojoResult ReadDataImplNoLock(UserPointer<void> /*elements*/, |
108 UserPointer<uint32_t> /*num_bytes*/, | 108 UserPointer<uint32_t> /*num_bytes*/, |
109 MojoReadDataFlags /*flags*/) OVERRIDE { | 109 MojoReadDataFlags /*flags*/) override { |
110 info_->IncrementReadDataCallCount(); | 110 info_->IncrementReadDataCallCount(); |
111 lock().AssertAcquired(); | 111 lock().AssertAcquired(); |
112 return MOJO_RESULT_UNIMPLEMENTED; | 112 return MOJO_RESULT_UNIMPLEMENTED; |
113 } | 113 } |
114 | 114 |
115 virtual MojoResult BeginReadDataImplNoLock( | 115 virtual MojoResult BeginReadDataImplNoLock( |
116 UserPointer<const void*> /*buffer*/, | 116 UserPointer<const void*> /*buffer*/, |
117 UserPointer<uint32_t> /*buffer_num_bytes*/, | 117 UserPointer<uint32_t> /*buffer_num_bytes*/, |
118 MojoReadDataFlags /*flags*/) OVERRIDE { | 118 MojoReadDataFlags /*flags*/) override { |
119 info_->IncrementBeginReadDataCallCount(); | 119 info_->IncrementBeginReadDataCallCount(); |
120 lock().AssertAcquired(); | 120 lock().AssertAcquired(); |
121 return MOJO_RESULT_UNIMPLEMENTED; | 121 return MOJO_RESULT_UNIMPLEMENTED; |
122 } | 122 } |
123 | 123 |
124 virtual MojoResult EndReadDataImplNoLock( | 124 virtual MojoResult EndReadDataImplNoLock( |
125 uint32_t /*num_bytes_read*/) OVERRIDE { | 125 uint32_t /*num_bytes_read*/) override { |
126 info_->IncrementEndReadDataCallCount(); | 126 info_->IncrementEndReadDataCallCount(); |
127 lock().AssertAcquired(); | 127 lock().AssertAcquired(); |
128 return MOJO_RESULT_UNIMPLEMENTED; | 128 return MOJO_RESULT_UNIMPLEMENTED; |
129 } | 129 } |
130 | 130 |
131 virtual MojoResult AddWaiterImplNoLock( | 131 virtual MojoResult AddWaiterImplNoLock( |
132 Waiter* /*waiter*/, | 132 Waiter* /*waiter*/, |
133 MojoHandleSignals /*signals*/, | 133 MojoHandleSignals /*signals*/, |
134 uint32_t /*context*/, | 134 uint32_t /*context*/, |
135 HandleSignalsState* signals_state) OVERRIDE { | 135 HandleSignalsState* signals_state) override { |
136 info_->IncrementAddWaiterCallCount(); | 136 info_->IncrementAddWaiterCallCount(); |
137 lock().AssertAcquired(); | 137 lock().AssertAcquired(); |
138 if (signals_state) | 138 if (signals_state) |
139 *signals_state = HandleSignalsState(); | 139 *signals_state = HandleSignalsState(); |
140 return MOJO_RESULT_FAILED_PRECONDITION; | 140 return MOJO_RESULT_FAILED_PRECONDITION; |
141 } | 141 } |
142 | 142 |
143 virtual void RemoveWaiterImplNoLock( | 143 virtual void RemoveWaiterImplNoLock( |
144 Waiter* /*waiter*/, | 144 Waiter* /*waiter*/, |
145 HandleSignalsState* signals_state) OVERRIDE { | 145 HandleSignalsState* signals_state) override { |
146 info_->IncrementRemoveWaiterCallCount(); | 146 info_->IncrementRemoveWaiterCallCount(); |
147 lock().AssertAcquired(); | 147 lock().AssertAcquired(); |
148 if (signals_state) | 148 if (signals_state) |
149 *signals_state = HandleSignalsState(); | 149 *signals_state = HandleSignalsState(); |
150 } | 150 } |
151 | 151 |
152 virtual void CancelAllWaitersNoLock() OVERRIDE { | 152 virtual void CancelAllWaitersNoLock() override { |
153 info_->IncrementCancelAllWaitersCallCount(); | 153 info_->IncrementCancelAllWaitersCallCount(); |
154 lock().AssertAcquired(); | 154 lock().AssertAcquired(); |
155 } | 155 } |
156 | 156 |
157 virtual scoped_refptr<Dispatcher> | 157 virtual scoped_refptr<Dispatcher> |
158 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE { | 158 CreateEquivalentDispatcherAndCloseImplNoLock() override { |
159 return scoped_refptr<Dispatcher>(new MockDispatcher(info_)); | 159 return scoped_refptr<Dispatcher>(new MockDispatcher(info_)); |
160 } | 160 } |
161 | 161 |
162 CoreTestBase::MockHandleInfo* const info_; | 162 CoreTestBase::MockHandleInfo* const info_; |
163 | 163 |
164 DISALLOW_COPY_AND_ASSIGN(MockDispatcher); | 164 DISALLOW_COPY_AND_ASSIGN(MockDispatcher); |
165 }; | 165 }; |
166 | 166 |
167 } // namespace | 167 } // namespace |
168 | 168 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 } | 348 } |
349 | 349 |
350 void CoreTestBase_MockHandleInfo::IncrementCancelAllWaitersCallCount() { | 350 void CoreTestBase_MockHandleInfo::IncrementCancelAllWaitersCallCount() { |
351 base::AutoLock locker(lock_); | 351 base::AutoLock locker(lock_); |
352 cancel_all_waiters_call_count_++; | 352 cancel_all_waiters_call_count_++; |
353 } | 353 } |
354 | 354 |
355 } // namespace test | 355 } // namespace test |
356 } // namespace system | 356 } // namespace system |
357 } // namespace mojo | 357 } // namespace mojo |
OLD | NEW |