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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Eliminate unnecessary PostTask Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java b/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
index 5150f32ab82bffca49276be51d3bdd3ef9b9b305..b30d72ff8521d371478ee8aa82220e44298f064a 100644
--- a/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
+++ b/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
@@ -17,14 +17,13 @@ import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.content.browser.AppWebMessagePort;
-import org.chromium.content.browser.AppWebMessagePortService;
import org.chromium.content.browser.MediaSessionImpl;
import org.chromium.content_public.browser.AccessibilitySnapshotCallback;
import org.chromium.content_public.browser.AccessibilitySnapshotNode;
import org.chromium.content_public.browser.ContentBitmapCallback;
import org.chromium.content_public.browser.ImageDownloadCallback;
import org.chromium.content_public.browser.JavaScriptCallback;
-import org.chromium.content_public.browser.MessagePortService;
+import org.chromium.content_public.browser.MessagePort;
import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver;
@@ -337,17 +336,25 @@ import java.util.UUID;
@Override
public void postMessageToFrame(String frameName, String message,
- String sourceOrigin, String targetOrigin, int[] sentPortIds) {
- nativePostMessageToFrame(mNativeWebContentsAndroid, frameName, message,
- sourceOrigin, targetOrigin, sentPortIds);
+ String sourceOrigin, String targetOrigin, MessagePort[] ports) {
+ if (ports != null) {
+ for (MessagePort port : ports) {
+ if (port.isClosed() || port.isTransferred()) {
+ throw new IllegalStateException("Port is already closed or transferred");
+ }
+ if (port.isStarted()) {
+ throw new IllegalStateException("Port is already started");
+ }
+ }
+ }
+ nativePostMessageToFrame(
+ mNativeWebContentsAndroid, frameName, message, sourceOrigin, targetOrigin, ports);
}
@Override
- public AppWebMessagePort[] createMessageChannel(MessagePortService service)
+ public AppWebMessagePort[] createMessageChannel()
throws IllegalStateException {
- AppWebMessagePort[] ports = ((AppWebMessagePortService) service).createMessageChannel();
- nativeCreateMessageChannel(mNativeWebContentsAndroid, ports);
- return ports;
+ return AppWebMessagePort.createPair();
}
@Override
@@ -539,9 +546,7 @@ import java.util.UUID;
private native void nativeAddMessageToDevToolsConsole(
long nativeWebContentsAndroid, int level, String message);
private native void nativePostMessageToFrame(long nativeWebContentsAndroid, String frameName,
- String message, String sourceOrigin, String targetOrigin, int[] sentPortIds);
- private native void nativeCreateMessageChannel(
- long nativeWebContentsAndroid, AppWebMessagePort[] ports);
+ String message, String sourceOrigin, String targetOrigin, MessagePort[] ports);
private native boolean nativeHasAccessedInitialDocument(
long nativeWebContentsAndroid);
private native int nativeGetThemeColor(long nativeWebContentsAndroid);

Powered by Google App Engine
This is Rietveld 408576698