| 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/cronet_url_request_context_adapter.h" | 5 #include "components/cronet/android/cronet_url_request_context_adapter.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_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 if (net_log_logger_) { | 302 if (net_log_logger_) { |
| 303 net_log_logger_->StopObserving(); | 303 net_log_logger_->StopObserving(); |
| 304 net_log_logger_.reset(); | 304 net_log_logger_.reset(); |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 // Creates RequestContextAdater if config is valid URLRequestContextConfig, | 308 // Creates RequestContextAdater if config is valid URLRequestContextConfig, |
| 309 // returns 0 otherwise. | 309 // returns 0 otherwise. |
| 310 static jlong CreateRequestContextAdapter(JNIEnv* env, | 310 static jlong CreateRequestContextAdapter(JNIEnv* env, |
| 311 jclass jcaller, | 311 jclass jcaller, |
| 312 jobject japp_context, | |
| 313 jstring jconfig) { | 312 jstring jconfig) { |
| 314 std::string config_string = | 313 std::string config_string = |
| 315 base::android::ConvertJavaStringToUTF8(env, jconfig); | 314 base::android::ConvertJavaStringToUTF8(env, jconfig); |
| 316 scoped_ptr<URLRequestContextConfig> context_config( | 315 scoped_ptr<URLRequestContextConfig> context_config( |
| 317 new URLRequestContextConfig()); | 316 new URLRequestContextConfig()); |
| 318 if (!context_config->LoadFromJSON(config_string)) | 317 if (!context_config->LoadFromJSON(config_string)) |
| 319 return 0; | 318 return 0; |
| 320 | 319 |
| 321 CronetURLRequestContextAdapter* context_adapter = | 320 CronetURLRequestContextAdapter* context_adapter = |
| 322 new CronetURLRequestContextAdapter(context_config.Pass()); | 321 new CronetURLRequestContextAdapter(context_config.Pass()); |
| 323 return reinterpret_cast<jlong>(context_adapter); | 322 return reinterpret_cast<jlong>(context_adapter); |
| 324 } | 323 } |
| 325 | 324 |
| 326 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { | 325 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { |
| 327 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); | 326 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); |
| 328 // MinLogLevel is global, shared by all URLRequestContexts. | 327 // MinLogLevel is global, shared by all URLRequestContexts. |
| 329 logging::SetMinLogLevel(static_cast<int>(jlog_level)); | 328 logging::SetMinLogLevel(static_cast<int>(jlog_level)); |
| 330 return old_log_level; | 329 return old_log_level; |
| 331 } | 330 } |
| 332 | 331 |
| 333 } // namespace cronet | 332 } // namespace cronet |
| OLD | NEW |