Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: components/cronet/android/cronet_url_request_context_adapter.cc

Issue 1312153003: jni_generator: Pass object parameters as JavaParamRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (!file_thread_) { 391 if (!file_thread_) {
392 file_thread_.reset(new base::Thread("Network File Thread")); 392 file_thread_.reset(new base::Thread("Network File Thread"));
393 file_thread_->Start(); 393 file_thread_->Start();
394 } 394 }
395 return file_thread_.get(); 395 return file_thread_.get();
396 } 396 }
397 397
398 // Creates RequestContextAdater if config is valid URLRequestContextConfig, 398 // Creates RequestContextAdater if config is valid URLRequestContextConfig,
399 // returns 0 otherwise. 399 // returns 0 otherwise.
400 static jlong CreateRequestContextAdapter(JNIEnv* env, 400 static jlong CreateRequestContextAdapter(JNIEnv* env,
401 jclass jcaller, 401 const JavaParamRef<jclass>& jcaller,
402 jstring jconfig) { 402 const JavaParamRef<jstring>& jconfig) {
403 std::string config_string = 403 std::string config_string =
404 base::android::ConvertJavaStringToUTF8(env, jconfig); 404 base::android::ConvertJavaStringToUTF8(env, jconfig);
405 scoped_ptr<URLRequestContextConfig> context_config( 405 scoped_ptr<URLRequestContextConfig> context_config(
406 new URLRequestContextConfig()); 406 new URLRequestContextConfig());
407 if (!context_config->LoadFromJSON(config_string)) 407 if (!context_config->LoadFromJSON(config_string))
408 return 0; 408 return 0;
409 409
410 CronetURLRequestContextAdapter* context_adapter = 410 CronetURLRequestContextAdapter* context_adapter =
411 new CronetURLRequestContextAdapter(context_config.Pass()); 411 new CronetURLRequestContextAdapter(context_config.Pass());
412 return reinterpret_cast<jlong>(context_adapter); 412 return reinterpret_cast<jlong>(context_adapter);
413 } 413 }
414 414
415 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { 415 static jint SetMinLogLevel(JNIEnv* env,
416 const JavaParamRef<jclass>& jcaller,
417 jint jlog_level) {
416 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); 418 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel());
417 // MinLogLevel is global, shared by all URLRequestContexts. 419 // MinLogLevel is global, shared by all URLRequestContexts.
418 logging::SetMinLogLevel(static_cast<int>(jlog_level)); 420 logging::SetMinLogLevel(static_cast<int>(jlog_level));
419 return old_log_level; 421 return old_log_level;
420 } 422 }
421 423
422 } // namespace cronet 424 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698