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

Unified Diff: net/proxy/proxy_script_fetcher_impl_unittest.cc

Issue 2888043008: Revert of Allow use of Mojo/V8 ProxyResolvers with URLRequestContextBuilder. (Closed)
Patch Set: 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
« no previous file with comments | « net/BUILD.gn ('k') | net/proxy/proxy_service_mojo_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_script_fetcher_impl_unittest.cc
diff --git a/net/proxy/proxy_script_fetcher_impl_unittest.cc b/net/proxy/proxy_script_fetcher_impl_unittest.cc
index a1a7e5ea383f5d4a0fd7a6f84e742884dbecee0f..c1bebe744903ef49b1e89a770aaa2d02dff9adcb 100644
--- a/net/proxy/proxy_script_fetcher_impl_unittest.cc
+++ b/net/proxy/proxy_script_fetcher_impl_unittest.cc
@@ -39,7 +39,7 @@
#include "net/socket/transport_client_socket_pool.h"
#include "net/ssl/ssl_config_service_defaults.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
-#include "net/test/embedded_test_server/simple_connection_listener.h"
+#include "net/test/embedded_test_server/embedded_test_server_connection_listener.h"
#include "net/test/gtest_util.h"
#include "net/url_request/url_request_context_storage.h"
#include "net/url_request/url_request_file_job.h"
@@ -72,6 +72,36 @@
struct FetchResult {
int code;
base::string16 text;
+};
+
+// Waits for the specified number of connection attempts to be seen.
+class WaitForConnectionsListener
+ : public test_server::EmbeddedTestServerConnectionListener {
+ public:
+ explicit WaitForConnectionsListener(int expected_num_connections)
+ : expected_num_connections_(expected_num_connections),
+ task_runner_(base::SequencedTaskRunnerHandle::Get()) {}
+
+ void AcceptedSocket(const StreamSocket& socket) override {
+ ++seen_connections_;
+ EXPECT_LE(seen_connections_, expected_num_connections_);
+ if (expected_num_connections_ == seen_connections_)
+ task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure());
+ }
+
+ void ReadFromSocket(const StreamSocket& socket, int rv) override {}
+
+ void Wait() { run_loop_.Run(); }
+
+ private:
+ int seen_connections_ = 0;
+ int expected_num_connections_;
+
+ scoped_refptr<base::SequencedTaskRunner> task_runner_;
+
+ base::RunLoop run_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(WaitForConnectionsListener);
};
// A non-mock URL request which can access http:// and file:// urls, in the case
@@ -513,9 +543,7 @@
int num_requests = 10 + ClientSocketPoolManager::max_sockets_per_pool(
HttpNetworkSession::NORMAL_SOCKET_POOL);
- net::test_server::SimpleConnectionListener connection_listener(
- num_requests, net::test_server::SimpleConnectionListener::
- FAIL_ON_ADDITIONAL_CONNECTIONS);
+ WaitForConnectionsListener connection_listener(num_requests);
test_server_.SetConnectionListener(&connection_listener);
ASSERT_TRUE(test_server_.Start());
@@ -534,7 +562,7 @@
pac_fetchers.push_back(std::move(pac_fetcher));
}
- connection_listener.WaitForConnections();
+ connection_listener.Wait();
// None of the callbacks should have been invoked - all jobs should still be
// hung.
EXPECT_FALSE(callback.have_result());
« no previous file with comments | « net/BUILD.gn ('k') | net/proxy/proxy_service_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698