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

Issue 7480016: Add AutoJObject and AutoGlobalJObject (Closed)

Created:
9 years, 5 months ago by steveblock
Modified:
9 years, 4 months ago
CC:
chromium-reviews, brettw-cc_chromium.org
Visibility:
Public.

Description

Add AutoJObject and AutoGlobalJObject BUG= TEST= Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=95821

Patch Set 1 #

Patch Set 2 : Updated base.gypi to exclude android directory for any non-Android OS #

Total comments: 4

Patch Set 3 : Fixed nitts #

Total comments: 11

Patch Set 4 : Removed FromLocalRef() #

Total comments: 3

Patch Set 5 : Uses templated ScopedJava(Global)Reference #

Patch Set 6 : Adds use of static_cast #

Patch Set 7 : Correct upload error #

Total comments: 12

Patch Set 8 : Fixed nits #

Unified diffs Side-by-side diffs Delta from patch set Stats (+138 lines, -0 lines) Patch
A base/android/scoped_java_global_reference.h View 1 2 3 4 5 6 7 1 chunk +63 lines, -0 lines 0 comments Download
A base/android/scoped_java_reference.h View 1 2 3 4 5 6 7 1 chunk +69 lines, -0 lines 0 comments Download
M base/base.gypi View 1 2 3 4 2 chunks +6 lines, -0 lines 0 comments Download

Messages

