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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "jni/NativeTestServer_jni.h" | 14 #include "jni/NativeTestServer_jni.h" |
| 15 #include "net/base/host_port_pair.h" |
15 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
16 #include "net/test/embedded_test_server/embedded_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
17 #include "net/test/embedded_test_server/http_request.h" | 18 #include "net/test/embedded_test_server/http_request.h" |
18 #include "net/test/embedded_test_server/http_response.h" | 19 #include "net/test/embedded_test_server/http_response.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 namespace cronet { | 22 namespace cronet { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 return base::android::ConvertUTF8ToJavaString(env, url.spec()).Release(); | 138 return base::android::ConvertUTF8ToJavaString(env, url.spec()).Release(); |
138 } | 139 } |
139 | 140 |
140 jstring GetFileURL(JNIEnv* env, jclass jcaller, jstring jfile_path) { | 141 jstring GetFileURL(JNIEnv* env, jclass jcaller, jstring jfile_path) { |
141 DCHECK(g_test_server); | 142 DCHECK(g_test_server); |
142 std::string file = base::android::ConvertJavaStringToUTF8(env, jfile_path); | 143 std::string file = base::android::ConvertJavaStringToUTF8(env, jfile_path); |
143 GURL url = g_test_server->GetURL(file); | 144 GURL url = g_test_server->GetURL(file); |
144 return base::android::ConvertUTF8ToJavaString(env, url.spec()).Release(); | 145 return base::android::ConvertUTF8ToJavaString(env, url.spec()).Release(); |
145 } | 146 } |
146 | 147 |
| 148 jstring GetHostPort(JNIEnv* env, jclass jcaller) { |
| 149 DCHECK(g_test_server); |
| 150 std::string host_port = |
| 151 net::HostPortPair::FromURL(g_test_server->base_url()).ToString(); |
| 152 return base::android::ConvertUTF8ToJavaString(env, host_port).Release(); |
| 153 } |
| 154 |
147 bool RegisterNativeTestServer(JNIEnv* env) { | 155 bool RegisterNativeTestServer(JNIEnv* env) { |
148 return RegisterNativesImpl(env); | 156 return RegisterNativesImpl(env); |
149 } | 157 } |
150 | 158 |
151 } // namespace cronet | 159 } // namespace cronet |
OLD | NEW |