| 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 20 matching lines...) Expand all Loading... |
| 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 virtual void InitProxyConfigService() OVERRIDE { |
| 42 JNIEnv* env = base::android::AttachCurrentThread(); |
| 43 cronet::Java_ChromiumUrlRequestContext_initProxyConfigService(env, owner_); |
| 44 } |
| 45 |
| 41 protected: | 46 protected: |
| 42 virtual ~JniURLRequestContextAdapterDelegate() { | 47 virtual ~JniURLRequestContextAdapterDelegate() { |
| 43 JNIEnv* env = base::android::AttachCurrentThread(); | 48 JNIEnv* env = base::android::AttachCurrentThread(); |
| 44 env->DeleteGlobalRef(owner_); | 49 env->DeleteGlobalRef(owner_); |
| 45 } | 50 } |
| 46 | 51 |
| 47 private: | 52 private: |
| 48 jobject owner_; | 53 jobject owner_; |
| 49 }; | 54 }; |
| 50 | 55 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 145 |
| 141 // Stops recording NetLog. | 146 // Stops recording NetLog. |
| 142 static void StopNetLog(JNIEnv* env, | 147 static void StopNetLog(JNIEnv* env, |
| 143 jobject jcaller, | 148 jobject jcaller, |
| 144 jlong urlRequestContextAdapter) { | 149 jlong urlRequestContextAdapter) { |
| 145 URLRequestContextAdapter* adapter = | 150 URLRequestContextAdapter* adapter = |
| 146 reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter); | 151 reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter); |
| 147 adapter->StopNetLog(); | 152 adapter->StopNetLog(); |
| 148 } | 153 } |
| 149 | 154 |
| 155 // Called on application's main UI thread. |
| 156 static void InitProxyConfigServiceOnUIThread( |
| 157 JNIEnv* env, |
| 158 jobject jcaller, |
| 159 jlong urlRequestContextAdapter) { |
| 160 URLRequestContextAdapter* adapter = |
| 161 reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter); |
| 162 adapter->InitProxyConfigServiceOnUIThread(); |
| 163 } |
| 164 |
| 150 } // namespace cronet | 165 } // namespace cronet |
| OLD | NEW |