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 "components/cronet/android/chromium_url_request_context.h" | 5 #include "components/cronet/android/chromium_url_request_context.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 13 matching lines...) Expand all Loading... |
24 // Delegate of URLRequestContextAdapter that delivers callbacks to the Java | 24 // Delegate of URLRequestContextAdapter that delivers callbacks to the Java |
25 // layer. | 25 // layer. |
26 class JniURLRequestContextAdapterDelegate | 26 class JniURLRequestContextAdapterDelegate |
27 : public cronet::URLRequestContextAdapter:: | 27 : public cronet::URLRequestContextAdapter:: |
28 URLRequestContextAdapterDelegate { | 28 URLRequestContextAdapterDelegate { |
29 public: | 29 public: |
30 JniURLRequestContextAdapterDelegate(JNIEnv* env, jobject owner) | 30 JniURLRequestContextAdapterDelegate(JNIEnv* env, jobject owner) |
31 : owner_(env->NewGlobalRef(owner)) {} | 31 : owner_(env->NewGlobalRef(owner)) {} |
32 | 32 |
33 virtual void OnContextInitialized( | 33 virtual void OnContextInitialized( |
34 cronet::URLRequestContextAdapter* context) OVERRIDE { | 34 cronet::URLRequestContextAdapter* context) override { |
35 JNIEnv* env = base::android::AttachCurrentThread(); | 35 JNIEnv* env = base::android::AttachCurrentThread(); |
36 cronet::Java_ChromiumUrlRequestContext_initNetworkThread(env, owner_); | 36 cronet::Java_ChromiumUrlRequestContext_initNetworkThread(env, owner_); |
37 // TODO(dplotnikov): figure out if we need to detach from the thread. | 37 // TODO(dplotnikov): figure out if we need to detach from the thread. |
38 // The documentation says we should detach just before the thread exits. | 38 // The documentation says we should detach just before the thread exits. |
39 } | 39 } |
40 | 40 |
41 protected: | 41 protected: |
42 virtual ~JniURLRequestContextAdapterDelegate() { | 42 virtual ~JniURLRequestContextAdapterDelegate() { |
43 JNIEnv* env = base::android::AttachCurrentThread(); | 43 JNIEnv* env = base::android::AttachCurrentThread(); |
44 env->DeleteGlobalRef(owner_); | 44 env->DeleteGlobalRef(owner_); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // Stops recording NetLog. | 141 // Stops recording NetLog. |
142 static void StopNetLog(JNIEnv* env, | 142 static void StopNetLog(JNIEnv* env, |
143 jobject jcaller, | 143 jobject jcaller, |
144 jlong urlRequestContextAdapter) { | 144 jlong urlRequestContextAdapter) { |
145 URLRequestContextAdapter* adapter = | 145 URLRequestContextAdapter* adapter = |
146 reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter); | 146 reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter); |
147 adapter->StopNetLog(); | 147 adapter->StopNetLog(); |
148 } | 148 } |
149 | 149 |
150 } // namespace cronet | 150 } // namespace cronet |
OLD | NEW |