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 // This file contains helper classes for video accelerator unittests. | 5 // This file contains helper classes for video accelerator unittests. |
6 | 6 |
7 #ifndef CONTENT_COMMON_GPU_MEDIA_VIDEO_ACCELERATOR_UNITTEST_HELPERS_H_ | 7 #ifndef MEDIA_GPU_VIDEO_ACCELERATOR_UNITTEST_HELPERS_H_ |
8 #define CONTENT_COMMON_GPU_MEDIA_VIDEO_ACCELERATOR_UNITTEST_HELPERS_H_ | 8 #define MEDIA_GPU_VIDEO_ACCELERATOR_UNITTEST_HELPERS_H_ |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
11 | 11 |
12 #include "base/synchronization/condition_variable.h" | 12 #include "base/synchronization/condition_variable.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 | 14 |
15 namespace content { | 15 namespace media { |
16 | 16 |
17 // Helper class allowing one thread to wait on a notification from another. | 17 // Helper class allowing one thread to wait on a notification from another. |
18 // If notifications come in faster than they are Wait()'d for, they are | 18 // If notifications come in faster than they are Wait()'d for, they are |
19 // accumulated (so exactly as many Wait() calls will unblock as Notify() calls | 19 // accumulated (so exactly as many Wait() calls will unblock as Notify() calls |
20 // were made, regardless of order). | 20 // were made, regardless of order). |
21 template <typename StateEnum> | 21 template <typename StateEnum> |
22 class ClientStateNotification { | 22 class ClientStateNotification { |
23 public: | 23 public: |
24 ClientStateNotification(); | 24 ClientStateNotification(); |
25 ~ClientStateNotification(); | 25 ~ClientStateNotification(); |
(...skipping 25 matching lines...) Expand all Loading... |
51 template <typename StateEnum> | 51 template <typename StateEnum> |
52 StateEnum ClientStateNotification<StateEnum>::Wait() { | 52 StateEnum ClientStateNotification<StateEnum>::Wait() { |
53 base::AutoLock auto_lock(lock_); | 53 base::AutoLock auto_lock(lock_); |
54 while (pending_states_for_notification_.empty()) | 54 while (pending_states_for_notification_.empty()) |
55 cv_.Wait(); | 55 cv_.Wait(); |
56 StateEnum ret = pending_states_for_notification_.front(); | 56 StateEnum ret = pending_states_for_notification_.front(); |
57 pending_states_for_notification_.pop(); | 57 pending_states_for_notification_.pop(); |
58 return ret; | 58 return ret; |
59 } | 59 } |
60 | 60 |
61 } // namespace content | 61 } // namespace media |
62 | 62 |
63 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_ACCELERATOR_UNITTEST_HELPERS_H_ | 63 #endif // MEDIA_GPU_VIDEO_ACCELERATOR_UNITTEST_HELPERS_H_ |
OLD | NEW |