| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 context_adapter->Release(); | 110 context_adapter->Release(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Starts recording statistics. | 113 // Starts recording statistics. |
| 114 static void InitializeStatistics(JNIEnv* env, jobject jcaller) { | 114 static void InitializeStatistics(JNIEnv* env, jobject jcaller) { |
| 115 base::StatisticsRecorder::Initialize(); | 115 base::StatisticsRecorder::Initialize(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Gets current statistics with |jfilter| as a substring as JSON text (an empty | 118 // Gets current statistics with |jfilter| as a substring as JSON text (an empty |
| 119 // |jfilter| will include all registered histograms). | 119 // |jfilter| will include all registered histograms). |
| 120 static jstring GetStatisticsJSON(JNIEnv* env, | 120 static ScopedJavaLocalRef<jstring> GetStatisticsJSON(JNIEnv* env, |
| 121 jobject jcaller, | 121 jobject jcaller, |
| 122 jstring jfilter) { | 122 jstring jfilter) { |
| 123 std::string query = ConvertJavaStringToUTF8(env, jfilter); | 123 std::string query = ConvertJavaStringToUTF8(env, jfilter); |
| 124 std::string json = base::StatisticsRecorder::ToJSON(query); | 124 std::string json = base::StatisticsRecorder::ToJSON(query); |
| 125 return ConvertUTF8ToJavaString(env, json).Release(); | 125 return ConvertUTF8ToJavaString(env, json); |
| 126 } | 126 } |
| 127 | 127 |
| 128 // Starts recording NetLog into file with |jfilename|. | 128 // Starts recording NetLog into file with |jfilename|. |
| 129 static void StartNetLogToFile(JNIEnv* env, | 129 static void StartNetLogToFile(JNIEnv* env, |
| 130 jobject jcaller, | 130 jobject jcaller, |
| 131 jlong jurl_request_context_adapter, | 131 jlong jurl_request_context_adapter, |
| 132 jstring jfilename, | 132 jstring jfilename, |
| 133 jboolean jlog_all) { | 133 jboolean jlog_all) { |
| 134 URLRequestContextAdapter* context_adapter = | 134 URLRequestContextAdapter* context_adapter = |
| 135 reinterpret_cast<URLRequestContextAdapter*>(jurl_request_context_adapter); | 135 reinterpret_cast<URLRequestContextAdapter*>(jurl_request_context_adapter); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 149 // Called on application's main Java thread. | 149 // Called on application's main Java thread. |
| 150 static void InitRequestContextOnMainThread(JNIEnv* env, | 150 static void InitRequestContextOnMainThread(JNIEnv* env, |
| 151 jobject jcaller, | 151 jobject jcaller, |
| 152 jlong jurl_request_context_adapter) { | 152 jlong jurl_request_context_adapter) { |
| 153 URLRequestContextAdapter* context_adapter = | 153 URLRequestContextAdapter* context_adapter = |
| 154 reinterpret_cast<URLRequestContextAdapter*>(jurl_request_context_adapter); | 154 reinterpret_cast<URLRequestContextAdapter*>(jurl_request_context_adapter); |
| 155 context_adapter->InitRequestContextOnMainThread(); | 155 context_adapter->InitRequestContextOnMainThread(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace cronet | 158 } // namespace cronet |
| OLD | NEW |