Total messages: 18 (0 generated)
steveblock
Marcus, should these files be guarded with OS_ANDROID and/or excluded from the build for non-Android ...
9 years, 5 months ago (2011-07-26 15:35:42 UTC) #1
steveblock
Michael, Marcus mentioned that you're working on Android-specific code in base/. Is this patch in ...
9 years, 5 months ago (2011-07-26 15:47:21 UTC) #2
michaelbai
http://codereview.chromium.org/7480016/diff/3001/base/base.gypi File base/base.gypi (right): http://codereview.chromium.org/7480016/diff/3001/base/base.gypi#newcode25 base/base.gypi:25: 'android/auto_jobject.h', Above 4 lines might be in line 15.
9 years, 5 months ago (2011-07-26 17:34:15 UTC) #3
michaelbai
http://codereview.chromium.org/7480016/diff/3001/base/base.gypi File base/base.gypi (right): http://codereview.chromium.org/7480016/diff/3001/base/base.gypi#newcode25 base/base.gypi:25: 'android/auto_jobject.h', On 2011/07/26 17:34:15, michaelbai wrote: > Above 4 ...
9 years, 5 months ago (2011-07-26 17:44:58 UTC) #4
steveblock
9 years, 5 months ago (2011-07-26 18:22:43 UTC) #5
bulach
(I'm not in the owners, but LGTM) just a couple of nits: http://codereview.chromium.org/7480016/diff/3001/base/android/auto_jobject.cc File base/android/auto_jobject.cc ...
9 years, 5 months ago (2011-07-26 18:23:04 UTC) #6
brettw
http://codereview.chromium.org/7480016/diff/8001/base/android/auto_global_jobject.h File base/android/auto_global_jobject.h (right): http://codereview.chromium.org/7480016/diff/8001/base/android/auto_global_jobject.h#newcode20 base/android/auto_global_jobject.h:20: static AutoGlobalJObject FromLocalRef(JNIEnv* env, jobject obj); There's not a ...
9 years, 4 months ago (2011-08-01 16:03:53 UTC) #7
steveblock
http://codereview.chromium.org/7480016/diff/8001/base/android/auto_global_jobject.h File base/android/auto_global_jobject.h (right): http://codereview.chromium.org/7480016/diff/8001/base/android/auto_global_jobject.h#newcode20 base/android/auto_global_jobject.h:20: static AutoGlobalJObject FromLocalRef(JNIEnv* env, jobject obj); On 2011/08/01 16:03:54, ...
9 years, 4 months ago (2011-08-02 15:05:45 UTC) #8
bulach
reply inline: http://codereview.chromium.org/7480016/diff/8001/base/android/auto_jobject.h File base/android/auto_jobject.h (right): http://codereview.chromium.org/7480016/diff/8001/base/android/auto_jobject.h#newcode17 base/android/auto_jobject.h:17: static AutoJObject FromLocalRef(JNIEnv* env, jobject obj); On ...
9 years, 4 months ago (2011-08-02 15:18:36 UTC) #9
Sami (do not use)
http://codereview.chromium.org/7480016/diff/8001/base/android/auto_jobject.h File base/android/auto_jobject.h (right): http://codereview.chromium.org/7480016/diff/8001/base/android/auto_jobject.h#newcode17 base/android/auto_jobject.h:17: static AutoJObject FromLocalRef(JNIEnv* env, jobject obj); I'd be fine ...
9 years, 4 months ago (2011-08-02 15:23:48 UTC) #10
steveblock
Great, I'll upload a new patch without FromLocalRef(). I think this makes sense, as this ...
9 years, 4 months ago (2011-08-02 15:28:21 UTC) #11
brettw
http://codereview.chromium.org/7480016/diff/8001/base/android/auto_global_jobject.h File base/android/auto_global_jobject.h (right): http://codereview.chromium.org/7480016/diff/8001/base/android/auto_global_jobject.h#newcode23 base/android/auto_global_jobject.h:23: AutoGlobalJObject(const AutoGlobalJObject& other); If you're going to be returning ...
9 years, 4 months ago (2011-08-02 15:55:39 UTC) #12
steveblock
> we might consider use template in AutoJObject. Sounds reasonable. I'll rename to ScopedJava(Global)Reference and ...
9 years, 4 months ago (2011-08-02 17:45:17 UTC) #13
bulach
LGTM (not an owner). just some nits / suggestions below: http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_global_reference.h File base/android/scoped_java_global_reference.h (right): http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_global_reference.h#newcode18 ...
9 years, 4 months ago (2011-08-05 12:03:01 UTC) #14
michaelbai
I doubt we should have copy constructor. From my point of view, the ScopedJavaReference just ...
9 years, 4 months ago (2011-08-05 16:48:13 UTC) #15
brettw
LGTM
9 years, 4 months ago (2011-08-05 23:20:38 UTC) #16
steveblock
> I doubt we should have copy constructor. Unfortunately, as mentioned, this is required to ...
9 years, 4 months ago (2011-08-08 11:28:32 UTC) #17
michaelbai
9 years, 4 months ago (2011-08-08 16:26:35 UTC) #18
I didn't want to get in your way of submitting it, please feel free to do it. 

The orignal design of AutoJObject and AutoGlobalJObject might have some issues.

The calling DeleteLocalRef is optional, which means the JVM could gc it at
anytime when we left the function or the block where the local reference was
gotten.

So, what's the point of returning a ScopedJavaReference? Why
ScopedJavaGlobalReference just has the constructor which has java object itself
as parameter instead of ScopedJavaReference since we have
ScopedJavaReference::obj(). 


On 2011/08/08 11:28:32, Steve Block wrote:
> > I doubt we should have copy constructor.
> Unfortunately, as mentioned, this is required to allow us to return
> ScopedJavaReference by value, such as from JavaObjectWeakGlobalRef::get().
> 
> > Having copy constructor and release method might imply the
> > embedded Java object will still available as long as we
> > keep the reference.
> I'm not sure what you mean. Can you elaborate?
> 
> Given that we seem to be agreed on the basic approach for these classes, and
> that this patch has been in review for so long already, I'm going to commit
it.
> Tao, I'm happy to work with you to remove the need for the ScopedJavaReference
> copy constructor.
> 
>
http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_gl...
> File base/android/scoped_java_global_reference.h (right):
> 
>
http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_gl...
> base/android/scoped_java_global_reference.h:18: // to the lifetime of this
> object.
> On 2011/08/05 12:03:02, bulach wrote:
> > perhaps we can also add a comment saying that this isn't thread-friendly as
> the
> > jnienv can't cross thread boundaries / must be only used / destroyed in the
> > thread that created it?
> 
> Done.
> 
>
http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_gl...
> base/android/scoped_java_global_reference.h:28: // reference is deleted when
> this object goes out of scope.
> On 2011/08/05 12:03:02, bulach wrote:
> > the second sentence seems a bit redundant with the class comment on 17.
> 
> Done.
> 
>
http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_gl...
> base/android/scoped_java_global_reference.h:48: }
> On 2011/08/05 12:03:02, bulach wrote:
> > I'm not sure if we have a pattern for \n, but I'd add one here to separate
the
> > methods above.
> 
> Done.
> 
>
http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_re...
> File base/android/scoped_java_reference.h (right):
> 
>
http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_re...
> base/android/scoped_java_reference.h:26: // goes out of scope.
> On 2011/08/05 12:03:02, bulach wrote:
> > same here.
> 
> Done.
> 
>
http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_re...
> base/android/scoped_java_reference.h:51: T obj() const { return obj_; }
> On 2011/08/05 12:03:02, bulach wrote:
> > \n
> 
> Done.
> 
>
http://codereview.chromium.org/7480016/diff/13002/base/android/scoped_java_re...
> base/android/scoped_java_reference.h:61: 
> On 2011/08/05 12:03:02, bulach wrote:
> > remove \n
> 
> Done.

Powered by Google App Engine
This is Rietveld 408576698