| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |