OLD | NEW |
(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 |
OLD | NEW |