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

Issue 864563002: Separate JNI registration with initialization (Closed)

Created:
5 years, 11 months ago by michaelbai
Modified:
5 years, 10 months ago
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, jbudorick+watch_chromium.org, darin-cc_chromium.org, yfriedman+watch_chromium.org, mkwst+moarreviews-shell_chromium.org, erikwright+watch_chromium.org, klundberg+watch_chromium.org, jochen+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

This is the first patch to separate JNI registration with initialization, currently, we have JNI_OnLoad defined multiple places which has a lot of duplicated code and JNI registration and initialization are mixed; This patch - Added JNIOnLoadDelegate class for each component specific initialization. - Added base::android::OnJNIOnLoad() to call a list of delegates - Migrate testing, content_shell, chrome_shell. BUG=447393 TBR=thakis Committed: https://crrev.com/842c972d5011ed671d2486deee78ae7640b0cca6 Cr-Commit-Position: refs/heads/master@{#313592}

Patch Set 1 #

Patch Set 2 : move JNI_OnLoad back #

Patch Set 3 : fix component build #

Total comments: 7

Patch Set 4 : put delegate implementation into .cc #

Total comments: 8

Patch Set 5 : address comments #

Total comments: 7

Patch Set 6 : address comments and sync #

Unified diffs Side-by-side diffs Delta from patch set Stats (+421 lines, -110 lines) Patch
M base/BUILD.gn View 1 2 3 4 5 2 chunks +3 lines, -0 lines 0 comments Download
A base/android/base_jni_onload.h View 1 2 3 4 5 1 chunk +27 lines, -0 lines 0 comments Download
A base/android/base_jni_onload.cc View 1 2 3 4 5 1 chunk +64 lines, -0 lines 0 comments Download
A base/android/jni_onload_delegate.h View 1 2 3 4 5 1 chunk +41 lines, -0 lines 0 comments Download
M base/base.gypi View 1 2 3 4 5 2 chunks +3 lines, -0 lines 0 comments Download
M chrome/BUILD.gn View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M chrome/android/BUILD.gn View 1 2 chunks +0 lines, -6 lines 0 comments Download
M chrome/app/android/chrome_android_initializer.h View 1 chunk +1 line, -5 lines 0 comments Download
M chrome/app/android/chrome_android_initializer.cc View 1 chunk +3 lines, -14 lines 0 comments Download
D chrome/app/android/chrome_jni_onload.cc View 1 2 3 4 5 1 chunk +28 lines, -7 lines 0 comments Download
M chrome/chrome_android.gypi View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M chrome/chrome_shell.gypi View 1 2 3 4 5 2 chunks +0 lines, -6 lines 0 comments Download
M content/app/BUILD.gn View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
A content/app/android/content_jni_onload.cc View 1 2 3 4 5 1 chunk +52 lines, -0 lines 0 comments Download
M content/content_app.gypi View 1 2 3 2 chunks +2 lines, -0 lines 0 comments Download
M content/content_shell.gypi View 1 2 3 1 chunk +0 lines, -1 line 0 comments Download
M content/content_tests.gypi View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M content/public/app/BUILD.gn View 1 1 chunk +1 line, -0 lines 0 comments Download
A content/public/app/content_jni_onload.h View 1 2 3 4 1 chunk +32 lines, -0 lines 0 comments Download
M content/shell/android/BUILD.gn View 1 2 3 1 chunk +0 lines, -1 line 0 comments Download
A content/shell/android/browsertests_apk/content_browser_tests_android.h View 1 chunk +16 lines, -0 lines 0 comments Download
M content/shell/android/browsertests_apk/content_browser_tests_android.cc View 2 chunks +4 lines, -26 lines 0 comments Download
A content/shell/android/browsertests_apk/content_browser_tests_jni_onload.cc View 1 2 3 4 5 1 chunk +44 lines, -0 lines 0 comments Download
D content/shell/android/shell_library_loader.cc View 1 2 3 4 5 1 chunk +23 lines, -18 lines 0 comments Download
M testing/android/BUILD.gn View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M testing/android/native_test.gyp View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
A testing/android/native_test_jni_onload.cc View 1 2 3 4 5 1 chunk +40 lines, -0 lines 0 comments Download
A testing/android/native_test_launcher.h View 1 chunk +13 lines, -0 lines 0 comments Download
M testing/android/native_test_launcher.cc View 1 3 chunks +15 lines, -26 lines 0 comments Download

Messages

