| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "native_test_server.h" | 5 #include "native_test_server.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace cronet { | 33 namespace cronet { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 const char kEchoBodyPath[] = "/echo_body"; | 37 const char kEchoBodyPath[] = "/echo_body"; |
| 38 const char kEchoHeaderPath[] = "/echo_header"; | 38 const char kEchoHeaderPath[] = "/echo_header"; |
| 39 const char kEchoAllHeadersPath[] = "/echo_all_headers"; | 39 const char kEchoAllHeadersPath[] = "/echo_all_headers"; |
| 40 const char kEchoMethodPath[] = "/echo_method"; | 40 const char kEchoMethodPath[] = "/echo_method"; |
| 41 const char kRedirectToEchoBodyPath[] = "/redirect_to_echo_body"; | 41 const char kRedirectToEchoBodyPath[] = "/redirect_to_echo_body"; |
| 42 const char kFakeSdchDomain[] = "fake.sdch.domain"; | 42 const char kFakeSdchDomain[] = "fake.sdch.domain"; |
| 43 // Host used in QuicTestServer. This must match the certificate used |
| 44 // (quic_test.example.com.crt and quic_test.example.com.key.pkcs8), and |
| 45 // the file served ( |
| 46 // components/cronet/android/test/assets/test/quic_data/simple.txt). |
| 47 const char kFakeQuicDomain[] = "test.example.com"; |
| 43 // Path that advertises the dictionary passed in query params if client | 48 // Path that advertises the dictionary passed in query params if client |
| 44 // supports Sdch encoding. E.g. /sdch/index?q=LeQxM80O will make the server | 49 // supports Sdch encoding. E.g. /sdch/index?q=LeQxM80O will make the server |
| 45 // responds with "Get-Dictionary: /sdch/dict/LeQxM80O". | 50 // responds with "Get-Dictionary: /sdch/dict/LeQxM80O". |
| 46 const char kSdchPath[] = "/sdch/index"; | 51 const char kSdchPath[] = "/sdch/index"; |
| 47 // Path that returns encoded response if client has the right dictionary. | 52 // Path that returns encoded response if client has the right dictionary. |
| 48 const char kSdchTestPath[] = "/sdch/test"; | 53 const char kSdchTestPath[] = "/sdch/test"; |
| 49 // Path where dictionaries are stored. | 54 // Path where dictionaries are stored. |
| 50 const char kSdchDictPath[] = "/sdch/dict/"; | 55 const char kSdchDictPath[] = "/sdch/dict/"; |
| 51 | 56 |
| 52 net::test_server::EmbeddedTestServer* g_test_server = nullptr; | 57 net::test_server::EmbeddedTestServer* g_test_server = nullptr; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 return scoped_ptr<net::test_server::BasicHttpResponse>(); | 188 return scoped_ptr<net::test_server::BasicHttpResponse>(); |
| 184 } | 189 } |
| 185 | 190 |
| 186 void RegisterHostResolverProcHelper( | 191 void RegisterHostResolverProcHelper( |
| 187 net::URLRequestContext* url_request_context) { | 192 net::URLRequestContext* url_request_context) { |
| 188 net::HostResolverImpl* resolver = | 193 net::HostResolverImpl* resolver = |
| 189 static_cast<net::HostResolverImpl*>(url_request_context->host_resolver()); | 194 static_cast<net::HostResolverImpl*>(url_request_context->host_resolver()); |
| 190 scoped_refptr<net::RuleBasedHostResolverProc> proc = | 195 scoped_refptr<net::RuleBasedHostResolverProc> proc = |
| 191 new net::RuleBasedHostResolverProc(NULL); | 196 new net::RuleBasedHostResolverProc(NULL); |
| 192 proc->AddRule(kFakeSdchDomain, "127.0.0.1"); | 197 proc->AddRule(kFakeSdchDomain, "127.0.0.1"); |
| 198 proc->AddRule(kFakeQuicDomain, "127.0.0.1"); |
| 193 resolver->set_proc_params_for_test( | 199 resolver->set_proc_params_for_test( |
| 194 net::HostResolverImpl::ProcTaskParams(proc.get(), 1u)); | 200 net::HostResolverImpl::ProcTaskParams(proc.get(), 1u)); |
| 195 JNIEnv* env = base::android::AttachCurrentThread(); | 201 JNIEnv* env = base::android::AttachCurrentThread(); |
| 196 Java_NativeTestServer_onHostResolverProcRegistered(env); | 202 Java_NativeTestServer_onHostResolverProcRegistered(env); |
| 197 } | 203 } |
| 198 | 204 |
| 199 void RegisterHostResolverProcOnNetworkThread( | 205 void RegisterHostResolverProcOnNetworkThread( |
| 200 CronetURLRequestContextAdapter* context_adapter) { | 206 CronetURLRequestContextAdapter* context_adapter) { |
| 201 RegisterHostResolverProcHelper(context_adapter->GetURLRequestContext()); | 207 RegisterHostResolverProcHelper(context_adapter->GetURLRequestContext()); |
| 202 } | 208 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 #else | 339 #else |
| 334 return JNI_FALSE; | 340 return JNI_FALSE; |
| 335 #endif | 341 #endif |
| 336 } | 342 } |
| 337 | 343 |
| 338 bool RegisterNativeTestServer(JNIEnv* env) { | 344 bool RegisterNativeTestServer(JNIEnv* env) { |
| 339 return RegisterNativesImpl(env); | 345 return RegisterNativesImpl(env); |
| 340 } | 346 } |
| 341 | 347 |
| 342 } // namespace cronet | 348 } // namespace cronet |
| OLD | NEW |