| 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/edk/system/core_test_base.h" | 5 #include "mojo/edk/system/core_test_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class MockDispatcher : public Dispatcher { | 28 class MockDispatcher : public Dispatcher { |
| 29 public: | 29 public: |
| 30 static scoped_refptr<MockDispatcher> Create( | 30 static scoped_refptr<MockDispatcher> Create( |
| 31 CoreTestBase::MockHandleInfo* info) { | 31 CoreTestBase::MockHandleInfo* info) { |
| 32 return make_scoped_refptr(new MockDispatcher(info)); | 32 return make_scoped_refptr(new MockDispatcher(info)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Dispatcher: | 35 // Dispatcher: |
| 36 Type GetType() const override { return Type::UNKNOWN; } | 36 Type GetType() const override { return Type::UNKNOWN; } |
| 37 | 37 |
| 38 MojoResult Close() override { | 38 MojoResult Close(RequestContext* request_context) override { |
| 39 info_->IncrementCloseCallCount(); | 39 info_->IncrementCloseCallCount(); |
| 40 return MOJO_RESULT_OK; | 40 return MOJO_RESULT_OK; |
| 41 } | 41 } |
| 42 | 42 |
| 43 MojoResult WriteMessage( | 43 MojoResult WriteMessage( |
| 44 const void* bytes, | 44 const void* bytes, |
| 45 uint32_t num_bytes, | 45 uint32_t num_bytes, |
| 46 const DispatcherInTransit* dispatchers, | 46 const DispatcherInTransit* dispatchers, |
| 47 uint32_t num_dispatchers, | 47 uint32_t num_dispatchers, |
| 48 MojoWriteMessageFlags /*flags*/) override { | 48 MojoWriteMessageFlags /*flags*/, |
| 49 RequestContext* request_context) override { |
| 49 info_->IncrementWriteMessageCallCount(); | 50 info_->IncrementWriteMessageCallCount(); |
| 50 | 51 |
| 51 if (num_bytes > GetConfiguration().max_message_num_bytes) | 52 if (num_bytes > GetConfiguration().max_message_num_bytes) |
| 52 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 53 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
| 53 | 54 |
| 54 if (dispatchers) | 55 if (dispatchers) |
| 55 return MOJO_RESULT_UNIMPLEMENTED; | 56 return MOJO_RESULT_UNIMPLEMENTED; |
| 56 | 57 |
| 57 return MOJO_RESULT_OK; | 58 return MOJO_RESULT_OK; |
| 58 } | 59 } |
| 59 | 60 |
| 60 MojoResult ReadMessage(void* bytes, | 61 MojoResult ReadMessage(void* bytes, |
| 61 uint32_t* num_bytes, | 62 uint32_t* num_bytes, |
| 62 MojoHandle* handle, | 63 MojoHandle* handle, |
| 63 uint32_t* num_handles, | 64 uint32_t* num_handles, |
| 64 MojoReadMessageFlags /*flags*/) override { | 65 MojoReadMessageFlags /*flags*/, |
| 66 RequestContext* request_context) override { |
| 65 info_->IncrementReadMessageCallCount(); | 67 info_->IncrementReadMessageCallCount(); |
| 66 | 68 |
| 67 if (num_handles) | 69 if (num_handles) |
| 68 *num_handles = 1; | 70 *num_handles = 1; |
| 69 | 71 |
| 70 return MOJO_RESULT_OK; | 72 return MOJO_RESULT_OK; |
| 71 } | 73 } |
| 72 | 74 |
| 73 MojoResult WriteData(const void* elements, | 75 MojoResult WriteData(const void* elements, |
| 74 uint32_t* num_bytes, | 76 uint32_t* num_bytes, |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 337 } |
| 336 | 338 |
| 337 void CoreTestBase_MockHandleInfo::AwakableWasAdded(Awakable* awakable) { | 339 void CoreTestBase_MockHandleInfo::AwakableWasAdded(Awakable* awakable) { |
| 338 base::AutoLock locker(lock_); | 340 base::AutoLock locker(lock_); |
| 339 added_awakables_.push_back(awakable); | 341 added_awakables_.push_back(awakable); |
| 340 } | 342 } |
| 341 | 343 |
| 342 } // namespace test | 344 } // namespace test |
| 343 } // namespace edk | 345 } // namespace edk |
| 344 } // namespace mojo | 346 } // namespace mojo |
| OLD | NEW |