Index: net/tools/quic/test_tools/server_thread.cc |
diff --git a/net/tools/quic/test_tools/server_thread.cc b/net/tools/quic/test_tools/server_thread.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..36b28fd2e397b6597b1492202d4db1c32dbb24d6 |
--- /dev/null |
+++ b/net/tools/quic/test_tools/server_thread.cc |
@@ -0,0 +1,54 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
ramant (doing other things)
2013/09/25 14:39:12
nit: consider changing 2012 to 2013.
Ryan Hamilton
2013/09/25 23:29:36
Done. Although there's a script which does this f
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "net/tools/quic/test_tools/server_thread.h" |
+ |
+namespace net { |
+namespace tools { |
+namespace test { |
+ |
+ServerThread::ServerThread(IPEndPoint address, |
+ const QuicConfig& config, |
+ bool strike_register_no_startup_period) |
+ : SimpleThread("server_thread"), |
+ listening_(true, false), |
+ quit_(true, false), |
+ server_(config), |
+ address_(address), |
+ port_(0) { |
+ if (strike_register_no_startup_period) { |
+ server_.SetStrikeRegisterNoStartupPeriod(); |
+ } |
+} |
+ |
+ServerThread::~ServerThread() { |
+} |
+ |
+void ServerThread::Run() { |
+ LOG(INFO) << "listening"; |
+ server_.Listen(address_); |
+ |
+ port_lock_.Acquire(); |
+ port_ = server_.port(); |
+ port_lock_.Release(); |
+ |
+ listening_.Signal(); |
+ while (!quit_.IsSignaled()) { |
+ //LOG(INFO) << "waiting"; |
+ server_.WaitForEvents(); |
ramant (doing other things)
2013/09/25 14:39:12
nit: //LOG(INFO) -> // LOG(INFO)
Ryan Hamilton
2013/09/25 23:29:36
Done.
|
+ } |
+ LOG(INFO) << "shutdown"; |
+ server_.Shutdown(); |
+} |
+ |
+int ServerThread::GetPort() { |
+ port_lock_.Acquire(); |
+ int rc = port_; |
+ port_lock_.Release(); |
+ return rc; |
+} |
+ |
+} // namespace test |
+} // namespace tools |
+} // namespace net |