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

Unified Diff: components/grpc_support/test/quic_test_server.cc

Issue 2518063007: Pass QuicInMemoryCache directly instead of using a singleton. (Closed)
Patch Set: Fix Cronet compile error Created 4 years, 1 month 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 | « components/cronet/android/test/quic_test_server.cc ('k') | net/net.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/grpc_support/test/quic_test_server.cc
diff --git a/components/grpc_support/test/quic_test_server.cc b/components/grpc_support/test/quic_test_server.cc
index 169241db124c1bd9e92da4f0fff8bd75bc267f0d..8455cd6d303c4d05cbf21463dcb8514adc499a44 100644
--- a/components/grpc_support/test/quic_test_server.cc
+++ b/components/grpc_support/test/quic_test_server.cc
@@ -41,22 +41,20 @@ const char kHelloTrailerName[] = "hello_trailer";
const char kHelloTrailerValue[] = "hello trailer value";
base::Thread* g_quic_server_thread = nullptr;
+net::QuicInMemoryCache* g_quic_in_memory_cache = nullptr;
net::QuicSimpleServer* g_quic_server = nullptr;
int g_quic_server_port = 0;
void SetupQuicInMemoryCache() {
- static bool setup_done = false;
- if (setup_done)
- return;
- setup_done = true;
net::SpdyHeaderBlock headers;
headers[kHelloHeaderName] = kHelloHeaderValue;
headers[kStatusHeader] = kHelloStatus;
net::SpdyHeaderBlock trailers;
trailers[kHelloTrailerName] = kHelloTrailerValue;
- net::QuicInMemoryCache::GetInstance()->AddResponse(
- base::StringPrintf("%s", kTestServerHost),
- kHelloPath, std::move(headers), kHelloBodyValue, std::move(trailers));
+ g_quic_in_memory_cache = new net::QuicInMemoryCache();
+ g_quic_in_memory_cache->AddResponse(base::StringPrintf("%s", kTestServerHost),
+ kHelloPath, std::move(headers),
+ kHelloBodyValue, std::move(trailers));
}
void StartQuicServerOnServerThread(const base::FilePath& test_files_root,
@@ -74,10 +72,13 @@ void StartQuicServerOnServerThread(const base::FilePath& test_files_root,
directory.AppendASCII("quic_test.example.com.crt"),
directory.AppendASCII("quic_test.example.com.key.pkcs8"),
directory.AppendASCII("quic_test.example.com.key.sct")));
- g_quic_server =
- new net::QuicSimpleServer(std::move(proof_source), config,
- net::QuicCryptoServerConfig::ConfigOptions(),
- net::AllSupportedVersions());
+
+ SetupQuicInMemoryCache();
+
+ g_quic_server = new net::QuicSimpleServer(
+ std::move(proof_source), config,
+ net::QuicCryptoServerConfig::ConfigOptions(), net::AllSupportedVersions(),
+ g_quic_in_memory_cache);
// Start listening on an unbound port.
int rv = g_quic_server->Listen(
@@ -85,8 +86,6 @@ void StartQuicServerOnServerThread(const base::FilePath& test_files_root,
CHECK_GE(rv, 0) << "Quic server fails to start";
g_quic_server_port = g_quic_server->server_address().port();
- SetupQuicInMemoryCache();
-
server_started_event->Signal();
}
@@ -95,6 +94,8 @@ void ShutdownOnServerThread(base::WaitableEvent* server_stopped_event) {
g_quic_server->Shutdown();
delete g_quic_server;
g_quic_server = nullptr;
+ delete g_quic_in_memory_cache;
+ g_quic_in_memory_cache = nullptr;
server_stopped_event->Signal();
}
« no previous file with comments | « components/cronet/android/test/quic_test_server.cc ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698