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

Side by Side Diff: net/proxy/multi_threaded_proxy_resolver_unittest.cc

Issue 2030663002: Migrate WaitableEvent to enum-based constructor in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: Created 4 years, 6 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/log/net_log_unittest.cc ('k') | net/proxy/proxy_config_service_linux_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/proxy/multi_threaded_proxy_resolver.h" 5 #include "net/proxy/multi_threaded_proxy_resolver.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 // A mock synchronous ProxyResolver which can be set to block upon reaching 93 // A mock synchronous ProxyResolver which can be set to block upon reaching
94 // GetProxyForURL(). 94 // GetProxyForURL().
95 // TODO(eroman): WaitUntilBlocked() *must* be called before calling Unblock(), 95 // TODO(eroman): WaitUntilBlocked() *must* be called before calling Unblock(),
96 // otherwise there will be a race on |should_block_| since it is 96 // otherwise there will be a race on |should_block_| since it is
97 // read without any synchronization. 97 // read without any synchronization.
98 class BlockableProxyResolver : public MockProxyResolver { 98 class BlockableProxyResolver : public MockProxyResolver {
99 public: 99 public:
100 BlockableProxyResolver() 100 BlockableProxyResolver()
101 : should_block_(false), 101 : should_block_(false),
102 unblocked_(true, true), 102 unblocked_(base::WaitableEvent::ResetPolicy::MANUAL,
103 blocked_(true, false) { 103 base::WaitableEvent::InitialState::SIGNALED),
104 } 104 blocked_(base::WaitableEvent::ResetPolicy::MANUAL,
105 base::WaitableEvent::InitialState::NOT_SIGNALED) {}
105 106
106 void Block() { 107 void Block() {
107 should_block_ = true; 108 should_block_ = true;
108 unblocked_.Reset(); 109 unblocked_.Reset();
109 } 110 }
110 111
111 void Unblock() { 112 void Unblock() {
112 should_block_ = false; 113 should_block_ = false;
113 blocked_.Reset(); 114 blocked_.Reset();
114 unblocked_.Signal(); 115 unblocked_.Signal();
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 } 774 }
774 // The factory destructor will block until the worker thread stops, but it may 775 // The factory destructor will block until the worker thread stops, but it may
775 // post tasks to the origin message loop which are still pending. Run them 776 // post tasks to the origin message loop which are still pending. Run them
776 // now to ensure it works as expected. 777 // now to ensure it works as expected.
777 base::RunLoop().RunUntilIdle(); 778 base::RunLoop().RunUntilIdle();
778 } 779 }
779 780
780 } // namespace 781 } // namespace
781 782
782 } // namespace net 783 } // namespace net
OLDNEW
« no previous file with comments | « net/log/net_log_unittest.cc ('k') | net/proxy/proxy_config_service_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698