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

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

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Add missing ScopedAsyncTaskScheduler instance for the new unit tests; required by a recent change t… 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 b7dc50638047944bc3d5274028ae1d971e4d2ee6..657c9a0f81a816d1ebd2f17a9c966a205fc9847f 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
@@ -19,14 +19,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.SmartClipCallback;
import org.chromium.content_public.browser.WebContents;
@@ -342,17 +341,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
@@ -579,9 +586,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