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

Issue 2169553002: Properly throw java exceptions from shouldOverrideUrlLoading (Closed)

Created:
4 years, 5 months ago by gsennton
Modified:
4 years, 4 months ago
Reviewers:
danakj, nyquist, Torne
CC:
chromium-reviews, sadrul, android-webview-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Properly throw java exceptions from shouldOverrideUrlLoading [WebView] Since all our java methods called through the jni-interface are annotated with @CalledByNative (rather than @CalledByNativeUnchecked) any java crash in those methods will cause a native crash since we call jni_android::CheckException (which aborts in native code) when returning from those methods. In this CL we annotate the jni-call for shouldOverrideUrlLoading with @CalledByNativeUnchecked to avoid crashing directly after the jni-call. We also add an Abort function for the android specific message loop and message pump to ensure no new tasks will be run before we return to the Java handler (at which point the original Java exception will be rethrown and thus correctly reported). BUG=592556 Committed: https://crrev.com/ebe2e203bd421bc1a5e4c28a48f7d54d407c6fac Cr-Commit-Position: refs/heads/master@{#412956}

Patch Set 1 #

Total comments: 12

Patch Set 2 : Fixed some nits and comments. #

Patch Set 3 : Add unit test draft #

Patch Set 4 : Better separation of production and test code, and minor cleanups. #

Total comments: 4

Patch Set 5 : Add test-only subclasses for JavaHandlerThread and SystemMessageHandler. #

Total comments: 6

Patch Set 6 : Add factory for creating custom java-side message handler. Separate test and production code. #

Patch Set 7 : Remove unused file. #

Total comments: 14

Patch Set 8 : Remove @MainDex from TestSystemMessageHandler + rebase + fix danakj's comments. #

Patch Set 9 : Create unittest-starter only for base unittests, register TestSystemMessageHandler jni bindings in … #

Total comments: 1

Patch Set 10 : Remove unused includes in test_support_android.cc. #

Total comments: 28

Patch Set 11 : Fix nyquist@'s nits. #

Patch Set 12 : Move run_all_base_unittests to base/test/. #

Total comments: 2

Patch Set 13 : Nit fix. #

Patch Set 14 : Fix trybot compilation failure. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+479 lines, -18 lines) Patch
M android_webview/browser/aw_content_browser_client.cc View 1 2 3 4 5 6 7 1 chunk +2 lines, -0 lines 0 comments Download
M android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java View 2 chunks +2 lines, -1 line 0 comments Download
M android_webview/native/aw_contents_client_bridge.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +11 lines, -1 line 0 comments Download
M base/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +6 lines, -3 lines 0 comments Download
M base/android/java/src/org/chromium/base/SystemMessageHandler.java View 1 2 3 4 5 3 chunks +9 lines, -5 lines 0 comments Download
M base/android/java_handler_thread.h View 1 2 3 4 1 chunk +6 lines, -1 line 0 comments Download
M base/android/java_handler_thread.cc View 1 2 3 4 5 6 7 1 chunk +10 lines, -2 lines 0 comments Download
A base/android/java_message_handler_factory.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +32 lines, -0 lines 0 comments Download
M base/message_loop/message_loop.h View 1 2 3 4 5 6 7 2 chunks +15 lines, -0 lines 0 comments Download
M base/message_loop/message_loop.cc View 1 2 3 4 5 6 7 1 chunk +12 lines, -0 lines 0 comments Download
M base/message_loop/message_loop_unittest.cc View 1 2 3 4 5 2 chunks +51 lines, -0 lines 0 comments Download
M base/message_loop/message_pump_android.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +18 lines, -0 lines 0 comments Download
M base/message_loop/message_pump_android.cc View 1 2 3 4 5 6 7 7 chunks +37 lines, -5 lines 0 comments Download
M base/test/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +18 lines, -0 lines 0 comments Download
A base/test/android/java/src/org/chromium/base/TestSystemMessageHandler.java View 1 2 3 4 5 6 7 8 9 10 1 chunk +54 lines, -0 lines 0 comments Download
A base/test/android/java_handler_thread_for_testing.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +54 lines, -0 lines 0 comments Download
A base/test/android/java_handler_thread_for_testing.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +49 lines, -0 lines 0 comments Download
A base/test/android/test_system_message_handler_link_android.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +43 lines, -0 lines 0 comments Download
A base/test/android/test_system_message_handler_link_android.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +40 lines, -0 lines 0 comments Download
A + base/test/run_all_base_unittests.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +10 lines, -0 lines 0 comments Download

Messages

