| 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 8f21eae7b92cee88ea30248b7b6bd52892b6b51c..d9efb08d50ab5c3f89487c19a0f66a132d8ff983 100644
|
| --- a/components/cronet/android/test/quic_test_server.cc
|
| +++ b/components/cronet/android/test/quic_test_server.cc
|
| @@ -5,11 +5,13 @@
|
| #include "quic_test_server.h"
|
|
|
| #include "base/android/jni_android.h"
|
| +#include "base/android/jni_array.h"
|
| #include "base/android/jni_string.h"
|
| #include "base/android/path_utils.h"
|
| #include "base/bind.h"
|
| #include "base/files/file_path.h"
|
| #include "base/files/file_util.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| #include "base/threading/thread.h"
|
| #include "components/cronet/android/test/cronet_test_util.h"
|
| #include "jni/QuicTestServer_jni.h"
|
| @@ -69,6 +71,30 @@ void ShutdownOnServerThread() {
|
|
|
| } // namespace
|
|
|
| +void AddResponse(JNIEnv* env,
|
| + const JavaParamRef<jclass>& /*jcaller*/,
|
| + const JavaParamRef<jstring>& jpath,
|
| + const JavaParamRef<jobjectArray>& jbody_chunks,
|
| + const JavaParamRef<jobjectArray>& jtrailers) {
|
| + std::string host(kFakeQuicDomain);
|
| + host.append(":");
|
| + host.append(base::IntToString(kServerPort));
|
| + std::string path;
|
| + base::android::ConvertJavaStringToUTF8(env, jpath, &path);
|
| + std::vector<std::string> body_chunks;
|
| + base::android::AppendJavaStringArrayToStringVector(env, jbody_chunks,
|
| + &body_chunks);
|
| + std::vector<std::string> trailers;
|
| + base::android::AppendJavaStringArrayToStringVector(env, jtrailers, &trailers);
|
| + net::SpdyHeaderBlock trailers_block;
|
| + for (int i = 0; i < trailers.size() / 2; i++) {
|
| + trailers_block.ReplaceOrAppendHeader(trailers[i * 2], trailers[i * 2 + 1]);
|
| + }
|
| +
|
| + net::QuicInMemoryCache::GetInstance()->AddBidirectionalResponse(
|
| + host, path, 200, body_chunks, trailers_block);
|
| +}
|
| +
|
| // Quic server is currently hardcoded to run on port 6121 of the localhost on
|
| // the device.
|
| void StartQuicTestServer(JNIEnv* env,
|
|
|