| Index: components/cronet/android/test/quic_test_server.cc
|
| diff --git a/components/cronet/android/test/quic_test_server.cc b/components/cronet/android/test/quic_test_server.cc
|
| index cb6d926a991952d81ec9685ca90778a2cb6a9a17..008fb9ded4e325b4ce1f50e42b776ca30e452986 100644
|
| --- a/components/cronet/android/test/quic_test_server.cc
|
| +++ b/components/cronet/android/test/quic_test_server.cc
|
| @@ -13,6 +13,7 @@
|
| #include "jni/QuicTestServer_jni.h"
|
| #include "net/base/ip_endpoint.h"
|
| #include "net/base/net_util.h"
|
| +#include "net/quic/crypto/proof_source_chromium.h"
|
| #include "net/tools/quic/quic_in_memory_cache.h"
|
| #include "net/tools/quic/quic_simple_server.h"
|
|
|
| @@ -26,11 +27,21 @@ static const int kServerPort = 6121;
|
| base::Thread* g_quic_server_thread = nullptr;
|
| net::tools::QuicSimpleServer* g_quic_server = nullptr;
|
|
|
| -void ServeFilesFromDirectory(
|
| - const base::FilePath& directory) {
|
| +net::ProofSource* CreateProofSource(const base::FilePath& cert_path,
|
| + const base::FilePath& key_path) {
|
| + VLOG(0) << "file: " << cert_path.value()
|
| + << ", key_path: " << key_path.value();
|
| + net::ProofSourceChromium* proof_source = new net::ProofSourceChromium();
|
| + CHECK(proof_source->Initialize(cert_path, key_path));
|
| + return proof_source;
|
| +}
|
| +
|
| +void StartOnServerThread(const base::FilePath& test_files_root) {
|
| DCHECK(g_quic_server_thread->task_runner()->BelongsToCurrentThread());
|
| DCHECK(!g_quic_server);
|
| - base::FilePath file_dir = directory.Append("quic_data");
|
| +
|
| + // Set up in-memory cache.
|
| + base::FilePath file_dir = test_files_root.Append("quic_data");
|
| CHECK(base::PathExists(file_dir)) << "Quic data does not exist";
|
| net::tools::QuicInMemoryCache::GetInstance()->InitializeFromDirectory(
|
| file_dir.value());
|
| @@ -39,6 +50,13 @@ void ServeFilesFromDirectory(
|
| net::QuicConfig config;
|
| g_quic_server =
|
| new net::tools::QuicSimpleServer(config, net::QuicSupportedVersions());
|
| +
|
| + // Set up server certs.
|
| + g_quic_server->SetProofSource(CreateProofSource(
|
| + test_files_root.Append("quic_certs").Append("leaf_cert.pem"),
|
| + test_files_root.Append("quic_certs").Append("leaf_cert.pkcs8")));
|
| +
|
| + // Start listening.
|
| int rv = g_quic_server->Listen(net::IPEndPoint(ip, kServerPort));
|
| CHECK_GE(rv, 0) << "Quic server fails to start";
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| @@ -67,7 +85,7 @@ void StartQuicTestServer(JNIEnv* env,
|
| base::FilePath test_files_root(
|
| base::android::ConvertJavaStringToUTF8(env, jtest_files_root));
|
| g_quic_server_thread->task_runner()->PostTask(
|
| - FROM_HERE, base::Bind(&ServeFilesFromDirectory, test_files_root));
|
| + FROM_HERE, base::Bind(&StartOnServerThread, test_files_root));
|
| }
|
|
|
| void ShutdownQuicTestServer(JNIEnv* env,
|
|
|