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

Side by Side Diff: base/test/android/java/src/org/chromium/base/TestSystemMessageHandler.java

Issue 2169553002: Properly throw java exceptions from shouldOverrideUrlLoading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix trybot compilation failure. Created 4 years, 4 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
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/android/java_handler_thread_for_testing.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.base;
6
7 import android.os.Message;
8
9 import org.chromium.base.annotations.CalledByNative;
10 import org.chromium.base.annotations.JNINamespace;
11
12 /**
13 * Test-only message handler enabling us to test that Java exceptions thrown fro m a JNI call
14 * originating from the native side are propagated to the Message Handler (inste ad of causing a
15 * native crash).
16 * This class declares a custom exception and wraps the SystemMessageHandler mes sage handling
17 * mechanism to catch such exceptions. When catching an exception we call the na tive side to notify
18 * tests that the correct exception was thrown and caught.
19 */
20 @JNINamespace("base::android")
21 class TestSystemMessageHandler extends SystemMessageHandler {
22 private long mWaitableTestEventNative;
23
24 private TestSystemMessageHandler(
25 long messagePumpDelegateNative, long messagePumpNative, long waitabl eTestEventNative) {
26 super(messagePumpDelegateNative, messagePumpNative);
27 mWaitableTestEventNative = waitableTestEventNative;
28 }
29
30 @Override
31 public void handleMessage(Message msg) {
32 try {
33 super.handleMessage(msg);
34 } catch (TestException e) {
35 nativeNotifyTestDone(mWaitableTestEventNative);
36 return;
37 }
38 }
39
40 private static class TestException extends RuntimeException {
41 TestException(String message) {
42 super(message);
43 }
44 }
45
46 @CalledByNative
47 private static TestSystemMessageHandler create(
48 long messagePumpDelegateNative, long messagePumpNative, long waitabl eTestEvent) {
49 return new TestSystemMessageHandler(
50 messagePumpDelegateNative, messagePumpNative, waitableTestEvent) ;
51 }
52
53 private static native void nativeNotifyTestDone(long messagePumpNative);
54 }
OLDNEW
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/android/java_handler_thread_for_testing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698