Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/AppWebMessagePortService.java |
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwMessagePortService.java b/content/public/android/java/src/org/chromium/content/browser/AppWebMessagePortService.java |
| similarity index 74% |
| rename from android_webview/java/src/org/chromium/android_webview/AwMessagePortService.java |
| rename to content/public/android/java/src/org/chromium/content/browser/AppWebMessagePortService.java |
| index eec71e1e59ad6d5300647d29aa0e53d6a36c2ef2..4d9026bc4a88b81cdfe3e146508418c996d8fbca 100644 |
| --- a/android_webview/java/src/org/chromium/android_webview/AwMessagePortService.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/AppWebMessagePortService.java |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -package org.chromium.android_webview; |
| +package org.chromium.content.browser; |
| import android.util.SparseArray; |
| @@ -21,20 +21,20 @@ import org.chromium.base.annotations.JNINamespace; |
| * The message ports have unique IDs. In Android webview implementation, |
| * the message ports are only known by their IDs at the native side. |
| * At the java side, the embedder deals with MessagePort objects. The mapping |
| - * from an ID to an object is in AwMessagePortService. AwMessagePortService |
| + * from an ID to an object is in AppWebMessagePortService. AppWebMessagePortService |
| * keeps a strong ref to MessagePort objects until they are closed. |
| * |
| - * Ownership: The Java AwMessagePortService is owned by Java AwBrowserContext. |
| - * The native AwMessagePortService is owned by native AwBrowserContext. The |
| + * Ownership: The Java AppWebMessagePortService is owned by Java AwBrowserContext. |
|
sgurun-gerrit only
2016/09/30 23:40:59
update ownership
Yusuf
2016/10/04 21:33:14
Done.
|
| + * The native AppWebMessagePortService is owned by native AwBrowserContext. The |
| * native peer maintains a weak ref to the java object and deregisters itself |
| * before being deleted. |
| * |
| * All methods are called on UI thread except as noted. |
| */ |
| -@JNINamespace("android_webview") |
| -public class AwMessagePortService { |
| +@JNINamespace("content") |
| +public class AppWebMessagePortService { |
| - private static final String TAG = "AwMessagePortService"; |
| + private static final String TAG = "AppWebMessagePortService"; |
| /** |
| * Observer for MessageChannel events. |
| @@ -45,7 +45,7 @@ public class AwMessagePortService { |
| // A thread safe storage for Message Ports. |
| private static class MessagePortStorage { |
| - private SparseArray<AwMessagePort> mMessagePorts = new SparseArray<AwMessagePort>(); |
| + private SparseArray<AppWebMessagePort> mMessagePorts = new SparseArray<AppWebMessagePort>(); |
| private final Object mLock = new Object(); |
| public void remove(int portId) { |
| @@ -54,12 +54,12 @@ public class AwMessagePortService { |
| } |
| } |
| - public void put(int portId, AwMessagePort m) { |
| + public void put(int portId, AppWebMessagePort m) { |
| synchronized (mLock) { |
| mMessagePorts.put(portId, m); |
| } |
| } |
| - public AwMessagePort get(int portId) { |
| + public AppWebMessagePort get(int portId) { |
| synchronized (mLock) { |
| return mMessagePorts.get(portId); |
| } |
| @@ -71,8 +71,8 @@ public class AwMessagePortService { |
| private ObserverList<MessageChannelObserver> mObserverList = |
| new ObserverList<MessageChannelObserver>(); |
| - AwMessagePortService() { |
| - mNativeMessagePortService = nativeInitAwMessagePortService(); |
| + public AppWebMessagePortService() { |
| + mNativeMessagePortService = nativeInitAppWebMessagePortService(); |
| } |
| public void addObserver(MessageChannelObserver observer) { |
| @@ -102,7 +102,7 @@ public class AwMessagePortService { |
| // verify that webview owns all the ports that are transferred |
| if (sentPorts != null) { |
| for (int port : sentPorts) { |
| - AwMessagePort p = mPortStorage.get(port); |
| + AppWebMessagePort p = mPortStorage.get(port); |
| if (p == null) { |
| throw new IllegalStateException("Cannot transfer unknown port " + port); |
| } |
| @@ -111,8 +111,8 @@ public class AwMessagePortService { |
| } |
| } |
| - public AwMessagePort[] createMessageChannel() { |
| - return new AwMessagePort[]{new AwMessagePort(this), new AwMessagePort(this)}; |
| + public AppWebMessagePort[] createMessageChannel() { |
| + return new AppWebMessagePort[]{new AppWebMessagePort(this), new AppWebMessagePort(this)}; |
| } |
| // Called on UI thread. |
| @@ -121,7 +121,7 @@ public class AwMessagePortService { |
| nativeReleaseMessages(mNativeMessagePortService, portId); |
| } |
| - private AwMessagePort addPort(AwMessagePort m, int portId) { |
| + private AppWebMessagePort addPort(AppWebMessagePort m, int portId) { |
| if (mPortStorage.get(portId) != null) { |
| throw new IllegalStateException("Port already exists"); |
| } |
| @@ -132,7 +132,7 @@ public class AwMessagePortService { |
| @CalledByNative |
| private void onMessageChannelCreated(int portId1, int portId2, |
| - AwMessagePort[] ports) { |
| + AppWebMessagePort[] ports) { |
| ThreadUtils.assertOnUiThread(); |
| addPort(ports[0], portId1); |
| addPort(ports[1], portId2); |
| @@ -144,26 +144,26 @@ public class AwMessagePortService { |
| // Called on IO thread. |
| @CalledByNative |
| private void onReceivedMessage(int portId, String message, int[] ports) { |
| - AwMessagePort[] messagePorts = null; |
| + AppWebMessagePort[] messagePorts = null; |
| for (int i = 0; i < ports.length; i++) { |
| if (messagePorts == null) { |
| - messagePorts = new AwMessagePort[ports.length]; |
| + messagePorts = new AppWebMessagePort[ports.length]; |
| } |
| - messagePorts[i] = addPort(new AwMessagePort(this), ports[i]); |
| + messagePorts[i] = addPort(new AppWebMessagePort(this), ports[i]); |
| } |
| mPortStorage.get(portId).onReceivedMessage(message, messagePorts); |
| } |
| @CalledByNative |
| - private void unregisterNativeAwMessagePortService() { |
| + private void unregisterNativeAppWebMessagePortService() { |
| mNativeMessagePortService = 0; |
| } |
| - private native long nativeInitAwMessagePortService(); |
| - private native void nativePostAppToWebMessage(long nativeAwMessagePortServiceImpl, |
| + private native long nativeInitAppWebMessagePortService(); |
| + private native void nativePostAppToWebMessage(long nativeAppWebMessagePortServiceImpl, |
| int senderId, String message, int[] portIds); |
| - private native void nativeClosePort(long nativeAwMessagePortServiceImpl, |
| + private native void nativeClosePort(long nativeAppWebMessagePortServiceImpl, |
| int messagePortId); |
| - private native void nativeReleaseMessages(long nativeAwMessagePortServiceImpl, |
| + private native void nativeReleaseMessages(long nativeAppWebMessagePortServiceImpl, |
| int messagePortId); |
| } |