Total messages: 49 (13 generated)
gsennton
torne@chromium.org: android_webview/ base/*android* thakis@chromium.org: base/message_loop/message_loop.* (I'm only doing android-specific changes here though)
4 years, 5 months ago (2016-07-20 17:05:16 UTC) #2
gsennton
On 2016/07/20 17:05:16, gsennton wrote: > mailto:torne@chromium.org: > android_webview/ > base/*android* > > > mailto:thakis@chromium.org: ...
4 years, 5 months ago (2016-07-20 18:09:46 UTC) #3
gsennton
Replaced thakis@ with danakj@ for base/message_loop/ since thakis@ is OOO.
4 years, 5 months ago (2016-07-20 21:01:54 UTC) #5
danakj
Can you provide some unit tests for this? https://codereview.chromium.org/2169553002/diff/1/base/message_loop/message_loop.cc File base/message_loop/message_loop.cc (right): https://codereview.chromium.org/2169553002/diff/1/base/message_loop/message_loop.cc#newcode627 base/message_loop/message_loop.cc:627: if ...
4 years, 5 months ago (2016-07-20 21:37:09 UTC) #6
Torne
https://codereview.chromium.org/2169553002/diff/1/android_webview/native/aw_contents_client_bridge.cc File android_webview/native/aw_contents_client_bridge.cc (right): https://codereview.chromium.org/2169553002/diff/1/android_webview/native/aw_contents_client_bridge.cc#newcode366 android_webview/native/aw_contents_client_bridge.cc:366: static_cast<base::MessageLoopForUI*>(base::MessageLoop::current())->Abort(); This stops later stages of DoRunLoopOnce from executing, ...
4 years, 5 months ago (2016-07-21 13:38:26 UTC) #7
gsennton
I'm not currently sure how we could unit test this, I guess what we are ...
4 years, 4 months ago (2016-07-26 14:42:39 UTC) #8
gsennton
I'm working on an instrumentation test for this but I'm still not sure how we ...
4 years, 4 months ago (2016-07-27 19:19:45 UTC) #9
danakj
On 2016/07/27 19:19:45, gsennton wrote: > I'm working on an instrumentation test for this but ...
4 years, 4 months ago (2016-07-28 23:21:37 UTC) #10
danakj
On 2016/07/28 23:21:37, danakj wrote: > On 2016/07/27 19:19:45, gsennton wrote: > > I'm working ...
4 years, 4 months ago (2016-07-28 23:22:10 UTC) #11
gsennton
Ok, so I've fiddled a bit with a unit test (posting a couple of tasks ...
4 years, 4 months ago (2016-07-29 14:35:06 UTC) #12
Torne
CL as implemented LGTM. Are you planning to add unit tests for the base-level functionality? ...
4 years, 4 months ago (2016-08-02 13:08:07 UTC) #13
gsennton
On 2016/08/02 13:08:07, Torne wrote: > CL as implemented LGTM. Are you planning to add ...
4 years, 4 months ago (2016-08-03 11:56:52 UTC) #14
gsennton
Alright, I've added a draft unit test now, it starts the message loop and posts ...
4 years, 4 months ago (2016-08-03 14:51:56 UTC) #15
gsennton
On 2016/08/03 14:51:56, gsennton_OOO_back_8.15 wrote: > Alright, I've added a draft unit test now, it ...
4 years, 4 months ago (2016-08-09 08:59:21 UTC) #16
Torne
On 2016/08/09 08:59:21, gsennton_OOO_back_8.15 wrote: > On 2016/08/03 14:51:56, gsennton_OOO_back_8.15 wrote: > > Alright, I've ...
4 years, 4 months ago (2016-08-09 11:16:36 UTC) #17
gsennton
Ok, so I haven't created a separate class instead of JavaHandlerThread yet (since I think ...
4 years, 4 months ago (2016-08-14 11:10:44 UTC) #20
danakj
On 2016/08/14 11:10:44, gsennton_OOO_back_8.15 wrote: > Ok, so I haven't created a separate class instead ...
4 years, 4 months ago (2016-08-15 18:20:25 UTC) #23
danakj
Thanks for all the work to get a test for this. LGTM but if you ...
4 years, 4 months ago (2016-08-15 18:29:59 UTC) #24
nyquist
https://codereview.chromium.org/2169553002/diff/60001/base/message_loop/message_pump_android.cc File base/message_loop/message_pump_android.cc (right): https://codereview.chromium.org/2169553002/diff/60001/base/message_loop/message_pump_android.cc#newcode147 base/message_loop/message_pump_android.cc:147: Start(delegate); Could this instantiate a subclass of SystemMessageHandler that ...
4 years, 4 months ago (2016-08-15 19:06:14 UTC) #26
gsennton
Alright! I've now added sub-classes for JavaHandlerThread (only on the native side) and SystemMessageHandler (added ...
4 years, 4 months ago (2016-08-16 15:27:36 UTC) #27
nyquist
https://codereview.chromium.org/2169553002/diff/80001/base/BUILD.gn File base/BUILD.gn (right): https://codereview.chromium.org/2169553002/diff/80001/base/BUILD.gn#newcode2448 base/BUILD.gn:2448: component("base_native_unittest_support") { Did you mean for this to be ...
4 years, 4 months ago (2016-08-16 17:46:39 UTC) #28
gsennton
Well, this turn into a bit of a monster... ptal :) https://codereview.chromium.org/2169553002/diff/80001/base/BUILD.gn File base/BUILD.gn (right): ...
4 years, 4 months ago (2016-08-17 17:05:48 UTC) #29
danakj
https://codereview.chromium.org/2169553002/diff/120001/base/android/java_message_handler_factory.h File base/android/java_message_handler_factory.h (right): https://codereview.chromium.org/2169553002/diff/120001/base/android/java_message_handler_factory.h#newcode23 base/android/java_message_handler_factory.h:23: JavaMessageHandlerFactory() {} dont need this https://codereview.chromium.org/2169553002/diff/120001/base/android/java_message_handler_factory.h#newcode32 base/android/java_message_handler_factory.h:32: DISALLOW_COPY_AND_ASSIGN(JavaMessageHandlerFactory); or ...
4 years, 4 months ago (2016-08-17 18:40:15 UTC) #30
gsennton
https://codereview.chromium.org/2169553002/diff/120001/base/android/java_message_handler_factory.h File base/android/java_message_handler_factory.h (right): https://codereview.chromium.org/2169553002/diff/120001/base/android/java_message_handler_factory.h#newcode23 base/android/java_message_handler_factory.h:23: JavaMessageHandlerFactory() {} On 2016/08/17 18:40:15, danakj wrote: > dont ...
4 years, 4 months ago (2016-08-17 19:23:47 UTC) #31
danakj
LGTM % android folks
4 years, 4 months ago (2016-08-17 20:22:30 UTC) #32
gsennton
Thanks danakj@, I had to make an additional small change (see base/run_all_base_unittests.cc), apart from that ...
4 years, 4 months ago (2016-08-18 13:03:09 UTC) #33
Torne
LGTM - thanks for the effort to get a test here!
4 years, 4 months ago (2016-08-18 14:33:43 UTC) #34
nyquist
lgtm % nits https://codereview.chromium.org/2169553002/diff/180001/android_webview/native/aw_contents_client_bridge.cc File android_webview/native/aw_contents_client_bridge.cc (right): https://codereview.chromium.org/2169553002/diff/180001/android_webview/native/aw_contents_client_bridge.cc#newcode355 android_webview/native/aw_contents_client_bridge.cc:355: // any new jni calls. Nit: ...
4 years, 4 months ago (2016-08-18 15:50:03 UTC) #35
danakj
https://codereview.chromium.org/2169553002/diff/180001/base/BUILD.gn File base/BUILD.gn (right): https://codereview.chromium.org/2169553002/diff/180001/base/BUILD.gn#newcode2198 base/BUILD.gn:2198: static_library("run_all_base_unittests") { Please move this to base/test/BUILD.gn https://codereview.chromium.org/2169553002/diff/180001/base/run_all_base_unittests.cc File ...
4 years, 4 months ago (2016-08-18 17:50:16 UTC) #36
danakj
Thanks, LGTM https://codereview.chromium.org/2169553002/diff/220001/base/test/BUILD.gn File base/test/BUILD.gn (right): https://codereview.chromium.org/2169553002/diff/220001/base/test/BUILD.gn#newcode270 base/test/BUILD.gn:270: # should depend on run_all_unittests above nit: ...
4 years, 4 months ago (2016-08-18 18:53:57 UTC) #37
gsennton
Alright! Commit queue inc. https://codereview.chromium.org/2169553002/diff/180001/android_webview/native/aw_contents_client_bridge.cc File android_webview/native/aw_contents_client_bridge.cc (right): https://codereview.chromium.org/2169553002/diff/180001/android_webview/native/aw_contents_client_bridge.cc#newcode355 android_webview/native/aw_contents_client_bridge.cc:355: // any new jni calls. ...
4 years, 4 months ago (2016-08-18 18:56:55 UTC) #38
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2169553002/240001
4 years, 4 months ago (2016-08-18 18:57:50 UTC) #41
commit-bot: I haz the power
Try jobs failed on following builders: android_clang_dbg_recipe on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_clang_dbg_recipe/builds/114907)
4 years, 4 months ago (2016-08-18 19:55:49 UTC) #43
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2169553002/260001
4 years, 4 months ago (2016-08-18 21:13:01 UTC) #46
commit-bot: I haz the power
Committed patchset #14 (id:260001)
4 years, 4 months ago (2016-08-18 22:34:33 UTC) #47
commit-bot: I haz the power
4 years, 4 months ago (2016-08-18 23:24:19 UTC) #49
Message was sent while issue was closed.
Patchset 14 (id:??) landed as
https://crrev.com/ebe2e203bd421bc1a5e4c28a48f7d54d407c6fac
Cr-Commit-Position: refs/heads/master@{#412956}

Powered by Google App Engine
This is Rietveld 408576698