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

Side by Side Diff: net/tools/quic/test_tools/server_thread.cc

Issue 2430973004: Landing Recent QUIC changes until 10:38 AM, Oct 17, 2016 UTC-4 (Closed)
Patch Set: Improving flagsaver logging Created 4 years, 2 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/tools/quic/test_tools/server_thread.h ('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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 if (!initialized_) { 54 if (!initialized_) {
55 Initialize(); 55 Initialize();
56 } 56 }
57 57
58 while (!quit_.IsSignaled()) { 58 while (!quit_.IsSignaled()) {
59 if (pause_.IsSignaled() && !resume_.IsSignaled()) { 59 if (pause_.IsSignaled() && !resume_.IsSignaled()) {
60 paused_.Signal(); 60 paused_.Signal();
61 resume_.Wait(); 61 resume_.Wait();
62 } 62 }
63 server_->WaitForEvents(); 63 server_->WaitForEvents();
64 ExecuteScheduledActions();
64 MaybeNotifyOfHandshakeConfirmation(); 65 MaybeNotifyOfHandshakeConfirmation();
65 } 66 }
66 67
67 server_->Shutdown(); 68 server_->Shutdown();
68 } 69 }
69 70
70 int ServerThread::GetPort() { 71 int ServerThread::GetPort() {
71 port_lock_.Acquire(); 72 port_lock_.Acquire();
72 int rc = port_; 73 int rc = port_;
73 port_lock_.Release(); 74 port_lock_.Release();
74 return rc; 75 return rc;
75 } 76 }
76 77
78 void ServerThread::Schedule(std::function<void()> action) {
79 DCHECK(!quit_.IsSignaled());
80 base::AutoLock lock(scheduled_actions_lock_);
81 scheduled_actions_.push_back(std::move(action));
82 }
83
77 void ServerThread::WaitForCryptoHandshakeConfirmed() { 84 void ServerThread::WaitForCryptoHandshakeConfirmed() {
78 confirmed_.Wait(); 85 confirmed_.Wait();
79 } 86 }
80 87
81 void ServerThread::Pause() { 88 void ServerThread::Pause() {
82 DCHECK(!pause_.IsSignaled()); 89 DCHECK(!pause_.IsSignaled());
83 pause_.Signal(); 90 pause_.Signal();
84 paused_.Wait(); 91 paused_.Wait();
85 } 92 }
86 93
(...skipping 19 matching lines...) Expand all
106 if (dispatcher->session_map().empty()) { 113 if (dispatcher->session_map().empty()) {
107 // Wait for a session to be created. 114 // Wait for a session to be created.
108 return; 115 return;
109 } 116 }
110 QuicSession* session = dispatcher->session_map().begin()->second; 117 QuicSession* session = dispatcher->session_map().begin()->second;
111 if (session->IsCryptoHandshakeConfirmed()) { 118 if (session->IsCryptoHandshakeConfirmed()) {
112 confirmed_.Signal(); 119 confirmed_.Signal();
113 } 120 }
114 } 121 }
115 122
123 void ServerThread::ExecuteScheduledActions() {
124 std::deque<std::function<void()>> actions;
125 {
126 base::AutoLock lock(scheduled_actions_lock_);
127 actions.swap(scheduled_actions_);
128 }
129 while (!actions.empty()) {
130 actions.front()();
131 actions.pop_front();
132 }
133 }
134
116 } // namespace test 135 } // namespace test
117 } // namespace net 136 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/server_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698