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

Side by Side Diff: base/android/jni_string.h

Issue 9358028: Upstream Android JNI code, allowing us to use more ScopedJava references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef BASE_ANDROID_JNI_STRING_H_ 5 #ifndef BASE_ANDROID_JNI_STRING_H_
6 #define BASE_ANDROID_JNI_STRING_H_ 6 #define BASE_ANDROID_JNI_STRING_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/android/scoped_java_ref.h"
11 #include "base/string16.h" 12 #include "base/string16.h"
12 #include "base/string_piece.h" 13 #include "base/string_piece.h"
13 14
14 namespace base { 15 namespace base {
15 namespace android { 16 namespace android {
16 17
17 // Convert a Java string to UTF8. Returns a std string. 18 // Convert a Java string to UTF8. Returns a std string.
18 std::string ConvertJavaStringToUTF8(JNIEnv* env, jstring str); 19 std::string ConvertJavaStringToUTF8(JNIEnv* env, jstring str);
20 std::string ConvertJavaStringToUTF8(const JavaRef<jstring>& str);
19 21
20 // Convert a std string to Java string. 22 // Convert a std string to Java string.
21 jstring ConvertUTF8ToJavaString(JNIEnv* env, const base::StringPiece& str); 23 ScopedJavaLocalRef<jstring> ConvertUTF8ToJavaString(
Steve Block 2012/02/08 18:41:55 I think this will break JavaBoundObject. Is the Ja
Jay Civelli 2012/02/08 18:49:56 In the JavaBoundObject we release the actual scope
Steve Block 2012/02/08 19:02:43 I just meant that it will cause a build break. Jav
Peter Beverloo 2012/02/09 15:25:29 There are several other files which have to be upd
24 JNIEnv* env, const base::StringPiece& str);
22 25
23 // Convert a Java string to UTF16. Returns a string16. 26 // Convert a Java string to UTF16. Returns a string16.
24 string16 ConvertJavaStringToUTF16(JNIEnv* env, jstring str); 27 string16 ConvertJavaStringToUTF16(JNIEnv* env, jstring str);
28 string16 ConvertJavaStringToUTF16(const JavaRef<jstring>& str);
25 29
26 // Convert a string16 to a Java string. 30 // Convert a string16 to a Java string.
27 jstring ConvertUTF16ToJavaString(JNIEnv* env, const string16& str); 31 ScopedJavaLocalRef<jstring> ConvertUTF16ToJavaString(
32 JNIEnv* env, const string16& str);
28 33
29 } // namespace android 34 } // namespace android
30 } // namespace base 35 } // namespace base
31 36
32 #endif // BASE_ANDROID_JNI_STRING_H_ 37 #endif // BASE_ANDROID_JNI_STRING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698