| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 ~MockDispatcher() override { info_->IncrementDtorCallCount(); } | 51 ~MockDispatcher() override { info_->IncrementDtorCallCount(); } |
| 52 | 52 |
| 53 // |Dispatcher| protected methods: | 53 // |Dispatcher| protected methods: |
| 54 void CloseImplNoLock() override { | 54 void CloseImplNoLock() override { |
| 55 info_->IncrementCloseCallCount(); | 55 info_->IncrementCloseCallCount(); |
| 56 mutex().AssertHeld(); | 56 mutex().AssertHeld(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 MojoResult DuplicateDispatcherImplNoLock( |
| 60 util::RefPtr<Dispatcher>* new_dispatcher) override { |
| 61 info_->IncrementDuplicateDispatcherCallCount(); |
| 62 *new_dispatcher = MockDispatcher::Create(info_); |
| 63 return MOJO_RESULT_OK; |
| 64 } |
| 65 |
| 59 MojoResult WriteMessageImplNoLock(UserPointer<const void> bytes, | 66 MojoResult WriteMessageImplNoLock(UserPointer<const void> bytes, |
| 60 uint32_t num_bytes, | 67 uint32_t num_bytes, |
| 61 std::vector<HandleTransport>* transports, | 68 std::vector<HandleTransport>* transports, |
| 62 MojoWriteMessageFlags /*flags*/) override { | 69 MojoWriteMessageFlags /*flags*/) override { |
| 63 info_->IncrementWriteMessageCallCount(); | 70 info_->IncrementWriteMessageCallCount(); |
| 64 mutex().AssertHeld(); | 71 mutex().AssertHeld(); |
| 65 | 72 |
| 66 if (num_bytes > GetConfiguration().max_message_num_bytes) | 73 if (num_bytes > GetConfiguration().max_message_num_bytes) |
| 67 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 74 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
| 68 | 75 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 unsigned CoreTestBase_MockHandleInfo::GetDtorCallCount() const { | 261 unsigned CoreTestBase_MockHandleInfo::GetDtorCallCount() const { |
| 255 MutexLocker locker(&mutex_); | 262 MutexLocker locker(&mutex_); |
| 256 return dtor_call_count_; | 263 return dtor_call_count_; |
| 257 } | 264 } |
| 258 | 265 |
| 259 unsigned CoreTestBase_MockHandleInfo::GetCloseCallCount() const { | 266 unsigned CoreTestBase_MockHandleInfo::GetCloseCallCount() const { |
| 260 MutexLocker locker(&mutex_); | 267 MutexLocker locker(&mutex_); |
| 261 return close_call_count_; | 268 return close_call_count_; |
| 262 } | 269 } |
| 263 | 270 |
| 271 unsigned CoreTestBase_MockHandleInfo::GetDuplicateDispatcherCallCount() const { |
| 272 MutexLocker locker(&mutex_); |
| 273 return duplicate_dispatcher_call_count_; |
| 274 } |
| 275 |
| 264 unsigned CoreTestBase_MockHandleInfo::GetWriteMessageCallCount() const { | 276 unsigned CoreTestBase_MockHandleInfo::GetWriteMessageCallCount() const { |
| 265 MutexLocker locker(&mutex_); | 277 MutexLocker locker(&mutex_); |
| 266 return write_message_call_count_; | 278 return write_message_call_count_; |
| 267 } | 279 } |
| 268 | 280 |
| 269 unsigned CoreTestBase_MockHandleInfo::GetReadMessageCallCount() const { | 281 unsigned CoreTestBase_MockHandleInfo::GetReadMessageCallCount() const { |
| 270 MutexLocker locker(&mutex_); | 282 MutexLocker locker(&mutex_); |
| 271 return read_message_call_count_; | 283 return read_message_call_count_; |
| 272 } | 284 } |
| 273 | 285 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 void CoreTestBase_MockHandleInfo::IncrementDtorCallCount() { | 362 void CoreTestBase_MockHandleInfo::IncrementDtorCallCount() { |
| 351 MutexLocker locker(&mutex_); | 363 MutexLocker locker(&mutex_); |
| 352 dtor_call_count_++; | 364 dtor_call_count_++; |
| 353 } | 365 } |
| 354 | 366 |
| 355 void CoreTestBase_MockHandleInfo::IncrementCloseCallCount() { | 367 void CoreTestBase_MockHandleInfo::IncrementCloseCallCount() { |
| 356 MutexLocker locker(&mutex_); | 368 MutexLocker locker(&mutex_); |
| 357 close_call_count_++; | 369 close_call_count_++; |
| 358 } | 370 } |
| 359 | 371 |
| 372 void CoreTestBase_MockHandleInfo::IncrementDuplicateDispatcherCallCount() { |
| 373 MutexLocker locker(&mutex_); |
| 374 duplicate_dispatcher_call_count_++; |
| 375 } |
| 376 |
| 360 void CoreTestBase_MockHandleInfo::IncrementWriteMessageCallCount() { | 377 void CoreTestBase_MockHandleInfo::IncrementWriteMessageCallCount() { |
| 361 MutexLocker locker(&mutex_); | 378 MutexLocker locker(&mutex_); |
| 362 write_message_call_count_++; | 379 write_message_call_count_++; |
| 363 } | 380 } |
| 364 | 381 |
| 365 void CoreTestBase_MockHandleInfo::IncrementReadMessageCallCount() { | 382 void CoreTestBase_MockHandleInfo::IncrementReadMessageCallCount() { |
| 366 MutexLocker locker(&mutex_); | 383 MutexLocker locker(&mutex_); |
| 367 read_message_call_count_++; | 384 read_message_call_count_++; |
| 368 } | 385 } |
| 369 | 386 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 455 } |
| 439 | 456 |
| 440 void CoreTestBase_MockHandleInfo::AwakableWasAdded(Awakable* awakable) { | 457 void CoreTestBase_MockHandleInfo::AwakableWasAdded(Awakable* awakable) { |
| 441 MutexLocker locker(&mutex_); | 458 MutexLocker locker(&mutex_); |
| 442 added_awakables_.push_back(awakable); | 459 added_awakables_.push_back(awakable); |
| 443 } | 460 } |
| 444 | 461 |
| 445 } // namespace test | 462 } // namespace test |
| 446 } // namespace system | 463 } // namespace system |
| 447 } // namespace mojo | 464 } // namespace mojo |
| OLD | NEW |