| 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 const char kFakeQuicDomain[] = "test.example.com"; | 
| 43 // Path that advertises the dictionary passed in query params if client | 44 // 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 | 45 // supports Sdch encoding. E.g. /sdch/index?q=LeQxM80O will make the server | 
| 45 // responds with "Get-Dictionary: /sdch/dict/LeQxM80O". | 46 // responds with "Get-Dictionary: /sdch/dict/LeQxM80O". | 
| 46 const char kSdchPath[] = "/sdch/index"; | 47 const char kSdchPath[] = "/sdch/index"; | 
| 47 // Path that returns encoded response if client has the right dictionary. | 48 // Path that returns encoded response if client has the right dictionary. | 
| 48 const char kSdchTestPath[] = "/sdch/test"; | 49 const char kSdchTestPath[] = "/sdch/test"; | 
| 49 // Path where dictionaries are stored. | 50 // Path where dictionaries are stored. | 
| 50 const char kSdchDictPath[] = "/sdch/dict/"; | 51 const char kSdchDictPath[] = "/sdch/dict/"; | 
| 51 | 52 | 
| 52 net::test_server::EmbeddedTestServer* g_test_server = nullptr; | 53 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>(); | 184   return scoped_ptr<net::test_server::BasicHttpResponse>(); | 
| 184 } | 185 } | 
| 185 | 186 | 
| 186 void RegisterHostResolverProcHelper( | 187 void RegisterHostResolverProcHelper( | 
| 187     net::URLRequestContext* url_request_context) { | 188     net::URLRequestContext* url_request_context) { | 
| 188   net::HostResolverImpl* resolver = | 189   net::HostResolverImpl* resolver = | 
| 189       static_cast<net::HostResolverImpl*>(url_request_context->host_resolver()); | 190       static_cast<net::HostResolverImpl*>(url_request_context->host_resolver()); | 
| 190   scoped_refptr<net::RuleBasedHostResolverProc> proc = | 191   scoped_refptr<net::RuleBasedHostResolverProc> proc = | 
| 191       new net::RuleBasedHostResolverProc(NULL); | 192       new net::RuleBasedHostResolverProc(NULL); | 
| 192   proc->AddRule(kFakeSdchDomain, "127.0.0.1"); | 193   proc->AddRule(kFakeSdchDomain, "127.0.0.1"); | 
|  | 194   proc->AddRule(kFakeQuicDomain, "127.0.0.1"); | 
| 193   resolver->set_proc_params_for_test( | 195   resolver->set_proc_params_for_test( | 
| 194       net::HostResolverImpl::ProcTaskParams(proc.get(), 1u)); | 196       net::HostResolverImpl::ProcTaskParams(proc.get(), 1u)); | 
| 195   JNIEnv* env = base::android::AttachCurrentThread(); | 197   JNIEnv* env = base::android::AttachCurrentThread(); | 
| 196   Java_NativeTestServer_onHostResolverProcRegistered(env); | 198   Java_NativeTestServer_onHostResolverProcRegistered(env); | 
| 197 } | 199 } | 
| 198 | 200 | 
| 199 void RegisterHostResolverProcOnNetworkThread( | 201 void RegisterHostResolverProcOnNetworkThread( | 
| 200     CronetURLRequestContextAdapter* context_adapter) { | 202     CronetURLRequestContextAdapter* context_adapter) { | 
| 201   RegisterHostResolverProcHelper(context_adapter->GetURLRequestContext()); | 203   RegisterHostResolverProcHelper(context_adapter->GetURLRequestContext()); | 
| 202 } | 204 } | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 333 #else | 335 #else | 
| 334   return JNI_FALSE; | 336   return JNI_FALSE; | 
| 335 #endif | 337 #endif | 
| 336 } | 338 } | 
| 337 | 339 | 
| 338 bool RegisterNativeTestServer(JNIEnv* env) { | 340 bool RegisterNativeTestServer(JNIEnv* env) { | 
| 339   return RegisterNativesImpl(env); | 341   return RegisterNativesImpl(env); | 
| 340 } | 342 } | 
| 341 | 343 | 
| 342 }  // namespace cronet | 344 }  // namespace cronet | 
| OLD | NEW | 
|---|