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

Unified Diff: net/test/embedded_test_server/simple_connection_listener.cc

Issue 2881613002: Allow use of Mojo/V8 ProxyResolvers with URLRequestContextBuilder. (Closed)
Patch Set: Merge Created 3 years, 7 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
Index: net/test/embedded_test_server/simple_connection_listener.cc
diff --git a/net/test/embedded_test_server/simple_connection_listener.cc b/net/test/embedded_test_server/simple_connection_listener.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fe7eaf687667da2b3eda67923f0867ed3bd31757
--- /dev/null
+++ b/net/test/embedded_test_server/simple_connection_listener.cc
@@ -0,0 +1,41 @@
+// Copyright 2017 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/test/embedded_test_server/simple_connection_listener.h"
+
+#include "base/location.h"
+#include "base/sequenced_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace test_server {
+
+SimpleConnectionListener::SimpleConnectionListener(
+ int expected_connections,
+ AllowAdditionalConnections allow_additional_connections)
+ : expected_connections_(expected_connections),
+ allow_additional_connections_(allow_additional_connections),
+ run_loop_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
+
+SimpleConnectionListener::~SimpleConnectionListener() {}
+
+void SimpleConnectionListener::AcceptedSocket(const StreamSocket& socket) {
+ ++seen_connections_;
+ if (allow_additional_connections_ != ALLOW_ADDITIONAL_CONNECTIONS)
+ EXPECT_LE(seen_connections_, expected_connections_);
+ if (seen_connections_ == expected_connections_)
+ run_loop_task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure());
+}
+
+void SimpleConnectionListener::ReadFromSocket(const StreamSocket& socket,
+ int rv) {}
+
+void SimpleConnectionListener::WaitForConnections() {
+ EXPECT_TRUE(run_loop_task_runner_->RunsTasksOnCurrentThread());
+ run_loop_.Run();
+}
+
+} // test_server
+} // net
eroman 2017/05/16 20:21:20 ditto, unless the style has changed.
mmenke 2017/05/17 02:29:58 Done.

Powered by Google App Engine
This is Rietveld 408576698