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

Side by Side Diff: net/tools/quic/quic_server.cc

Issue 331963002: Test tools for udp proxying. This involves a few refactors of test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « net/tools/quic/quic_server.h ('k') | net/tools/quic/test_tools/server_thread.h » ('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/tools/quic/quic_server.h" 5 #include "net/tools/quic/quic_server.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <features.h> 8 #include <features.h>
9 #include <netinet/in.h> 9 #include <netinet/in.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 || 155 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 ||
156 !server_address.FromSockAddr(storage.addr, storage.addr_len)) { 156 !server_address.FromSockAddr(storage.addr, storage.addr_len)) {
157 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno); 157 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno);
158 return false; 158 return false;
159 } 159 }
160 port_ = server_address.port(); 160 port_ = server_address.port();
161 DVLOG(1) << "Kernel assigned port is " << port_; 161 DVLOG(1) << "Kernel assigned port is " << port_;
162 } 162 }
163 163
164 epoll_server_.RegisterFD(fd_, this, kEpollFlags); 164 epoll_server_.RegisterFD(fd_, this, kEpollFlags);
165 dispatcher_.reset(new QuicDispatcher( 165 dispatcher_.reset(CreateQuicDispatcher());
166 config_,
167 crypto_config_,
168 supported_versions_,
169 &epoll_server_));
170 dispatcher_->Initialize(fd_); 166 dispatcher_->Initialize(fd_);
171 167
172 return true; 168 return true;
173 } 169 }
174 170
171 QuicDispatcher* QuicServer::CreateQuicDispatcher() {
172 return new QuicDispatcher(
173 config_,
174 crypto_config_,
175 supported_versions_,
176 &epoll_server_);
177 }
178
175 void QuicServer::WaitForEvents() { 179 void QuicServer::WaitForEvents() {
176 epoll_server_.WaitForEventsAndExecuteCallbacks(); 180 epoll_server_.WaitForEventsAndExecuteCallbacks();
177 } 181 }
178 182
179 void QuicServer::Shutdown() { 183 void QuicServer::Shutdown() {
180 // Before we shut down the epoll server, give all active sessions a chance to 184 // Before we shut down the epoll server, give all active sessions a chance to
181 // notify clients that they're closing. 185 // notify clients that they're closing.
182 dispatcher_->Shutdown(); 186 dispatcher_->Shutdown();
183 187
184 close(fd_); 188 close(fd_);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 QuicEncryptedPacket packet(buf, bytes_read, false); 235 QuicEncryptedPacket packet(buf, bytes_read, false);
232 236
233 IPEndPoint server_address(server_ip, port); 237 IPEndPoint server_address(server_ip, port);
234 dispatcher->ProcessPacket(server_address, client_address, packet); 238 dispatcher->ProcessPacket(server_address, client_address, packet);
235 239
236 return true; 240 return true;
237 } 241 }
238 242
239 } // namespace tools 243 } // namespace tools
240 } // namespace net 244 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server.h ('k') | net/tools/quic/test_tools/server_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698