| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mock_simple_dispatcher.h" | 5 #include "mojo/edk/system/mock_simple_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/edk/util/thread_annotations.h" | 8 #include "mojo/edk/util/thread_annotations.h" |
| 9 | 9 |
| 10 using mojo::util::MakeRefCounted; | 10 using mojo::util::MakeRefCounted; |
| 11 using mojo::util::MutexLocker; | 11 using mojo::util::MutexLocker; |
| 12 using mojo::util::RefPtr; | 12 using mojo::util::RefPtr; |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 namespace system { | 15 namespace system { |
| 16 namespace test { | 16 namespace test { |
| 17 | 17 |
| 18 void MockSimpleDispatcher::SetSatisfiedSignals( | 18 void MockSimpleDispatcher::SetSatisfiedSignals( |
| 19 MojoHandleSignals new_satisfied_signals) { | 19 MojoHandleSignals new_satisfied_signals) { |
| 20 MutexLocker locker(&mutex()); | 20 MutexLocker locker(&mutex()); |
| 21 | 21 |
| 22 // Any new signals that are set should be satisfiable. | 22 // Any new signals that are set should be satisfiable. |
| 23 CHECK_EQ(new_satisfied_signals & ~state_.satisfied_signals, | 23 CHECK_EQ(new_satisfied_signals & ~state_.satisfied_signals, |
| 24 new_satisfied_signals & ~state_.satisfied_signals & | 24 new_satisfied_signals & ~state_.satisfied_signals & |
| 25 state_.satisfiable_signals); | 25 state_.satisfiable_signals); |
| 26 | 26 |
| 27 if (new_satisfied_signals == state_.satisfied_signals) | 27 if (new_satisfied_signals == state_.satisfied_signals) |
| 28 return; | 28 return; |
| 29 | 29 |
| 30 HandleSignalsState old_state = state_; |
| 30 state_.satisfied_signals = new_satisfied_signals; | 31 state_.satisfied_signals = new_satisfied_signals; |
| 31 HandleSignalsStateChangedNoLock(); | 32 OnHandleSignalsStateChangeNoLock(old_state, state_); |
| 32 } | 33 } |
| 33 | 34 |
| 34 void MockSimpleDispatcher::SetSatisfiableSignals( | 35 void MockSimpleDispatcher::SetSatisfiableSignals( |
| 35 MojoHandleSignals new_satisfiable_signals) { | 36 MojoHandleSignals new_satisfiable_signals) { |
| 36 MutexLocker locker(&mutex()); | 37 MutexLocker locker(&mutex()); |
| 37 | 38 |
| 38 // Satisfied implies satisfiable. | 39 // Satisfied implies satisfiable. |
| 39 CHECK_EQ(new_satisfiable_signals & state_.satisfied_signals, | 40 CHECK_EQ(new_satisfiable_signals & state_.satisfied_signals, |
| 40 state_.satisfied_signals); | 41 state_.satisfied_signals); |
| 41 | 42 |
| 42 if (new_satisfiable_signals == state_.satisfiable_signals) | 43 if (new_satisfiable_signals == state_.satisfiable_signals) |
| 43 return; | 44 return; |
| 44 | 45 |
| 46 HandleSignalsState old_state = state_; |
| 45 state_.satisfiable_signals = new_satisfiable_signals; | 47 state_.satisfiable_signals = new_satisfiable_signals; |
| 46 HandleSignalsStateChangedNoLock(); | 48 OnHandleSignalsStateChangeNoLock(old_state, state_); |
| 47 } | 49 } |
| 48 | 50 |
| 49 Dispatcher::Type MockSimpleDispatcher::GetType() const { | 51 Dispatcher::Type MockSimpleDispatcher::GetType() const { |
| 50 return Type::UNKNOWN; | 52 return Type::UNKNOWN; |
| 51 } | 53 } |
| 52 | 54 |
| 53 bool MockSimpleDispatcher::SupportsEntrypointClass( | 55 bool MockSimpleDispatcher::SupportsEntrypointClass( |
| 54 EntrypointClass entrypoint_class) const { | 56 EntrypointClass entrypoint_class) const { |
| 55 return (entrypoint_class == EntrypointClass::NONE); | 57 return (entrypoint_class == EntrypointClass::NONE); |
| 56 } | 58 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 | 83 |
| 82 HandleSignalsState MockSimpleDispatcher::GetHandleSignalsStateImplNoLock() | 84 HandleSignalsState MockSimpleDispatcher::GetHandleSignalsStateImplNoLock() |
| 83 const { | 85 const { |
| 84 mutex().AssertHeld(); | 86 mutex().AssertHeld(); |
| 85 return state_; | 87 return state_; |
| 86 } | 88 } |
| 87 | 89 |
| 88 } // namespace test | 90 } // namespace test |
| 89 } // namespace system | 91 } // namespace system |
| 90 } // namespace mojo | 92 } // namespace mojo |
| OLD | NEW |