Chromium Code Reviews| Index: blimp/engine/browser_tests/waitable_content_pump.h |
| diff --git a/blimp/engine/browser_tests/waitable_content_pump.h b/blimp/engine/browser_tests/waitable_content_pump.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a6e956013a82172ffec0ad1d009ad7d7a081b654 |
| --- /dev/null |
| +++ b/blimp/engine/browser_tests/waitable_content_pump.h |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2016 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 BLIMP_ENGINE_BROWSER_TESTS_WAITABLE_CONTENT_PUMP_H_ |
| +#define BLIMP_ENGINE_BROWSER_TESTS_WAITABLE_CONTENT_PUMP_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/synchronization/waitable_event.h" |
| + |
| +namespace blimp { |
| + |
| +// A helper class to suspend execution on the current stack and still allow all |
| +// content message loops to run until a WaitableEvent is signaled. This |
| +// currently only pumps the UI, IO, and FILE threads. The typical use case |
| +// would look like: |
| +// |
| +// WaitableContentPump waiter; |
| +// GiveEventToSomeoneToEventuallySignal(waiter.event()); |
| +// waiter.Wait(); |
|
Khushal
2016/09/13 23:47:10
Awesome comment. Thanks!
David Trainor- moved to gerrit
2016/09/14 00:31:09
Acknowledged.
|
| +class WaitableContentPump { |
| + public: |
| + WaitableContentPump(); |
| + virtual ~WaitableContentPump(); |
| + |
| + // Helper methods to use the WaitableContentPump without needing to build a |
| + // WaitableEvent. |
| + base::WaitableEvent* event() { return &event_; } |
| + void Wait(); |
| + |
| + // Pumps content message loops until |event| is signaled. This will reset |
| + // |event| afterwards. |
| + 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.
|
| + |
| + private: |
| + base::WaitableEvent event_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WaitableContentPump); |
| +}; |
| + |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_ENGINE_BROWSER_TESTS_WAITABLE_CONTENT_PUMP_H_ |