OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "net/test/embedded_test_server/android/embedded_test_server_android.h" | 5 #include "net/test/embedded_test_server/android/embedded_test_server_android.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.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/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "net/test/jni/EmbeddedTestServerImpl_jni.h" | 12 #include "net/test/jni/EmbeddedTestServer_jni.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 namespace test_server { | 15 namespace test_server { |
16 | 16 |
17 EmbeddedTestServerAndroid::EmbeddedTestServerAndroid(JNIEnv* env, jobject jobj) | 17 EmbeddedTestServerAndroid::EmbeddedTestServerAndroid(JNIEnv* env, jobject jobj) |
18 : weak_java_server_(env, jobj), test_server_() { | 18 : weak_java_server_(env, jobj), test_server_() { |
19 Java_EmbeddedTestServerImpl_setNativePtr(env, jobj, | 19 Java_EmbeddedTestServer_setNativePtr(env, jobj, |
20 reinterpret_cast<intptr_t>(this)); | 20 reinterpret_cast<intptr_t>(this)); |
21 } | 21 } |
22 | 22 |
23 EmbeddedTestServerAndroid::~EmbeddedTestServerAndroid() { | 23 EmbeddedTestServerAndroid::~EmbeddedTestServerAndroid() { |
24 JNIEnv* env = base::android::AttachCurrentThread(); | 24 JNIEnv* env = base::android::AttachCurrentThread(); |
25 Java_EmbeddedTestServerImpl_clearNativePtr(env, | 25 Java_EmbeddedTestServer_clearNativePtr(env, weak_java_server_.get(env).obj()); |
26 weak_java_server_.get(env).obj()); | |
27 } | 26 } |
28 | 27 |
29 jboolean EmbeddedTestServerAndroid::Start(JNIEnv* env, | 28 jboolean EmbeddedTestServerAndroid::Start(JNIEnv* env, |
30 const JavaParamRef<jobject>& jobj) { | 29 const JavaParamRef<jobject>& jobj) { |
31 return test_server_.Start(); | 30 return test_server_.Start(); |
32 } | 31 } |
33 | 32 |
34 jboolean EmbeddedTestServerAndroid::ShutdownAndWaitUntilComplete( | 33 jboolean EmbeddedTestServerAndroid::ShutdownAndWaitUntilComplete( |
35 JNIEnv* env, | 34 JNIEnv* env, |
36 const JavaParamRef<jobject>& jobj) { | 35 const JavaParamRef<jobject>& jobj) { |
(...skipping 28 matching lines...) Expand all Loading... |
65 new EmbeddedTestServerAndroid(env, jobj); | 64 new EmbeddedTestServerAndroid(env, jobj); |
66 } | 65 } |
67 | 66 |
68 // static | 67 // static |
69 bool EmbeddedTestServerAndroid::RegisterEmbeddedTestServerAndroid(JNIEnv* env) { | 68 bool EmbeddedTestServerAndroid::RegisterEmbeddedTestServerAndroid(JNIEnv* env) { |
70 return RegisterNativesImpl(env); | 69 return RegisterNativesImpl(env); |
71 } | 70 } |
72 | 71 |
73 } // namespace test_server | 72 } // namespace test_server |
74 } // namespace net | 73 } // namespace net |
OLD | NEW |