Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: net/test/event_waiter.h

Issue 904313003: Implement utility-side host resolver Mojo client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-proxy-resolver
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/net.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_TEST_EVENT_WAITER_H_
6 #define NET_TEST_EVENT_WAITER_H_
7
8 #include "base/run_loop.h"
9
10 namespace net {
11
12 // Helper class to run a RunLoop until an expected event is reported.
13 template <typename Event>
14 class EventWaiter {
15 public:
16 // Runs a RunLoop until NotifyEvent() is called with |event|.
17 void WaitForEvent(Event event) {
18 expected_event_ = event;
19 base::RunLoop run_loop;
20 quit_closure_ = run_loop.QuitClosure();
21 run_loop.Run();
22 }
23
24 // Unblocks a WaitForEvent() call if it was called with |event|. Otherwise,
25 // has no effect.
26 void NotifyEvent(Event event) {
27 if (event == expected_event_ && !quit_closure_.is_null()) {
28 quit_closure_.Run();
29 quit_closure_.Reset();
30 }
31 }
32
33 private:
34 Event expected_event_;
35 base::Closure quit_closure_;
36 };
37
38 } // namespace net
39
40 #endif // NET_TEST_EVENT_WAITER_H_
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698