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

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

Issue 24493003: Factor out ServerThread from the QUIC EndToEndTest in order to reuse in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 7 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 | Annotate | Revision Log
« 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/tools/quic/test_tools/server_thread.h"
6
7 namespace net {
8 namespace tools {
9 namespace test {
10
11 ServerThread::ServerThread(IPEndPoint address,
12 const QuicConfig& config,
13 bool strike_register_no_startup_period)
14 : SimpleThread("server_thread"),
15 listening_(true, false),
16 quit_(true, false),
17 server_(config),
18 address_(address),
19 port_(0) {
20 if (strike_register_no_startup_period) {
21 server_.SetStrikeRegisterNoStartupPeriod();
22 }
23 }
24
25 ServerThread::~ServerThread() {
26 }
27
28 void ServerThread::Run() {
29 LOG(INFO) << "listening";
30 server_.Listen(address_);
31
32 port_lock_.Acquire();
33 port_ = server_.port();
34 port_lock_.Release();
35
36 listening_.Signal();
37 while (!quit_.IsSignaled()) {
38 server_.WaitForEvents();
39 }
40 LOG(INFO) << "shutdown";
41 server_.Shutdown();
42 }
43
44 int ServerThread::GetPort() {
45 port_lock_.Acquire();
46 int rc = port_;
47 port_lock_.Release();
48 return rc;
49 }
50
51 } // namespace test
52 } // namespace tools
53 } // 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