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(); | |
Khushal
2016/09/13 23:47:10
Awesome comment. Thanks!
David Trainor- moved to gerrit
2016/09/14 00:31:09
Acknowledged.
| |
21 class WaitableContentPump { | |
22 public: | |
23 WaitableContentPump(); | |
24 virtual ~WaitableContentPump(); | |
25 | |
26 // Helper methods to use the WaitableContentPump without needing to build a | |
27 // WaitableEvent. | |
28 base::WaitableEvent* event() { return &event_; } | |
29 void Wait(); | |
30 | |
31 // Pumps content message loops until |event| is signaled. This will reset | |
32 // |event| afterwards. | |
33 void WaitFor(base::WaitableEvent* event); | |
Khushal
2016/09/13 23:47:10
If this is meant to be just a helper method for ot
David Trainor- moved to gerrit
2016/09/14 00:31:09
Done.
| |
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 |