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

Side by Side Diff: components/cronet/android/test/test_upload_data_stream_handler.cc

Issue 1294333002: Fix wrong usages of ScopedJavaLocalRef::Release(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment to Release() explaining it should not be used to call java methods Created 5 years, 4 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
« no previous file with comments | « chrome/browser/speech/tts_android.cc ('k') | components/gcm_driver/gcm_driver_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "test_upload_data_stream_handler.h" 5 #include "test_upload_data_stream_handler.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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 158
159 void TestUploadDataStreamHandler::NotifyJavaReadCompleted() { 159 void TestUploadDataStreamHandler::NotifyJavaReadCompleted() {
160 DCHECK(network_thread_->task_runner()->BelongsToCurrentThread()); 160 DCHECK(network_thread_->task_runner()->BelongsToCurrentThread());
161 JNIEnv* env = base::android::AttachCurrentThread(); 161 JNIEnv* env = base::android::AttachCurrentThread();
162 std::string data_read = ""; 162 std::string data_read = "";
163 if (read_buffer_.get() && bytes_read_ > 0) 163 if (read_buffer_.get() && bytes_read_ > 0)
164 data_read = std::string(read_buffer_->data(), bytes_read_); 164 data_read = std::string(read_buffer_->data(), bytes_read_);
165 cronet::Java_TestUploadDataStreamHandler_onReadCompleted( 165 cronet::Java_TestUploadDataStreamHandler_onReadCompleted(
166 env, jtest_upload_data_stream_handler_.obj(), bytes_read_, 166 env, jtest_upload_data_stream_handler_.obj(), bytes_read_,
167 base::android::ConvertUTF8ToJavaString(env, data_read).Release()); 167 base::android::ConvertUTF8ToJavaString(env, data_read).obj());
168 } 168 }
169 169
170 static jlong CreateTestUploadDataStreamHandler( 170 static jlong CreateTestUploadDataStreamHandler(
171 JNIEnv* env, 171 JNIEnv* env,
172 jobject jtest_upload_data_stream_handler, 172 jobject jtest_upload_data_stream_handler,
173 jlong jupload_data_stream) { 173 jlong jupload_data_stream) {
174 scoped_ptr<net::UploadDataStream> upload_data_stream( 174 scoped_ptr<net::UploadDataStream> upload_data_stream(
175 reinterpret_cast<net::UploadDataStream*>(jupload_data_stream)); 175 reinterpret_cast<net::UploadDataStream*>(jupload_data_stream));
176 TestUploadDataStreamHandler* handler = new TestUploadDataStreamHandler( 176 TestUploadDataStreamHandler* handler = new TestUploadDataStreamHandler(
177 upload_data_stream.Pass(), env, jtest_upload_data_stream_handler); 177 upload_data_stream.Pass(), env, jtest_upload_data_stream_handler);
178 return reinterpret_cast<jlong>(handler); 178 return reinterpret_cast<jlong>(handler);
179 } 179 }
180 180
181 bool TestUploadDataStreamHandlerRegisterJni(JNIEnv* env) { 181 bool TestUploadDataStreamHandlerRegisterJni(JNIEnv* env) {
182 return RegisterNativesImpl(env); 182 return RegisterNativesImpl(env);
183 } 183 }
184 184
185 } // namespace cronet 185 } // namespace cronet
OLDNEW
« no previous file with comments | « chrome/browser/speech/tts_android.cc ('k') | components/gcm_driver/gcm_driver_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698