| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tools/quic/test_tools/server_thread.h" | 5 #include "net/tools/quic/test_tools/server_thread.h" |
| 6 | 6 |
| 7 #include "net/quic/test_tools/crypto_test_utils.h" | 7 #include "net/quic/test_tools/crypto_test_utils.h" |
| 8 #include "net/tools/quic/quic_dispatcher.h" | 8 #include "net/tools/quic/quic_dispatcher.h" |
| 9 #include "net/tools/quic/test_tools/quic_server_peer.h" | 9 #include "net/tools/quic/test_tools/quic_server_peer.h" |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 int ServerThread::GetPort() { | 65 int ServerThread::GetPort() { |
| 66 port_lock_.Acquire(); | 66 port_lock_.Acquire(); |
| 67 int rc = port_; | 67 int rc = port_; |
| 68 port_lock_.Release(); | 68 port_lock_.Release(); |
| 69 return rc; | 69 return rc; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ServerThread::Schedule(std::function<void()> action) { | 72 void ServerThread::Schedule(std::function<void()> action) { |
| 73 DCHECK(!quit_.IsSignaled()); | 73 DCHECK(!quit_.IsSignaled()); |
| 74 base::AutoLock lock(scheduled_actions_lock_); | 74 QuicWriterMutexLock lock(&scheduled_actions_lock_); |
| 75 scheduled_actions_.push_back(std::move(action)); | 75 scheduled_actions_.push_back(std::move(action)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void ServerThread::WaitForCryptoHandshakeConfirmed() { | 78 void ServerThread::WaitForCryptoHandshakeConfirmed() { |
| 79 confirmed_.Wait(); | 79 confirmed_.Wait(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void ServerThread::Pause() { | 82 void ServerThread::Pause() { |
| 83 DCHECK(!pause_.IsSignaled()); | 83 DCHECK(!pause_.IsSignaled()); |
| 84 pause_.Signal(); | 84 pause_.Signal(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 110 } | 110 } |
| 111 QuicSession* session = dispatcher->session_map().begin()->second.get(); | 111 QuicSession* session = dispatcher->session_map().begin()->second.get(); |
| 112 if (session->IsCryptoHandshakeConfirmed()) { | 112 if (session->IsCryptoHandshakeConfirmed()) { |
| 113 confirmed_.Signal(); | 113 confirmed_.Signal(); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ServerThread::ExecuteScheduledActions() { | 117 void ServerThread::ExecuteScheduledActions() { |
| 118 std::deque<std::function<void()>> actions; | 118 std::deque<std::function<void()>> actions; |
| 119 { | 119 { |
| 120 base::AutoLock lock(scheduled_actions_lock_); | 120 QuicWriterMutexLock lock(&scheduled_actions_lock_); |
| 121 actions.swap(scheduled_actions_); | 121 actions.swap(scheduled_actions_); |
| 122 } | 122 } |
| 123 while (!actions.empty()) { | 123 while (!actions.empty()) { |
| 124 actions.front()(); | 124 actions.front()(); |
| 125 actions.pop_front(); | 125 actions.pop_front(); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace test | 129 } // namespace test |
| 130 } // namespace net | 130 } // namespace net |
| OLD | NEW |