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

Issue 8769005: Don't use Singleton to cache JNI method IDs in Java Bridge (Closed)

Created:
9 years ago by Steve Block
Modified:
9 years ago
CC:
chromium-reviews, joi+watch-content_chromium.org, darin-cc_chromium.org, dpranke-watch+content_chromium.org, jam, brettw-cc_chromium.org
Visibility:
Public.

Description

Don't use Singleton to cache JNI method IDs in Java Bridge The Java Bridge makes repeated use of numerous JNI method IDs. We wish to avoid repeatedly looking up these IDS, so we cache them. Currently we use Singleton objects to achieve this. However, this seems inappropriate for several reasons ... - Requires excessive boilerplate - Thread safety not required - Exit cleanup not required We can avoid using Singleton, without introducing static initializers, by simply using a static local. See http://codereview.chromium.org/8659007 for background. TBR=avi BUG=105547 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=112975

Patch Set 1 #

Total comments: 8

Patch Set 2 : Move caching to GetMethodIDFromClassName() #

Patch Set 3 : Finer grained locking #

Total comments: 2

Patch Set 4 : Updated comments, share some constants #

Total comments: 5

Patch Set 5 : Addressed comments and added test #

Total comments: 2

Patch Set 6 : Rename test file, fix comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+242 lines, -133 lines) Patch
M base/android/jni_android.h View 1 2 3 4 5 1 chunk +11 lines, -13 lines 0 comments Download
M base/android/jni_android.cc View 1 2 3 4 2 chunks +79 lines, -3 lines 0 comments Download
A base/android/jni_android_unittest.cc View 1 2 3 4 5 1 chunk +86 lines, -0 lines 0 comments Download
M base/base.gyp View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/renderer_host/java/java_bound_object.cc View 1 2 3 4 4 chunks +19 lines, -33 lines 0 comments Download
M content/browser/renderer_host/java/java_method.cc View 1 2 3 4 7 chunks +46 lines, -84 lines 0 comments Download

Messages

Total messages: 19 (0 generated)
Steve Block
9 years ago (2011-12-01 12:00:59 UTC) #1
joth
Fab, thanks. I think this is a much better pattern (for single threaded users, at ...
9 years ago (2011-12-01 12:55:25 UTC) #2
Steve Block
9 years ago (2011-12-01 13:20:12 UTC) #3
M-A Ruel
(Note the comments below aren't in the right order) http://codereview.chromium.org/8769005/diff/1/base/android/jni_android.cc File base/android/jni_android.cc (right): http://codereview.chromium.org/8769005/diff/1/base/android/jni_android.cc#newcode23 base/android/jni_android.cc:23: ...
9 years ago (2011-12-01 14:36:03 UTC) #4
Steve Block
http://codereview.chromium.org/8769005/diff/1/base/android/jni_android.cc File base/android/jni_android.cc (right): http://codereview.chromium.org/8769005/diff/1/base/android/jni_android.cc#newcode23 base/android/jni_android.cc:23: jint ret = g_jvm->AttachCurrentThread(&env, NULL); AttachCurrentThread() is intended to ...
9 years ago (2011-12-01 17:48:42 UTC) #5
joth
http://codereview.chromium.org/8769005/diff/1/content/browser/renderer_host/java/java_bound_object.cc File content/browser/renderer_host/java/java_bound_object.cc (left): http://codereview.chromium.org/8769005/diff/1/content/browser/renderer_host/java/java_bound_object.cc#oldcode487 content/browser/renderer_host/java/java_bound_object.cc:487: return Singleton<ObjectGetClassID>::get(); On 2011/12/01 14:36:03, Marc-Antoine Ruel wrote: > ...
9 years ago (2011-12-02 11:39:02 UTC) #6
M-A Ruel
On 2011/12/02 11:39:02, joth wrote: > http://codereview.chromium.org/8769005/diff/1/content/browser/renderer_host/java/java_bound_object.cc > File content/browser/renderer_host/java/java_bound_object.cc (left): > > http://codereview.chromium.org/8769005/diff/1/content/browser/renderer_host/java/java_bound_object.cc#oldcode487 > ...
9 years ago (2011-12-02 12:40:31 UTC) #7
M-A Ruel
http://codereview.chromium.org/8769005/diff/5001/base/android/jni_android.cc File base/android/jni_android.cc (right): http://codereview.chromium.org/8769005/diff/5001/base/android/jni_android.cc#newcode65 base/android/jni_android.cc:65: DCHECK_EQ(std::string::npos, std::string(class_name).find('!')); Can this code ever be called from ...
9 years ago (2011-12-02 12:40:57 UTC) #8
Steve Block
http://codereview.chromium.org/8769005/diff/5001/base/android/jni_android.cc File base/android/jni_android.cc (right): http://codereview.chromium.org/8769005/diff/5001/base/android/jni_android.cc#newcode65 base/android/jni_android.cc:65: DCHECK_EQ(std::string::npos, std::string(class_name).find('!')); No. Currently it's only used with constants. ...
9 years ago (2011-12-02 12:49:10 UTC) #9
joth
LGTM with a couple suggestions that could be done later if preferred ... http://codereview.chromium.org/8769005/diff/5003/base/android/jni_android.cc File ...
9 years ago (2011-12-02 14:10:13 UTC) #10
Steve Block
9 years ago (2011-12-02 16:44:54 UTC) #11
joth
lg from my side... http://codereview.chromium.org/8769005/diff/5003/content/browser/renderer_host/java/java_bound_object.cc File content/browser/renderer_host/java/java_bound_object.cc (right): http://codereview.chromium.org/8769005/diff/5003/content/browser/renderer_host/java/java_bound_object.cc#newcode570 content/browser/renderer_host/java/java_bound_object.cc:570: "()Ljava/lang/Class;")))); No problem with named ...
9 years ago (2011-12-02 17:35:36 UTC) #12
Steve Block
Thanks for the reviews, will land on Monday if no further comments.
9 years ago (2011-12-02 18:05:18 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/steveblock@chromium.org/8769005/5005
9 years ago (2011-12-05 10:38:09 UTC) #14
commit-bot: I haz the power
Presubmit check for 8769005-5005 failed and returned exit status 1. Running presubmit commit checks ...
9 years ago (2011-12-05 10:38:13 UTC) #15
Steve Block
+avi for content/browser/renderer_host
9 years ago (2011-12-05 10:44:31 UTC) #16
M-A Ruel
On 2011/12/05 10:44:31, Steve Block wrote: > +avi for content/browser/renderer_host Setting as TBR, it's been ...
9 years ago (2011-12-05 11:51:20 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/steveblock@chromium.org/8769005/5005
9 years ago (2011-12-05 11:51:34 UTC) #18
commit-bot: I haz the power
9 years ago (2011-12-05 14:42:13 UTC) #19
Change committed as 112975

Powered by Google App Engine
This is Rietveld 408576698