| 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 #include <utility> |
| 8 | 9 |
| 9 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 11 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/metrics/statistics_recorder.h" | 15 #include "base/metrics/statistics_recorder.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "components/cronet/android/chromium_url_request.h" | 17 #include "components/cronet/android/chromium_url_request.h" |
| 17 #include "components/cronet/android/url_request_adapter.h" | 18 #include "components/cronet/android/url_request_adapter.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 reinterpret_cast<URLRequestContextConfig*>(jconfig)); | 74 reinterpret_cast<URLRequestContextConfig*>(jconfig)); |
| 74 | 75 |
| 75 // TODO(mef): MinLogLevel is global, shared by all URLRequestContexts. | 76 // TODO(mef): MinLogLevel is global, shared by all URLRequestContexts. |
| 76 // Revisit this if each URLRequestContext would need an individual log level. | 77 // Revisit this if each URLRequestContext would need an individual log level. |
| 77 logging::SetMinLogLevel(static_cast<int>(jlog_level)); | 78 logging::SetMinLogLevel(static_cast<int>(jlog_level)); |
| 78 | 79 |
| 79 // TODO(dplotnikov): set application context. | 80 // TODO(dplotnikov): set application context. |
| 80 URLRequestContextAdapter* context_adapter = new URLRequestContextAdapter( | 81 URLRequestContextAdapter* context_adapter = new URLRequestContextAdapter( |
| 81 new JniURLRequestContextAdapterDelegate(env, jcaller), user_agent); | 82 new JniURLRequestContextAdapterDelegate(env, jcaller), user_agent); |
| 82 context_adapter->AddRef(); // Hold onto this ref-counted object. | 83 context_adapter->AddRef(); // Hold onto this ref-counted object. |
| 83 context_adapter->Initialize(context_config.Pass()); | 84 context_adapter->Initialize(std::move(context_config)); |
| 84 return reinterpret_cast<jlong>(context_adapter); | 85 return reinterpret_cast<jlong>(context_adapter); |
| 85 } | 86 } |
| 86 | 87 |
| 87 // Releases native objects. | 88 // Releases native objects. |
| 88 static void ReleaseRequestContextAdapter(JNIEnv* env, | 89 static void ReleaseRequestContextAdapter(JNIEnv* env, |
| 89 const JavaParamRef<jobject>& jcaller, | 90 const JavaParamRef<jobject>& jcaller, |
| 90 jlong jurl_request_context_adapter) { | 91 jlong jurl_request_context_adapter) { |
| 91 URLRequestContextAdapter* context_adapter = | 92 URLRequestContextAdapter* context_adapter = |
| 92 reinterpret_cast<URLRequestContextAdapter*>(jurl_request_context_adapter); | 93 reinterpret_cast<URLRequestContextAdapter*>(jurl_request_context_adapter); |
| 93 // TODO(mef): Revisit this from thread safety point of view: Can we delete a | 94 // TODO(mef): Revisit this from thread safety point of view: Can we delete a |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Called on application's main Java thread. | 140 // Called on application's main Java thread. |
| 140 static void InitRequestContextOnMainThread(JNIEnv* env, | 141 static void InitRequestContextOnMainThread(JNIEnv* env, |
| 141 const JavaParamRef<jobject>& jcaller, | 142 const JavaParamRef<jobject>& jcaller, |
| 142 jlong jurl_request_context_adapter) { | 143 jlong jurl_request_context_adapter) { |
| 143 URLRequestContextAdapter* context_adapter = | 144 URLRequestContextAdapter* context_adapter = |
| 144 reinterpret_cast<URLRequestContextAdapter*>(jurl_request_context_adapter); | 145 reinterpret_cast<URLRequestContextAdapter*>(jurl_request_context_adapter); |
| 145 context_adapter->InitRequestContextOnMainThread(); | 146 context_adapter->InitRequestContextOnMainThread(); |
| 146 } | 147 } |
| 147 | 148 |
| 148 } // namespace cronet | 149 } // namespace cronet |
| OLD | NEW |