| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef UI_ACCELERATED_WIDGET_MAC_WINDOW_RESIZE_HELPER_MAC_H_ | 5 #ifndef UI_ACCELERATED_WIDGET_MAC_WINDOW_RESIZE_HELPER_MAC_H_ |
| 6 #define UI_ACCELERATED_WIDGET_MAC_WINDOW_RESIZE_HELPER_MAC_H_ | 6 #define UI_ACCELERATED_WIDGET_MAC_WINDOW_RESIZE_HELPER_MAC_H_ |
| 7 | 7 |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 class ACCELERATED_WIDGET_MAC_EXPORT WindowResizeHelperMac { | 46 class ACCELERATED_WIDGET_MAC_EXPORT WindowResizeHelperMac { |
| 47 public: | 47 public: |
| 48 static WindowResizeHelperMac* Get(); | 48 static WindowResizeHelperMac* Get(); |
| 49 | 49 |
| 50 // Initializes the pumpable task_runner(), providing it with the task runner | 50 // Initializes the pumpable task_runner(), providing it with the task runner |
| 51 // for UI thread tasks. task_runner() will be null before Init() is called, | 51 // for UI thread tasks. task_runner() will be null before Init() is called, |
| 52 // and WaitForSingleTaskToRun() will immediately return false. | 52 // and WaitForSingleTaskToRun() will immediately return false. |
| 53 void Init( | 53 void Init( |
| 54 const scoped_refptr<base::SingleThreadTaskRunner>& target_task_runner); | 54 const scoped_refptr<base::SingleThreadTaskRunner>& target_task_runner); |
| 55 | 55 |
| 56 // Because this class is global, many tests may want to do this setup |
| 57 // repeatedly, so need some way to uninitialize as well. |
| 58 void ShutdownForTests(); |
| 59 |
| 56 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const; | 60 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const; |
| 57 | 61 |
| 58 // UI THREAD ONLY ----------------------------------------------------------- | 62 // UI THREAD ONLY ----------------------------------------------------------- |
| 59 | 63 |
| 60 // Waits at most |max_delay| for a task to run. Returns true if a task ran, | 64 // Waits at most |max_delay| for a task to run. Returns true if a task ran, |
| 61 // false if no task ran. | 65 // false if no task ran. |
| 62 bool WaitForSingleTaskToRun(const base::TimeDelta& max_delay); | 66 bool WaitForSingleTaskToRun(const base::TimeDelta& max_delay); |
| 63 | 67 |
| 64 private: | 68 private: |
| 65 friend struct base::DefaultLazyInstanceTraits<WindowResizeHelperMac>; | 69 friend struct base::DefaultLazyInstanceTraits<WindowResizeHelperMac>; |
| 66 WindowResizeHelperMac(); | 70 WindowResizeHelperMac(); |
| 67 ~WindowResizeHelperMac(); | 71 ~WindowResizeHelperMac(); |
| 68 | 72 |
| 69 // This helper is needed to create a ScopedAllowWait inside the scope of a | 73 // This helper is needed to create a ScopedAllowWait inside the scope of a |
| 70 // class where it is allowed. | 74 // class where it is allowed. |
| 71 static void EventTimedWait(base::WaitableEvent* event, base::TimeDelta delay); | 75 static void EventTimedWait(base::WaitableEvent* event, base::TimeDelta delay); |
| 72 | 76 |
| 73 // The task runner to which the helper will post tasks. This also maintains | 77 // The task runner to which the helper will post tasks. This also maintains |
| 74 // the task queue and does the actual work for WaitForSingleTaskToRun. | 78 // the task queue and does the actual work for WaitForSingleTaskToRun. |
| 75 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 79 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 76 | 80 |
| 77 DISALLOW_COPY_AND_ASSIGN(WindowResizeHelperMac); | 81 DISALLOW_COPY_AND_ASSIGN(WindowResizeHelperMac); |
| 78 }; | 82 }; |
| 79 | 83 |
| 80 } // namespace ui | 84 } // namespace ui |
| 81 | 85 |
| 82 #endif // UI_ACCELERATED_WIDGET_MAC_WINDOW_RESIZE_HELPER_MAC_H_ | 86 #endif // UI_ACCELERATED_WIDGET_MAC_WINDOW_RESIZE_HELPER_MAC_H_ |
| OLD | NEW |