Index: media/blink/waiter_index.h |
diff --git a/media/blink/waiter_index.h b/media/blink/waiter_index.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..83f44344c3a22ecf34dc7c6a56c1326b885c5aeb |
--- /dev/null |
+++ b/media/blink/waiter_index.h |
@@ -0,0 +1,44 @@ |
+// Copyright 2013 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 MEDIA_BLINK_WAITER_INDEX_H_ |
+#define MEDIA_BLINK_WAITER_INDEX_H_ |
+ |
+#include <map> |
+#include <set> |
+ |
+namespace media { |
+ |
+class Waiter { |
+public: |
+ virtual ~Waiter() {} |
+ virtual void Continue() = 0; |
+}; |
+ |
+class WaiterIndex { |
+public: |
+ WaiterIndex(); |
+ ~WaiterIndex(); |
+ // Register a waiter at position |pos|. |
+ void WaitFor(int32_t pos, Waiter* waiter); |
+ // Unregister a waiter, |pos| should be the same |
+ // position as given to WaitFor(). |
+ void StopWaitFor(int32_t pos, Waiter* waiter); |
+ // Wake up all waiters waiting at |pos|. |
+ void WakeUp(int32_t pos); |
+ // Delete all waiters. Makes it possible for |
+ // for this class to own waiters. |
+ void DeleteWaiters(); |
+ |
+ const std::map<int32_t, std::set<Waiter*> > map() const { |
+ return waiters_; |
+ } |
+ |
+ private: |
+ std::map<int32_t, std::set<Waiter*> > waiters_; |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BLINK_WAITER_INDEX_H |