| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_ENGINE_BROWSER_TESTS_WAITABLE_CONTENT_PUMP_H_ | |
| 6 #define BLIMP_ENGINE_BROWSER_TESTS_WAITABLE_CONTENT_PUMP_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/synchronization/waitable_event.h" | |
| 10 | |
| 11 namespace blimp { | |
| 12 | |
| 13 // A helper class to suspend execution on the current stack and still allow all | |
| 14 // content message loops to run until a WaitableEvent is signaled. This | |
| 15 // currently only pumps the UI, IO, and FILE threads. The typical use case | |
| 16 // would look like: | |
| 17 // | |
| 18 // WaitableContentPump waiter; | |
| 19 // GiveEventToSomeoneToEventuallySignal(waiter.event()); | |
| 20 // waiter.Wait(); | |
| 21 class WaitableContentPump { | |
| 22 public: | |
| 23 WaitableContentPump(); | |
| 24 virtual ~WaitableContentPump(); | |
| 25 | |
| 26 // Pumps content message loops until |event| is signaled. This will reset | |
| 27 // |event| afterwards. | |
| 28 static void WaitFor(base::WaitableEvent* event); | |
| 29 | |
| 30 // Helper methods to use the WaitableContentPump without needing to build a | |
| 31 // WaitableEvent. | |
| 32 base::WaitableEvent* event() { return &event_; } | |
| 33 void Wait(); | |
| 34 | |
| 35 private: | |
| 36 base::WaitableEvent event_; | |
| 37 | |
| 38 DISALLOW_COPY_AND_ASSIGN(WaitableContentPump); | |
| 39 }; | |
| 40 | |
| 41 } // namespace blimp | |
| 42 | |
| 43 #endif // BLIMP_ENGINE_BROWSER_TESTS_WAITABLE_CONTENT_PUMP_H_ | |
| OLD | NEW |