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
}
@CalledByNative
private void onTabAdded(TabImpl tab) {
private void onTabAdded(TabImpl tab) throws RemoteException {
tab.attachToBrowser(this);
try {
if (mClient != null) mClient.onTabAdded(tab);
} catch (RemoteException e) {
throw new APICallException(e);
}
if (mClient != null) mClient.onTabAdded(tab);
}
@CalledByNative
private void onActiveTabChanged(TabImpl tab) {
private void onActiveTabChanged(TabImpl tab) throws RemoteException {
if (mViewController != null) mViewController.setActiveTab(tab);
if (mInDestroy) return;
try {
if (mClient != null) {
mClient.onActiveTabChanged(tab != null ? tab.getId() : 0);
}
} catch (RemoteException e) {
throw new APICallException(e);
if (!mInDestroy && mClient != null) {
mClient.onActiveTabChanged(tab != null ? tab.getId() : 0);
}
}
@CalledByNative
private void onTabRemoved(TabImpl tab) {
private void onTabRemoved(TabImpl tab) throws RemoteException {
if (mInDestroy) return;
try {
if (mClient != null) mClient.onTabRemoved(tab.getId());
} catch (RemoteException e) {
throw new APICallException(e);
}
if (mClient != null) mClient.onTabRemoved(tab.getId());
// This doesn't reset state on TabImpl as |browser| is either about to be
// destroyed, or switching to a different fragment.
}
......
......@@ -11,7 +11,6 @@ import org.chromium.base.Callback;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
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.ICookieChangedCallbackClient;
import org.chromium.weblayer_private.interfaces.ICookieManager;
......@@ -73,13 +72,9 @@ public final class CookieManagerImpl extends ICookieManager.Stub {
}
@CalledByNative
private static void onCookieChange(
ICookieChangedCallbackClient callback, String cookie, int cause) {
try {
callback.onCookieChanged(cookie, mojoCauseToJavaType(cause));
} catch (RemoteException e) {
throw new APICallException(e);
}
private static void onCookieChange(ICookieChangedCallbackClient callback, String cookie,
int cause) throws RemoteException {
callback.onCookieChanged(cookie, mojoCauseToJavaType(cause));
}
@CookieChangeCause
......
......@@ -804,16 +804,12 @@ public final class TabImpl extends ITab.Stub implements LoginPrompt.Observer {
}
@CalledByNative
private void onFindResultAvailable(
int numberOfMatches, int activeMatchOrdinal, boolean finalUpdate) {
try {
if (mFindInPageCallbackClient != null) {
// The WebLayer API deals in indices instead of ordinals.
mFindInPageCallbackClient.onFindResult(
numberOfMatches, activeMatchOrdinal - 1, finalUpdate);
}
} catch (RemoteException e) {
throw new AndroidRuntimeException(e);
private void onFindResultAvailable(int numberOfMatches, int activeMatchOrdinal,
boolean finalUpdate) throws RemoteException {
if (mFindInPageCallbackClient != null) {
// The WebLayer API deals in indices instead of ordinals.
mFindInPageCallbackClient.onFindResult(
numberOfMatches, activeMatchOrdinal - 1, finalUpdate);
}
if (mFindResultBar != null) {
......
......@@ -44,22 +44,14 @@ public final class WebMessageReplyProxyImpl extends IWebMessageReplyProxy.Stub {
}
@CalledByNative
private void onNativeDestroyed() {
private void onNativeDestroyed() throws RemoteException {
mNativeWebMessageReplyProxyImpl = 0;
try {
mClient.onReplyProxyDestroyed(mId);
} catch (RemoteException e) {
throw new APICallException(e);
}
mClient.onReplyProxyDestroyed(mId);
}
@CalledByNative
private void onPostMessage(String message) {
try {
mClient.onPostMessage(mId, message);
} catch (RemoteException e) {
throw new APICallException(e);
}
private void onPostMessage(String message) throws RemoteException {
mClient.onPostMessage(mId, message);
}
@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