Commit 5192f19a authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

weblayer: removes unnecessary try/catch

For methods called by native it's easier to declare the
function as throwing a RemoteException.

BUG=none
TEST=none

Change-Id: I2a5aa0caa2b683312390ff6d941cfe534a997fcd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463967Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815819}
parent dd8308e5
...@@ -370,36 +370,23 @@ public class BrowserImpl extends IBrowser.Stub implements View.OnAttachStateChan ...@@ -370,36 +370,23 @@ public class BrowserImpl extends IBrowser.Stub implements View.OnAttachStateChan
} }
@CalledByNative @CalledByNative
private void onTabAdded(TabImpl tab) { private void onTabAdded(TabImpl tab) throws RemoteException {
tab.attachToBrowser(this); tab.attachToBrowser(this);
try { if (mClient != null) mClient.onTabAdded(tab);
if (mClient != null) mClient.onTabAdded(tab);
} catch (RemoteException e) {
throw new APICallException(e);
}
} }
@CalledByNative @CalledByNative
private void onActiveTabChanged(TabImpl tab) { private void onActiveTabChanged(TabImpl tab) throws RemoteException {
if (mViewController != null) mViewController.setActiveTab(tab); if (mViewController != null) mViewController.setActiveTab(tab);
if (mInDestroy) return; if (!mInDestroy && mClient != null) {
try { mClient.onActiveTabChanged(tab != null ? tab.getId() : 0);
if (mClient != null) {
mClient.onActiveTabChanged(tab != null ? tab.getId() : 0);
}
} catch (RemoteException e) {
throw new APICallException(e);
} }
} }
@CalledByNative @CalledByNative
private void onTabRemoved(TabImpl tab) { private void onTabRemoved(TabImpl tab) throws RemoteException {
if (mInDestroy) return; if (mInDestroy) return;
try { if (mClient != null) mClient.onTabRemoved(tab.getId());
if (mClient != null) mClient.onTabRemoved(tab.getId());
} catch (RemoteException e) {
throw new APICallException(e);
}
// This doesn't reset state on TabImpl as |browser| is either about to be // This doesn't reset state on TabImpl as |browser| is either about to be
// destroyed, or switching to a different fragment. // destroyed, or switching to a different fragment.
} }
......
...@@ -11,7 +11,6 @@ import org.chromium.base.Callback; ...@@ -11,7 +11,6 @@ import org.chromium.base.Callback;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods; import org.chromium.base.annotations.NativeMethods;
import org.chromium.weblayer_private.interfaces.APICallException;
import org.chromium.weblayer_private.interfaces.CookieChangeCause; import org.chromium.weblayer_private.interfaces.CookieChangeCause;
import org.chromium.weblayer_private.interfaces.ICookieChangedCallbackClient; import org.chromium.weblayer_private.interfaces.ICookieChangedCallbackClient;
import org.chromium.weblayer_private.interfaces.ICookieManager; import org.chromium.weblayer_private.interfaces.ICookieManager;
...@@ -73,13 +72,9 @@ public final class CookieManagerImpl extends ICookieManager.Stub { ...@@ -73,13 +72,9 @@ public final class CookieManagerImpl extends ICookieManager.Stub {
} }
@CalledByNative @CalledByNative
private static void onCookieChange( private static void onCookieChange(ICookieChangedCallbackClient callback, String cookie,
ICookieChangedCallbackClient callback, String cookie, int cause) { int cause) throws RemoteException {
try { callback.onCookieChanged(cookie, mojoCauseToJavaType(cause));
callback.onCookieChanged(cookie, mojoCauseToJavaType(cause));
} catch (RemoteException e) {
throw new APICallException(e);
}
} }
@CookieChangeCause @CookieChangeCause
......
...@@ -804,16 +804,12 @@ public final class TabImpl extends ITab.Stub implements LoginPrompt.Observer { ...@@ -804,16 +804,12 @@ public final class TabImpl extends ITab.Stub implements LoginPrompt.Observer {
} }
@CalledByNative @CalledByNative
private void onFindResultAvailable( private void onFindResultAvailable(int numberOfMatches, int activeMatchOrdinal,
int numberOfMatches, int activeMatchOrdinal, boolean finalUpdate) { boolean finalUpdate) throws RemoteException {
try { if (mFindInPageCallbackClient != null) {
if (mFindInPageCallbackClient != null) { // The WebLayer API deals in indices instead of ordinals.
// The WebLayer API deals in indices instead of ordinals. mFindInPageCallbackClient.onFindResult(
mFindInPageCallbackClient.onFindResult( numberOfMatches, activeMatchOrdinal - 1, finalUpdate);
numberOfMatches, activeMatchOrdinal - 1, finalUpdate);
}
} catch (RemoteException e) {
throw new AndroidRuntimeException(e);
} }
if (mFindResultBar != null) { if (mFindResultBar != null) {
......
...@@ -44,22 +44,14 @@ public final class WebMessageReplyProxyImpl extends IWebMessageReplyProxy.Stub { ...@@ -44,22 +44,14 @@ public final class WebMessageReplyProxyImpl extends IWebMessageReplyProxy.Stub {
} }
@CalledByNative @CalledByNative
private void onNativeDestroyed() { private void onNativeDestroyed() throws RemoteException {
mNativeWebMessageReplyProxyImpl = 0; mNativeWebMessageReplyProxyImpl = 0;
try { mClient.onReplyProxyDestroyed(mId);
mClient.onReplyProxyDestroyed(mId);
} catch (RemoteException e) {
throw new APICallException(e);
}
} }
@CalledByNative @CalledByNative
private void onPostMessage(String message) { private void onPostMessage(String message) throws RemoteException {
try { mClient.onPostMessage(mId, message);
mClient.onPostMessage(mId, message);
} catch (RemoteException e) {
throw new APICallException(e);
}
} }
@Override @Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment