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

Unified Diff: cc/test/thread_blocker.h

Issue 671653005: SetNeedsRedraw directly when updating a visible tile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pinchblurmerge-test: testfix Created 6 years, 1 month 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
Index: cc/test/thread_blocker.h
diff --git a/cc/test/thread_blocker.h b/cc/test/thread_blocker.h
new file mode 100644
index 0000000000000000000000000000000000000000..d7ab0b829cf720d3b72f665498ab98b68c6a5a3f
--- /dev/null
+++ b/cc/test/thread_blocker.h
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_TEST_THREAD_BLOCKER_H_
+#define CC_TEST_THREAD_BLOCKER_H_
+
+#include "base/synchronization/lock.h"
+#include "base/synchronization/waitable_event.h"
+
+namespace cc {
+
+// This class will block inside the Wait() function after BlockWait() has been
+// called until UnblockWait() is called. Because Wait() blocks, the
+// UnblockWait() call must be done from another thread, so this class is safe to
+// use on multiple threads.
+class ThreadBlocker {
+ public:
+ ThreadBlocker();
+ ~ThreadBlocker();
+
+ // This will block if BlockWait() has been called until UnblockWait() is
+ // called.
+ void Wait();
+
+ // Makes future calls to Wait() block.
+ void BlockWait();
+ // Unblocks any current calls to Wait() and prevents future calls from
+ // blocking.
+ void UnblockWait();
+
+ private:
+ base::Lock lock_;
+ bool should_delay_;
+ base::WaitableEvent waiter_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadBlocker);
+};
+
+} // namespace cc
+
+#endif // CC_TEST_THREAD_BLOCKER_H_

Powered by Google App Engine
This is Rietveld 408576698