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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/test_tools/server_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..97edcd3fb3c8aeaaade43e76331c4ca7eeb060ff
--- /dev/null
+++ b/net/tools/quic/test_tools/server_thread.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// 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()) {
+ server_.WaitForEvents();
+ }
+ 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
« 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