Total messages: 23 (3 generated)
michaelbai
nyquist@ for base/android jam@ for content dtrainor@ chrome/app/android
5 years, 11 months ago (2015-01-20 20:12:23 UTC) #3
David Trainor- moved to gerrit
chrome/app/android lgtm
5 years, 11 months ago (2015-01-21 08:18:40 UTC) #4
jam
i have a few questions, can we chat about this in person? would be faster ...
5 years, 11 months ago (2015-01-21 16:45:30 UTC) #5
michaelbai
On 2015/01/21 16:45:30, jam wrote: > i have a few questions, can we chat about ...
5 years, 11 months ago (2015-01-21 17:21:13 UTC) #6
michaelbai
jam@, I modified the patch as we discussed, PTAL
5 years, 11 months ago (2015-01-23 21:49:42 UTC) #7
jam
https://codereview.chromium.org/864563002/diff/40001/base/android/base_jni_onload_delegate.h File base/android/base_jni_onload_delegate.h (right): https://codereview.chromium.org/864563002/diff/40001/base/android/base_jni_onload_delegate.h#newcode14 base/android/base_jni_onload_delegate.h:14: class BaseJNIOnLoadDelegate : public JNIOnLoadDelegate { since the only ...
5 years, 11 months ago (2015-01-26 22:38:22 UTC) #8
michaelbai
jam@, all comments were addressed, PTAL
5 years, 11 months ago (2015-01-27 03:45:32 UTC) #9
jam
lgtm https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_onload.cc File base/android/base_jni_onload.cc (right): https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_onload.cc#newcode23 base/android/base_jni_onload.cc:23: bool BaseJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) { nit: it'd be easier ...
5 years, 11 months ago (2015-01-27 16:10:34 UTC) #10
michaelbai
@jam, please see my comments about inline implementation https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_onload.cc File base/android/base_jni_onload.cc (right): https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_onload.cc#newcode23 base/android/base_jni_onload.cc:23: bool ...
5 years, 11 months ago (2015-01-27 20:13:50 UTC) #11
michaelbai
nyquist@ PTAL dtrainor@ PTAL for both chrome and testing/android
5 years, 11 months ago (2015-01-27 23:54:34 UTC) #12
nyquist
base lgtm https://codereview.chromium.org/864563002/diff/80001/base/android/jni_onload_delegate.h File base/android/jni_onload_delegate.h (right): https://codereview.chromium.org/864563002/diff/80001/base/android/jni_onload_delegate.h#newcode24 base/android/jni_onload_delegate.h:24: // RegisterJNI(), so it could be strip ...
5 years, 11 months ago (2015-01-28 01:25:40 UTC) #13
nyquist
https://codereview.chromium.org/864563002/diff/80001/base/android/base_jni_onload.h File base/android/base_jni_onload.h (right): https://codereview.chromium.org/864563002/diff/80001/base/android/base_jni_onload.h#newcode18 base/android/base_jni_onload.h:18: // Returns true if JNI registration and initialization succeeded. ...
5 years, 11 months ago (2015-01-28 01:26:03 UTC) #14
David Trainor- moved to gerrit
chrome/ and testing/ lgtm with small nits https://codereview.chromium.org/864563002/diff/80001/chrome/app/android/chrome_jni_onload.cc File chrome/app/android/chrome_jni_onload.cc (right): https://codereview.chromium.org/864563002/diff/80001/chrome/app/android/chrome_jni_onload.cc#newcode14 chrome/app/android/chrome_jni_onload.cc:14: virtual bool ...
5 years, 10 months ago (2015-01-28 19:13:25 UTC) #15
michaelbai
you are right, virtual is not necessary https://codereview.chromium.org/864563002/diff/80001/chrome/app/android/chrome_jni_onload.cc File chrome/app/android/chrome_jni_onload.cc (right): https://codereview.chromium.org/864563002/diff/80001/chrome/app/android/chrome_jni_onload.cc#newcode14 chrome/app/android/chrome_jni_onload.cc:14: virtual bool ...
5 years, 10 months ago (2015-01-28 19:50:58 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/864563002/100001
5 years, 10 months ago (2015-01-28 20:16:25 UTC) #18
commit-bot: I haz the power
Committed patchset #6 (id:100001)
5 years, 10 months ago (2015-01-28 21:41:06 UTC) #19
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/842c972d5011ed671d2486deee78ae7640b0cca6 Cr-Commit-Position: refs/heads/master@{#313592}
5 years, 10 months ago (2015-01-28 21:42:23 UTC) #20
jam
https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_onload.cc File base/android/base_jni_onload.cc (right): https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_onload.cc#newcode23 base/android/base_jni_onload.cc:23: bool BaseJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) { On 2015/01/27 20:13:50, michaelbai wrote: ...
5 years, 10 months ago (2015-01-28 21:48:49 UTC) #21
Peter Kasting
On 2015/01/27 20:13:50, michaelbai wrote: > https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_onload.cc > File base/android/base_jni_onload.cc (right): > > https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_onload.cc#newcode23 > ...
5 years, 10 months ago (2015-01-28 23:40:46 UTC) #22
michaelbai
5 years, 10 months ago (2015-01-28 23:51:04 UTC) #23
Message was sent while issue was closed.
On 2015/01/28 23:40:46, Peter Kasting wrote:
> On 2015/01/27 20:13:50, michaelbai wrote:
> >
>
https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_on...
> > File base/android/base_jni_onload.cc (right):
> > 
> >
>
https://codereview.chromium.org/864563002/diff/60001/base/android/base_jni_on...
> > base/android/base_jni_onload.cc:23: bool
> > BaseJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) {
> > On 2015/01/27 16:10:33, jam wrote:
> > > nit: it'd be easier to read if these two short methods wre inlined above..
> > same
> > > for other files
> > 
> > I were told this style is only acceptable in unit tests, is it true?
> > I expect the method will be more complicated than now after refactoring is
> done,
> > is it still ok to have them inline?
> 
> For reference: inlining code into class declarations is acceptable in .cc
files;
> it's primarily a judgment call between author and reviewers what is ultimately
> most readable.
> 
> The C++ Dos and Don'ts page (
>
https://sites.google.com/a/chromium.org/dev/developers/coding-style/cpp-dos-a...
> ) has been clarified to make this more explicit.


Thanks for clarifying this!!

Powered by Google App Engine
This is Rietveld 408576698