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

Side by Side Diff: chrome/browser/speech/tts_android.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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/speech/tts_android.h" 5 #include "chrome/browser/speech/tts_android.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 39
40 bool TtsPlatformImplAndroid::Speak( 40 bool TtsPlatformImplAndroid::Speak(
41 int utterance_id, 41 int utterance_id,
42 const std::string& utterance, 42 const std::string& utterance,
43 const std::string& lang, 43 const std::string& lang,
44 const VoiceData& voice, 44 const VoiceData& voice,
45 const UtteranceContinuousParameters& params) { 45 const UtteranceContinuousParameters& params) {
46 JNIEnv* env = AttachCurrentThread(); 46 JNIEnv* env = AttachCurrentThread();
47 jboolean success = Java_TtsPlatformImpl_speak( 47 jboolean success = Java_TtsPlatformImpl_speak(
48 env, java_ref_.obj(), 48 env, java_ref_.obj(), utterance_id,
49 utterance_id, 49 base::android::ConvertUTF8ToJavaString(env, utterance).obj(),
50 base::android::ConvertUTF8ToJavaString(env, utterance).Release(), 50 base::android::ConvertUTF8ToJavaString(env, lang).obj(), params.rate,
51 base::android::ConvertUTF8ToJavaString(env, lang).Release(), 51 params.pitch, params.volume);
52 params.rate, params.pitch, params.volume);
53 if (!success) 52 if (!success)
54 return false; 53 return false;
55 54
56 utterance_ = utterance; 55 utterance_ = utterance;
57 utterance_id_ = utterance_id; 56 utterance_id_ = utterance_id;
58 return true; 57 return true;
59 } 58 }
60 59
61 bool TtsPlatformImplAndroid::StopSpeaking() { 60 bool TtsPlatformImplAndroid::StopSpeaking() {
62 JNIEnv* env = AttachCurrentThread(); 61 JNIEnv* env = AttachCurrentThread();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // static 136 // static
138 TtsPlatformImplAndroid* TtsPlatformImplAndroid::GetInstance() { 137 TtsPlatformImplAndroid* TtsPlatformImplAndroid::GetInstance() {
139 return Singleton<TtsPlatformImplAndroid, 138 return Singleton<TtsPlatformImplAndroid,
140 LeakySingletonTraits<TtsPlatformImplAndroid> >::get(); 139 LeakySingletonTraits<TtsPlatformImplAndroid> >::get();
141 } 140 }
142 141
143 // static 142 // static
144 bool TtsPlatformImplAndroid::Register(JNIEnv* env) { 143 bool TtsPlatformImplAndroid::Register(JNIEnv* env) {
145 return RegisterNativesImpl(env); 144 return RegisterNativesImpl(env);
146 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698