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

Unified Diff: mojo/system/simple_dispatcher_unittest.cc

Issue 325213004: Mojo: Wrap the satisfied/unsatisfied wait flags state in a single object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/system/simple_dispatcher.cc ('k') | mojo/system/wait_flags_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/simple_dispatcher_unittest.cc
diff --git a/mojo/system/simple_dispatcher_unittest.cc b/mojo/system/simple_dispatcher_unittest.cc
index 6f232693ab658e1662d121caf4e2b5e44100f14e..26fc2773aff008ee4edcd218c8914f086301b788 100644
--- a/mojo/system/simple_dispatcher_unittest.cc
+++ b/mojo/system/simple_dispatcher_unittest.cc
@@ -28,31 +28,36 @@ namespace {
class MockSimpleDispatcher : public SimpleDispatcher {
public:
MockSimpleDispatcher()
- : satisfied_flags_(MOJO_WAIT_FLAG_NONE),
- satisfiable_flags_(MOJO_WAIT_FLAG_READABLE | MOJO_WAIT_FLAG_WRITABLE) {}
+ : state_(MOJO_WAIT_FLAG_NONE,
+ MOJO_WAIT_FLAG_READABLE | MOJO_WAIT_FLAG_WRITABLE) {}
void SetSatisfiedFlags(MojoWaitFlags new_satisfied_flags) {
base::AutoLock locker(lock());
// Any new flags that are set should be satisfiable.
- CHECK_EQ(new_satisfied_flags & ~satisfied_flags_,
- new_satisfied_flags & ~satisfied_flags_ & satisfiable_flags_);
+ CHECK_EQ(new_satisfied_flags & ~state_.satisfied_flags,
+ new_satisfied_flags & ~state_.satisfied_flags &
+ state_.satisfiable_flags);
- if (new_satisfied_flags == satisfied_flags_)
+ if (new_satisfied_flags == state_.satisfied_flags)
return;
- satisfied_flags_ = new_satisfied_flags;
- StateChangedNoLock();
+ state_.satisfied_flags = new_satisfied_flags;
+ WaitFlagsStateChangedNoLock();
}
void SetSatisfiableFlags(MojoWaitFlags new_satisfiable_flags) {
base::AutoLock locker(lock());
- if (new_satisfiable_flags == satisfiable_flags_)
+ // Satisfied implies satisfiable.
+ CHECK_EQ(new_satisfiable_flags & state_.satisfied_flags,
+ state_.satisfied_flags);
+
+ if (new_satisfiable_flags == state_.satisfiable_flags)
return;
- satisfiable_flags_ = new_satisfiable_flags;
- StateChangedNoLock();
+ state_.satisfiable_flags = new_satisfiable_flags;
+ WaitFlagsStateChangedNoLock();
}
virtual Type GetType() const OVERRIDE {
@@ -66,25 +71,18 @@ class MockSimpleDispatcher : public SimpleDispatcher {
virtual scoped_refptr<Dispatcher>
CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE {
scoped_refptr<MockSimpleDispatcher> rv(new MockSimpleDispatcher());
- rv->satisfied_flags_ = satisfied_flags_;
- rv->satisfiable_flags_ = satisfiable_flags_;
+ rv->state_ = state_;
return scoped_refptr<Dispatcher>(rv.get());
}
// |SimpleDispatcher| implementation:
- virtual MojoWaitFlags SatisfiedFlagsNoLock() const OVERRIDE {
- lock().AssertAcquired();
- return satisfied_flags_;
- }
-
- virtual MojoWaitFlags SatisfiableFlagsNoLock() const OVERRIDE {
+ virtual WaitFlagsState GetWaitFlagsStateNoLock() const OVERRIDE {
lock().AssertAcquired();
- return satisfiable_flags_;
+ return state_;
}
// Protected by |lock()|:
- MojoWaitFlags satisfied_flags_;
- MojoWaitFlags satisfiable_flags_;
+ WaitFlagsState state_;
DISALLOW_COPY_AND_ASSIGN(MockSimpleDispatcher);
};
« no previous file with comments | « mojo/system/simple_dispatcher.cc ('k') | mojo/system/wait_flags_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698