483d6301490012448fe38a3f8a5b374290e15986 - chromium/src

1,168 views
Skip to first unread message

roc...@google.com

unread,
Mar 1, 2022, 6:44:49 PM3/1/22
to chromium...@chromium.org
commit 483d6301490012448fe38a3f8a5b374290e15986
Author: Ken Rockot <roc...@google.com>
AuthorDate: Tue Mar 01 23:43:26 2022
Commit: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
CommitDate: Tue Mar 01 23:43:26 2022

Change MojoHandle to 64 bits

We no longer have need to preserve Mojo Core ABI stability because
consuming Mojo Core as a shared library is no longer supported. This
changes MojoHandle to a 64-bit value in preparation for the
introduction of ipcz -- which itself uses 64-bit handles -- making it
trivial to reuse existing Mojo C++ handle types to wrap Mojo and ipcz
handles alike.

Note that this does not impact the wire format in any way, because
handle values are only for the (process-local) API interface. In
messages, handles are still encoded as 32-bit indices to some
object metadata within the message.

Bug: 1299283
Change-Id: I8d465e78878971aab243404e6491596d6357d632
Binary-Size: This intentionally increases the size of a widely used data type from 32 bits to 64 bits, a change which is required to support other improvements. The 110 kB binary size increase is a direct result of that, and it does not seem to be avoidable.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3493659
Reviewed-by: Bo Liu <bo...@chromium.org>
Reviewed-by: Daniel Cheng <dch...@chromium.org>
Commit-Queue: Ken Rockot <roc...@google.com>
Cr-Commit-Position: refs/heads/main@{#976468}

diff --git a/content/browser/android/dialog_overlay_impl.cc b/content/browser/android/dialog_overlay_impl.cc
index cc95bd5..eed4297 100644
--- a/content/browser/android/dialog_overlay_impl.cc
+++ b/content/browser/android/dialog_overlay_impl.cc
@@ -305,7 +305,7 @@

static void JNI_DialogOverlayImpl_NotifyDestroyedSynchronously(
JNIEnv* env,
- int message_pipe_handle) {
+ jlong message_pipe_handle) {
mojo::MessagePipeHandle handle(message_pipe_handle);
mojo::ScopedMessagePipeHandle scoped_handle(handle);
mojo::Remote<media::mojom::AndroidOverlayClient> remote(
diff --git a/content/browser/android/message_port_descriptor.cc b/content/browser/android/message_port_descriptor.cc
index c2875fb0..d904d01d 100644
--- a/content/browser/android/message_port_descriptor.cc
+++ b/content/browser/android/message_port_descriptor.cc
@@ -19,7 +19,7 @@

namespace {

-mojo::ScopedMessagePipeHandle WrapNativeHandle(jint native_handle) {
+mojo::ScopedMessagePipeHandle WrapNativeHandle(jlong native_handle) {
MojoHandle raw_handle = static_cast<MojoHandle>(native_handle);
DCHECK_NE(MOJO_HANDLE_INVALID, raw_handle);
return mojo::ScopedMessagePipeHandle(mojo::MessagePipeHandle(raw_handle));
@@ -45,7 +45,7 @@
}

JNI_EXPORT jlong JNI_AppWebMessagePortDescriptor_Create(JNIEnv* env,
- jint native_handle,
+ jlong native_handle,
jlong id_low,
jlong id_high,
jlong sequence_number) {
@@ -61,7 +61,7 @@
return reinterpret_cast<jlong>(port);
}

-JNI_EXPORT jint JNI_AppWebMessagePortDescriptor_TakeHandleToEntangle(
+JNI_EXPORT jlong JNI_AppWebMessagePortDescriptor_TakeHandleToEntangle(
JNIEnv* env,
jlong native_message_port_decriptor) {
blink::MessagePortDescriptor* message_port_descriptor =
@@ -82,7 +82,7 @@
JNI_EXPORT void JNI_AppWebMessagePortDescriptor_GiveDisentangledHandle(
JNIEnv* env,
jlong native_message_port_decriptor,
- jint native_handle) {
+ jlong native_handle) {
blink::MessagePortDescriptor* message_port_descriptor =
reinterpret_cast<blink::MessagePortDescriptor*>(
native_message_port_decriptor);
diff --git a/content/browser/renderer_host/render_frame_host_android.cc b/content/browser/renderer_host/render_frame_host_android.cc
index 8d76d04..f5830d7 100644
--- a/content/browser/renderer_host/render_frame_host_android.cc
+++ b/content/browser/renderer_host/render_frame_host_android.cc
@@ -183,7 +183,7 @@
JNIEnv* env,
const base::android::JavaParamRef<jobject>&,
const base::android::JavaParamRef<jstring>& interface_name,
- jint message_pipe_raw_handle) const {
+ jlong message_pipe_raw_handle) const {
DCHECK(render_frame_host_->IsRenderFrameCreated());
render_frame_host_->GetRemoteInterfaces()->GetInterfaceByName(
ConvertJavaStringToUTF8(env, interface_name),
diff --git a/content/browser/renderer_host/render_frame_host_android.h b/content/browser/renderer_host/render_frame_host_android.h
index f4f1525..55412020 100644
--- a/content/browser/renderer_host/render_frame_host_android.h
+++ b/content/browser/renderer_host/render_frame_host_android.h
@@ -73,7 +73,7 @@
JNIEnv* env,
const base::android::JavaParamRef<jobject>&,
const base::android::JavaParamRef<jstring>& interface_name,
- jint message_pipe_handle) const;
+ jlong message_pipe_handle) const;

void TerminateRendererDueToBadMessage(
JNIEnv* env,
diff --git a/content/public/android/java/src/org/chromium/content/browser/AppWebMessagePortDescriptor.java b/content/public/android/java/src/org/chromium/content/browser/AppWebMessagePortDescriptor.java
index a17e872b..f6cf377 100644
--- a/content/public/android/java/src/org/chromium/content/browser/AppWebMessagePortDescriptor.java
+++ b/content/public/android/java/src/org/chromium/content/browser/AppWebMessagePortDescriptor.java
@@ -45,7 +45,7 @@
*/
public class AppWebMessagePortDescriptor implements ConnectionErrorHandler {
private static final long NATIVE_NULL = 0;
- private static final int INVALID_NATIVE_MOJO_HANDLE = 0; // Mirrors CoreImpl.INVALID_HANDLE.
+ private static final long INVALID_NATIVE_MOJO_HANDLE = 0; // Mirrors CoreImpl.INVALID_HANDLE.
private static final long INVALID_SEQUENCE_NUMBER = 0;

/** Handle to the native blink::MessagePortDescriptor associated with this object. */
@@ -111,7 +111,7 @@
Connector entangleWithConnector() {
ensureNativeMessagePortDescriptorExists();
assert mConnector == null : "handle already taken";
- int nativeHandle = AppWebMessagePortDescriptorJni.get().takeHandleToEntangle(
+ long nativeHandle = AppWebMessagePortDescriptorJni.get().takeHandleToEntangle(
mNativeMessagePortDescriptor);
assert nativeHandle
!= INVALID_NATIVE_MOJO_HANDLE : "native object returned an invalid handle";
@@ -177,7 +177,7 @@
AppWebMessagePortDescriptorJni.get().passSerialized(mNativeMessagePortDescriptor);
assert serialized.length == 4 : "native passSerialized returned an invalid value";

- int nativeHandle = (int) serialized[0];
+ long nativeHandle = serialized[0];
long idLow = serialized[1];
long idHigh = serialized[2];
long sequenceNumber = serialized[3];
@@ -254,7 +254,7 @@
/**
* Wraps the provided native handle as MessagePipeHandle.
*/
- MessagePipeHandle wrapNativeHandle(int nativeHandle) {
+ MessagePipeHandle wrapNativeHandle(long nativeHandle) {
return CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessagePipeHandle();
}

@@ -282,7 +282,7 @@

private void disentangleImpl() {
MessagePipeHandle handle = mConnector.passHandle();
- int nativeHandle = handle.releaseNativeHandle();
+ long nativeHandle = handle.releaseNativeHandle();
// An invalid handle should be returned iff the connection errored.
if (mConnectorErrored) {
assert nativeHandle
@@ -324,14 +324,14 @@
@NativeMethods
interface Native {
long[] createPair();
- long create(int nativeHandle, long idLow, long idHigh, long sequenceNumber);
+ long create(long mojoHandle, long idLow, long idHigh, long sequenceNumber);
// Deliberately do not use nativeObjectType naming to avoid automatic typecasting and
// member function dispatch; these need to be routed to static functions.

// Takes the handle from the native object for entangling with a mojo.Connector.
- int takeHandleToEntangle(long blinkMessagePortDescriptor);
+ long takeHandleToEntangle(long blinkMessagePortDescriptor);
// Returns the handle previously taken via "takeHandleToEntangle".
- void giveDisentangledHandle(long blinkMessagePortDescriptor, int nativeHandle);
+ void giveDisentangledHandle(long blinkMessagePortDescriptor, long nativeHandle);
// Indicates that the entangled error experienced a connection error. The descriptor must be
// entangled at this point.
void onConnectionError(long blinkMessagePortDescriptor);
diff --git a/content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrarImpl.java b/content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrarImpl.java
index 97330d87..1c857b8 100644
--- a/content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrarImpl.java
+++ b/content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrarImpl.java
@@ -23,7 +23,7 @@
private static boolean sHasRegisteredRegistrars;

@CalledByNative
- static void createInterfaceRegistry(int nativeHandle) {
+ static void createInterfaceRegistry(long nativeHandle) {
ensureSingletonRegistrarsAreRegistered();

InterfaceRegistry registry = InterfaceRegistry.create(
@@ -32,14 +32,14 @@
}

@CalledByNative
- static void createInterfaceRegistryOnIOThread(int nativeHandle) {
+ static void createInterfaceRegistryOnIOThread(long nativeHandle) {
InterfaceRegistry registry = InterfaceRegistry.create(
CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessagePipeHandle());
registerInterfacesOnIOThread(registry);
}

@CalledByNative
- static void createInterfaceRegistryForWebContents(int nativeHandle, WebContents webContents) {
+ static void createInterfaceRegistryForWebContents(long nativeHandle, WebContents webContents) {
ensureSingletonRegistrarsAreRegistered();

InterfaceRegistry registry = InterfaceRegistry.create(
@@ -49,7 +49,7 @@

@CalledByNative
static void createInterfaceRegistryForRenderFrameHost(
- int nativeHandle, RenderFrameHost renderFrameHost) {
+ long nativeHandle, RenderFrameHost renderFrameHost) {
ensureSingletonRegistrarsAreRegistered();

InterfaceRegistry registry = InterfaceRegistry.create(
diff --git a/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayImpl.java b/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayImpl.java
index be59677..4cc64b1 100644
--- a/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayImpl.java
+++ b/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayImpl.java
@@ -297,7 +297,7 @@
// removed once Android O is no longer supported.
final AndroidOverlayClient.Proxy proxy = (AndroidOverlayClient.Proxy) client;
final MessagePipeHandle handle = proxy.getProxyHandler().passHandle();
- final int nativeHandle = handle.releaseNativeHandle();
+ final long nativeHandle = handle.releaseNativeHandle();
DialogOverlayImplJni.get().notifyDestroyedSynchronously(nativeHandle);
}

@@ -360,6 +360,6 @@
* @param version Mojo interface version.
* @return none, but the message pipe is closed.
*/
- void notifyDestroyedSynchronously(int messagePipeHandle);
+ void notifyDestroyedSynchronously(long messagePipeHandle);
}
}
diff --git a/content/public/android/java/src/org/chromium/content/browser/framehost/RenderFrameHostImpl.java b/content/public/android/java/src/org/chromium/content/browser/framehost/RenderFrameHostImpl.java
index 8d2d036..869a576 100644
--- a/content/public/android/java/src/org/chromium/content/browser/framehost/RenderFrameHostImpl.java
+++ b/content/public/android/java/src/org/chromium/content/browser/framehost/RenderFrameHostImpl.java
@@ -246,7 +246,7 @@
long nativeRenderFrameHostAndroid, RenderFrameHostImpl caller);
boolean isRenderFrameCreated(long nativeRenderFrameHostAndroid, RenderFrameHostImpl caller);
void getInterfaceToRendererFrame(long nativeRenderFrameHostAndroid,
- RenderFrameHostImpl caller, String interfacename, int messagePipeRawHandle);
+ RenderFrameHostImpl caller, String interfacename, long messagePipeRawHandle);
void terminateRendererDueToBadMessage(
long nativeRenderFrameHostAndroid, RenderFrameHostImpl caller, int reason);
boolean isProcessBlocked(long nativeRenderFrameHostAndroid, RenderFrameHostImpl caller);
diff --git a/mojo/core/handle_table.cc b/mojo/core/handle_table.cc
index a044f1c8..1befb91 100644
--- a/mojo/core/handle_table.cc
+++ b/mojo/core/handle_table.cc
@@ -73,8 +73,8 @@
DCHECK_GE(next_available_handle_, 1u);

// If this insertion would cause handle overflow, we're out of handles.
- const uint32_t num_handles_available =
- std::numeric_limits<uint32_t>::max() - next_available_handle_ + 1;
+ const uint64_t num_handles_available =
+ std::numeric_limits<uint64_t>::max() - next_available_handle_ + 1;
if (num_handles_available < dispatchers.size()) {
return false;
}
diff --git a/mojo/core/handle_table.h b/mojo/core/handle_table.h
index 6718b6f..c79b2a14 100644
--- a/mojo/core/handle_table.h
+++ b/mojo/core/handle_table.h
@@ -82,7 +82,7 @@
HandleMap handles_;
base::Lock lock_;

- uint32_t next_available_handle_ = 1;
+ uint64_t next_available_handle_ = 1;
};

} // namespace core
diff --git a/mojo/public/c/system/types.h b/mojo/public/c/system/types.h
index 56ffd78..0e1d16a 100644
--- a/mojo/public/c/system/types.h
+++ b/mojo/public/c/system/types.h
@@ -22,7 +22,7 @@
// |MojoHandle|: Handles to Mojo objects.
// |MOJO_HANDLE_INVALID| - A value that is never a valid handle.

-typedef uint32_t MojoHandle;
+typedef uint64_t MojoHandle;

#ifdef __cplusplus
const MojoHandle MOJO_HANDLE_INVALID = 0;
diff --git a/mojo/public/java/system/core_impl.cc b/mojo/public/java/system/core_impl.cc
index 0e00fbb..203323f 100644
--- a/mojo/public/java/system/core_impl.cc
+++ b/mojo/public/java/system/core_impl.cc
@@ -82,19 +82,19 @@
}
MojoHandle handle;
MojoResult result = MojoCreateSharedBuffer(num_bytes, options, &handle);
- return Java_CoreImpl_newResultAndInteger(env, result, handle);
+ return Java_CoreImpl_newResultAndLong(env, result, handle);
}

static jint JNI_CoreImpl_Close(JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle) {
+ jlong mojo_handle) {
return MojoClose(mojo_handle);
}

static jint JNI_CoreImpl_QueryHandleSignalsState(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
const JavaParamRef<jobject>& buffer) {
MojoHandleSignalsState* signals_state =
static_cast<MojoHandleSignalsState*>(env->GetDirectBufferAddress(buffer));
@@ -107,7 +107,7 @@
static jint JNI_CoreImpl_WriteMessage(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
const JavaParamRef<jobject>& bytes,
jint num_bytes,
const JavaParamRef<jobject>& handles_buffer,
@@ -125,7 +125,8 @@
if (handles_buffer) {
handles =
static_cast<MojoHandle*>(env->GetDirectBufferAddress(handles_buffer));
- num_handles = env->GetDirectBufferCapacity(handles_buffer) / 4;
+ num_handles =
+ env->GetDirectBufferCapacity(handles_buffer) / sizeof(MojoHandle);
}
// Java code will handle invalidating handles if the write succeeded.
return WriteMessageRaw(
@@ -136,7 +137,7 @@
static ScopedJavaLocalRef<jobject> JNI_CoreImpl_ReadMessage(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
jint flags) {
ScopedMessageHandle message;
MojoResult result =
@@ -170,14 +171,14 @@
env, result,
base::android::ToJavaByteArray(env, static_cast<uint8_t*>(buffer),
num_bytes),
- base::android::ToJavaIntArray(
- env, reinterpret_cast<jint*>(handles.data()), num_handles));
+ base::android::ToJavaLongArray(
+ env, reinterpret_cast<jlong*>(handles.data()), num_handles));
}

static ScopedJavaLocalRef<jobject> JNI_CoreImpl_ReadData(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
const JavaParamRef<jobject>& elements,
jint elements_capacity,
jint flags) {
@@ -200,7 +201,7 @@
static ScopedJavaLocalRef<jobject> JNI_CoreImpl_BeginReadData(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
jint num_bytes,
jint flags) {
void const* buffer = 0;
@@ -223,7 +224,7 @@

static jint JNI_CoreImpl_EndReadData(JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
jint num_bytes_read) {
return MojoEndReadData(mojo_handle, num_bytes_read, nullptr);
}
@@ -231,7 +232,7 @@
static ScopedJavaLocalRef<jobject> JNI_CoreImpl_WriteData(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
const JavaParamRef<jobject>& elements,
jint limit,
jint flags) {
@@ -252,7 +253,7 @@
static ScopedJavaLocalRef<jobject> JNI_CoreImpl_BeginWriteData(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
jint num_bytes,
jint flags) {
void* buffer = 0;
@@ -274,7 +275,7 @@

static jint JNI_CoreImpl_EndWriteData(JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
jint num_bytes_written) {
return MojoEndWriteData(mojo_handle, num_bytes_written, nullptr);
}
@@ -282,7 +283,7 @@
static ScopedJavaLocalRef<jobject> JNI_CoreImpl_Duplicate(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
const JavaParamRef<jobject>& options_buffer) {
const MojoDuplicateBufferHandleOptions* options = 0;
if (options_buffer) {
@@ -296,13 +297,13 @@
}
MojoHandle handle;
MojoResult result = MojoDuplicateBufferHandle(mojo_handle, options, &handle);
- return Java_CoreImpl_newResultAndInteger(env, result, handle);
+ return Java_CoreImpl_newResultAndLong(env, result, handle);
}

static ScopedJavaLocalRef<jobject> JNI_CoreImpl_Map(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
jlong offset,
jlong num_bytes,
jint flags) {
@@ -343,7 +344,7 @@
return alignment - offset;
}

-static jint JNI_CoreImpl_CreatePlatformHandle(JNIEnv* env, jint fd) {
+static jlong JNI_CoreImpl_CreatePlatformHandle(JNIEnv* env, jint fd) {
mojo::ScopedHandle handle =
mojo::WrapPlatformHandle(mojo::PlatformHandle(base::ScopedFD(fd)));
return handle.release().value();
diff --git a/mojo/public/java/system/javatests/src/org/chromium/mojo/HandleMock.java b/mojo/public/java/system/javatests/src/org/chromium/mojo/HandleMock.java
index 715e1e54..c0e48abc 100644
--- a/mojo/public/java/system/javatests/src/org/chromium/mojo/HandleMock.java
+++ b/mojo/public/java/system/javatests/src/org/chromium/mojo/HandleMock.java
@@ -77,7 +77,7 @@
* @see Handle#releaseNativeHandle()
*/
@Override
- public int releaseNativeHandle() {
+ public long releaseNativeHandle() {
return 0;
}

diff --git a/mojo/public/java/system/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java b/mojo/public/java/system/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java
index 762da41..6120083 100644
--- a/mojo/public/java/system/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java
+++ b/mojo/public/java/system/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java
@@ -119,7 +119,7 @@
}

{
- int expectedHandle = 42;
+ long expectedHandle = 42;
MultiVersionStructV7 v7 = new MultiVersionStructV7();
v7.fInt32 = 123;
v7.fRect = newRect(5);
@@ -198,7 +198,7 @@
}

{
- int expectedHandle = 42;
+ long expectedHandle = 42;
MultiVersionStructV7 expected = new MultiVersionStructV7();
expected.fInt32 = 123;
expected.fRect = newRect(5);
diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/Core.java b/mojo/public/java/system/src/org/chromium/mojo/system/Core.java
index 7b5684b..f059ef3 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/Core.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/Core.java
@@ -166,7 +166,7 @@
*
* @return a new {@link UntypedHandle} representing the native handle.
*/
- public UntypedHandle acquireNativeHandle(int handle);
+ public UntypedHandle acquireNativeHandle(long handle);

/**
* Creates and acquires a handle from the native side. The handle will be owned by the returned
diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/Handle.java b/mojo/public/java/system/src/org/chromium/mojo/system/Handle.java
index 903f36d..558ba5c 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/Handle.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/Handle.java
@@ -56,6 +56,5 @@
* Releases the native handle backed by this {@link Handle}. The caller owns the handle and must
* close it.
*/
- public int releaseNativeHandle();
-
+ public long releaseNativeHandle();
}
diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/InvalidHandle.java b/mojo/public/java/system/src/org/chromium/mojo/system/InvalidHandle.java
index 5292605..2ea4397 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/InvalidHandle.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/InvalidHandle.java
@@ -80,7 +80,7 @@
* @see Handle#releaseNativeHandle()
*/
@Override
- public int releaseNativeHandle() {
+ public long releaseNativeHandle() {
return 0;
}

diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/MessagePipeHandle.java b/mojo/public/java/system/src/org/chromium/mojo/system/MessagePipeHandle.java
index baa5a95..f151cf2 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/MessagePipeHandle.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/MessagePipeHandle.java
@@ -125,7 +125,7 @@
/**
* If a message was read, this contains the raw handle values.
*/
- public int[] mRawHandles;
+ public long[] mRawHandles;
/**
* If a message was read, the handles contained in the message, undefined otherwise.
*/
diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/impl/CoreImpl.java b/mojo/public/java/system/src/org/chromium/mojo/system/impl/CoreImpl.java
index 757636a..42f79ac 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/impl/CoreImpl.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/impl/CoreImpl.java
@@ -47,7 +47,7 @@
/**
* the size of a handle, in bytes.
*/
- private static final int HANDLE_SIZE = 4;
+ private static final int HANDLE_SIZE = 8;

/**
* the size of a flag, in bytes.
@@ -57,7 +57,7 @@
/**
* The mojo handle for an invalid handle.
*/
- static final int INVALID_HANDLE = 0;
+ static final long INVALID_HANDLE = 0;

private static class LazyHolder { private static final Core INSTANCE = new CoreImpl(); }

@@ -106,7 +106,7 @@
optionsBuffer.putInt(0, 8);
optionsBuffer.putInt(4, options.getFlags().getFlags());
}
- ResultAnd<IntegerPair> result =
+ ResultAnd<RawHandlePair> result =
CoreImplJni.get().createMessagePipe(CoreImpl.this, optionsBuffer);
if (result.getMojoResult() != MojoResult.OK) {
throw new MojoException(result.getMojoResult());
@@ -129,7 +129,7 @@
optionsBuffer.putInt(8, options.getElementNumBytes());
optionsBuffer.putInt(12, options.getCapacityNumBytes());
}
- ResultAnd<IntegerPair> result =
+ ResultAnd<RawHandlePair> result =
CoreImplJni.get().createDataPipe(CoreImpl.this, optionsBuffer);
if (result.getMojoResult() != MojoResult.OK) {
throw new MojoException(result.getMojoResult());
@@ -151,7 +151,7 @@
optionsBuffer.putInt(0, 8);
optionsBuffer.putInt(4, options.getFlags().getFlags());
}
- ResultAnd<Integer> result =
+ ResultAnd<Long> result =
CoreImplJni.get().createSharedBuffer(CoreImpl.this, optionsBuffer, numBytes);
if (result.getMojoResult() != MojoResult.OK) {
throw new MojoException(result.getMojoResult());
@@ -160,10 +160,10 @@
}

/**
- * @see org.chromium.mojo.system.Core#acquireNativeHandle(int)
+ * @see org.chromium.mojo.system.Core#acquireNativeHandle(long)
*/
@Override
- public UntypedHandle acquireNativeHandle(int handle) {
+ public UntypedHandle acquireNativeHandle(long handle) {
return new UntypedHandleImpl(this, handle);
}

@@ -172,7 +172,7 @@
*/
@Override
public UntypedHandle wrapFileDescriptor(ParcelFileDescriptor fd) {
- int releasedHandle = CoreImplJni.get().createPlatformHandle(fd.detachFd());
+ long releasedHandle = CoreImplJni.get().createPlatformHandle(fd.detachFd());
return acquireNativeHandle(releasedHandle);
}

@@ -212,18 +212,18 @@
mCurrentRunLoop.remove();
}

- int closeWithResult(int mojoHandle) {
+ int closeWithResult(long mojoHandle) {
return CoreImplJni.get().close(CoreImpl.this, mojoHandle);
}

- void close(int mojoHandle) {
+ void close(long mojoHandle) {
int mojoResult = CoreImplJni.get().close(CoreImpl.this, mojoHandle);
if (mojoResult != MojoResult.OK) {
throw new MojoException(mojoResult);
}
}

- HandleSignalsState queryHandleSignalsState(int mojoHandle) {
+ HandleSignalsState queryHandleSignalsState(long mojoHandle) {
ByteBuffer buffer = allocateDirectBuffer(8);
int result = CoreImplJni.get().queryHandleSignalsState(CoreImpl.this, mojoHandle, buffer);
if (result != MojoResult.OK) throw new MojoException(result);
@@ -240,7 +240,7 @@
if (handles != null && !handles.isEmpty()) {
handlesBuffer = allocateDirectBuffer(handles.size() * HANDLE_SIZE);
for (Handle handle : handles) {
- handlesBuffer.putInt(getMojoHandle(handle));
+ handlesBuffer.putLong(getMojoHandle(handle));
}
handlesBuffer.position(0);
}
@@ -272,10 +272,10 @@
}

MessagePipeHandle.ReadMessageResult readResult = result.getValue();
- int[] rawHandles = readResult.mRawHandles;
+ long[] rawHandles = readResult.mRawHandles;
if (rawHandles != null && rawHandles.length != 0) {
readResult.mHandles = new ArrayList<UntypedHandle>(rawHandles.length);
- for (int rawHandle : rawHandles) {
+ for (long rawHandle : rawHandles) {
readResult.mHandles.add(new UntypedHandleImpl(this, rawHandle));
}
} else {
@@ -385,7 +385,7 @@
optionsBuffer.putInt(0, 8);
optionsBuffer.putInt(4, options.getFlags().getFlags());
}
- ResultAnd<Integer> result =
+ ResultAnd<Long> result =
CoreImplJni.get().duplicate(CoreImpl.this, handle.getMojoHandle(), optionsBuffer);
if (result.getMojoResult() != MojoResult.OK) {
throw new MojoException(result.getMojoResult());
@@ -418,7 +418,7 @@
/**
* @return the mojo handle associated to the given handle, considering invalid handles.
*/
- private int getMojoHandle(Handle handle) {
+ private long getMojoHandle(Handle handle) {
if (handle.isValid()) {
return ((HandleBase) handle).getMojoHandle();
}
@@ -459,18 +459,18 @@
}

/**
- * Trivial alias for Pair<Integer, Integer>. This is needed because our jni generator is unable
+ * Trivial alias for Pair<Long, Long>. This is needed because our jni generator is unable
* to handle class that contains space.
*/
- static final class IntegerPair extends Pair<Integer, Integer> {
- public IntegerPair(Integer first, Integer second) {
+ static final class RawHandlePair extends Pair<Long, Long> {
+ public RawHandlePair(Long first, Long second) {
super(first, second);
}
}

@CalledByNative
private static ResultAnd<MessagePipeHandle.ReadMessageResult> newReadMessageResult(
- int mojoResult, byte[] data, int[] rawHandles) {
+ int mojoResult, byte[] data, long[] rawHandles) {
MessagePipeHandle.ReadMessageResult result = new MessagePipeHandle.ReadMessageResult();
if (mojoResult == MojoResult.OK) {
result.mData = data;
@@ -485,39 +485,45 @@
}

@CalledByNative
- private static ResultAnd<IntegerPair> newNativeCreationResult(
- int mojoResult, int mojoHandle1, int mojoHandle2) {
- return new ResultAnd<>(mojoResult, new IntegerPair(mojoHandle1, mojoHandle2));
+ private static ResultAnd<Long> newResultAndLong(int mojoResult, long value) {
+ return new ResultAnd<>(mojoResult, value);
+ }
+
+ @CalledByNative
+ private static ResultAnd<RawHandlePair> newNativeCreationResult(
+ int mojoResult, long mojoHandle1, long mojoHandle2) {
+ return new ResultAnd<>(mojoResult, new RawHandlePair(mojoHandle1, mojoHandle2));
}

@NativeMethods
interface Natives {
long getTimeTicksNow(CoreImpl caller);
- ResultAnd<IntegerPair> createMessagePipe(CoreImpl caller, ByteBuffer optionsBuffer);
- ResultAnd<IntegerPair> createDataPipe(CoreImpl caller, ByteBuffer optionsBuffer);
- ResultAnd<Integer> createSharedBuffer(
+ ResultAnd<RawHandlePair> createMessagePipe(CoreImpl caller, ByteBuffer optionsBuffer);
+ ResultAnd<RawHandlePair> createDataPipe(CoreImpl caller, ByteBuffer optionsBuffer);
+ ResultAnd<Long> createSharedBuffer(
CoreImpl caller, ByteBuffer optionsBuffer, long numBytes);
- int close(CoreImpl caller, int mojoHandle);
- int queryHandleSignalsState(CoreImpl caller, int mojoHandle, ByteBuffer signalsStateBuffer);
- int writeMessage(CoreImpl caller, int mojoHandle, ByteBuffer bytes, int numBytes,
+ int close(CoreImpl caller, long mojoHandle);
+ int queryHandleSignalsState(
+ CoreImpl caller, long mojoHandle, ByteBuffer signalsStateBuffer);
+ int writeMessage(CoreImpl caller, long mojoHandle, ByteBuffer bytes, int numBytes,
ByteBuffer handlesBuffer, int flags);
ResultAnd<MessagePipeHandle.ReadMessageResult> readMessage(
- CoreImpl caller, int mojoHandle, int flags);
+ CoreImpl caller, long mojoHandle, int flags);
ResultAnd<Integer> readData(
- CoreImpl caller, int mojoHandle, ByteBuffer elements, int elementsSize, int flags);
+ CoreImpl caller, long mojoHandle, ByteBuffer elements, int elementsSize, int flags);
ResultAnd<ByteBuffer> beginReadData(
- CoreImpl caller, int mojoHandle, int numBytes, int flags);
- int endReadData(CoreImpl caller, int mojoHandle, int numBytesRead);
+ CoreImpl caller, long mojoHandle, int numBytes, int flags);
+ int endReadData(CoreImpl caller, long mojoHandle, int numBytesRead);
ResultAnd<Integer> writeData(
- CoreImpl caller, int mojoHandle, ByteBuffer elements, int limit, int flags);
+ CoreImpl caller, long mojoHandle, ByteBuffer elements, int limit, int flags);
ResultAnd<ByteBuffer> beginWriteData(
- CoreImpl caller, int mojoHandle, int numBytes, int flags);
- int endWriteData(CoreImpl caller, int mojoHandle, int numBytesWritten);
- ResultAnd<Integer> duplicate(CoreImpl caller, int mojoHandle, ByteBuffer optionsBuffer);
+ CoreImpl caller, long mojoHandle, int numBytes, int flags);
+ int endWriteData(CoreImpl caller, long mojoHandle, int numBytesWritten);
+ ResultAnd<Long> duplicate(CoreImpl caller, long mojoHandle, ByteBuffer optionsBuffer);
ResultAnd<ByteBuffer> map(
- CoreImpl caller, int mojoHandle, long offset, long numBytes, int flags);
+ CoreImpl caller, long mojoHandle, long offset, long numBytes, int flags);
int unmap(CoreImpl caller, ByteBuffer buffer);
int getNativeBufferOffset(CoreImpl caller, ByteBuffer buffer, int alignment);
- int createPlatformHandle(int fd);
+ long createPlatformHandle(int fd);
}
}
diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/impl/DataPipeConsumerHandleImpl.java b/mojo/public/java/system/src/org/chromium/mojo/system/impl/DataPipeConsumerHandleImpl.java
index 820a6f9..587c14bb 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/impl/DataPipeConsumerHandleImpl.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/impl/DataPipeConsumerHandleImpl.java
@@ -15,9 +15,9 @@
*/
class DataPipeConsumerHandleImpl extends HandleBase implements ConsumerHandle {
/**
- * @see HandleBase#HandleBase(CoreImpl, int)
+ * @see HandleBase#HandleBase(CoreImpl, long)
*/
- DataPipeConsumerHandleImpl(CoreImpl core, int mojoHandle) {
+ DataPipeConsumerHandleImpl(CoreImpl core, long mojoHandle) {
super(core, mojoHandle);
}

diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/impl/DataPipeProducerHandleImpl.java b/mojo/public/java/system/src/org/chromium/mojo/system/impl/DataPipeProducerHandleImpl.java
index cf4eebe..28d7a89 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/impl/DataPipeProducerHandleImpl.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/impl/DataPipeProducerHandleImpl.java
@@ -15,9 +15,9 @@
*/
class DataPipeProducerHandleImpl extends HandleBase implements ProducerHandle {
/**
- * @see HandleBase#HandleBase(CoreImpl, int)
+ * @see HandleBase#HandleBase(CoreImpl, long)
*/
- DataPipeProducerHandleImpl(CoreImpl core, int mojoHandle) {
+ DataPipeProducerHandleImpl(CoreImpl core, long mojoHandle) {
super(core, mojoHandle);
}

diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/impl/HandleBase.java b/mojo/public/java/system/src/org/chromium/mojo/system/impl/HandleBase.java
index 9b7f5de..5e7f787 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/impl/HandleBase.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/impl/HandleBase.java
@@ -19,7 +19,7 @@
/**
* The pointer to the scoped handle owned by this object.
*/
- private int mMojoHandle;
+ private long mMojoHandle;

/**
* The core implementation. Will be used to delegate all behavior.
@@ -29,7 +29,7 @@
/**
* Base constructor. Takes ownership of the passed handle.
*/
- HandleBase(CoreImpl core, int mojoHandle) {
+ HandleBase(CoreImpl core, long mojoHandle) {
mCore = core;
mMojoHandle = mojoHandle;
}
@@ -41,7 +41,7 @@
protected HandleBase(HandleBase other) {
mCore = other.mCore;
HandleBase otherAsHandleImpl = other;
- int mojoHandle = otherAsHandleImpl.mMojoHandle;
+ long mojoHandle = otherAsHandleImpl.mMojoHandle;
otherAsHandleImpl.mMojoHandle = CoreImpl.INVALID_HANDLE;
mMojoHandle = mojoHandle;
}
@@ -53,7 +53,7 @@
public void close() {
if (mMojoHandle != CoreImpl.INVALID_HANDLE) {
// After a close, the handle is invalid whether the close succeed or not.
- int handle = mMojoHandle;
+ long handle = mMojoHandle;
mMojoHandle = CoreImpl.INVALID_HANDLE;
mCore.close(handle);
}
@@ -95,8 +95,8 @@
* @see Handle#releaseNativeHandle()
*/
@Override
- public int releaseNativeHandle() {
- int result = mMojoHandle;
+ public long releaseNativeHandle() {
+ long result = mMojoHandle;
mMojoHandle = CoreImpl.INVALID_HANDLE;
return result;
}
@@ -106,7 +106,7 @@
*
* @return the native scoped handle.
*/
- int getMojoHandle() {
+ long getMojoHandle() {
return mMojoHandle;
}

diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/impl/MessagePipeHandleImpl.java b/mojo/public/java/system/src/org/chromium/mojo/system/impl/MessagePipeHandleImpl.java
index a2dd75d..db6a5b3 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/impl/MessagePipeHandleImpl.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/impl/MessagePipeHandleImpl.java
@@ -16,9 +16,9 @@
*/
class MessagePipeHandleImpl extends HandleBase implements MessagePipeHandle {
/**
- * @see HandleBase#HandleBase(CoreImpl, int)
+ * @see HandleBase#HandleBase(CoreImpl, long)
*/
- MessagePipeHandleImpl(CoreImpl core, int mojoHandle) {
+ MessagePipeHandleImpl(CoreImpl core, long mojoHandle) {
super(core, mojoHandle);
}

diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/impl/SharedBufferHandleImpl.java b/mojo/public/java/system/src/org/chromium/mojo/system/impl/SharedBufferHandleImpl.java
index cd28a48..560ed6ce 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/impl/SharedBufferHandleImpl.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/impl/SharedBufferHandleImpl.java
@@ -13,9 +13,9 @@
*/
class SharedBufferHandleImpl extends HandleBase implements SharedBufferHandle {
/**
- * @see HandleBase#HandleBase(CoreImpl, int)
+ * @see HandleBase#HandleBase(CoreImpl, long)
*/
- SharedBufferHandleImpl(CoreImpl core, int mojoHandle) {
+ SharedBufferHandleImpl(CoreImpl core, long mojoHandle) {
super(core, mojoHandle);
}

diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/impl/UntypedHandleImpl.java b/mojo/public/java/system/src/org/chromium/mojo/system/impl/UntypedHandleImpl.java
index e365abf..8ddf784 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/impl/UntypedHandleImpl.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/impl/UntypedHandleImpl.java
@@ -15,9 +15,9 @@
*/
class UntypedHandleImpl extends HandleBase implements UntypedHandle {
/**
- * @see HandleBase#HandleBase(CoreImpl, int)
+ * @see HandleBase#HandleBase(CoreImpl, long)
*/
- UntypedHandleImpl(CoreImpl core, int mojoHandle) {
+ UntypedHandleImpl(CoreImpl core, long mojoHandle) {
super(core, mojoHandle);
}

diff --git a/mojo/public/java/system/src/org/chromium/mojo/system/impl/WatcherImpl.java b/mojo/public/java/system/src/org/chromium/mojo/system/impl/WatcherImpl.java
index ed4d760..8aec8844 100644
--- a/mojo/public/java/system/src/org/chromium/mojo/system/impl/WatcherImpl.java
+++ b/mojo/public/java/system/src/org/chromium/mojo/system/impl/WatcherImpl.java
@@ -59,7 +59,7 @@
@NativeMethods
interface Natives {
long createWatcher(WatcherImpl caller);
- int start(WatcherImpl caller, long implPtr, int mojoHandle, int flags);
+ int start(WatcherImpl caller, long implPtr, long mojoHandle, int flags);
void cancel(WatcherImpl caller, long implPtr);
void delete(WatcherImpl caller, long implPtr);
}
diff --git a/mojo/public/java/system/watcher_impl.cc b/mojo/public/java/system/watcher_impl.cc
index 065677f..eb2c9ce 100644
--- a/mojo/public/java/system/watcher_impl.cc
+++ b/mojo/public/java/system/watcher_impl.cc
@@ -33,7 +33,7 @@

jint Start(JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
- jint mojo_handle,
+ jlong mojo_handle,
jint signals) {
java_watcher_.Reset(env, jcaller);

@@ -83,7 +83,7 @@
static jint JNI_WatcherImpl_Start(JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
jlong watcher_ptr,
- jint mojo_handle,
+ jlong mojo_handle,
jint signals) {
auto* watcher = reinterpret_cast<WatcherImpl*>(watcher_ptr);
return watcher->Start(env, jcaller, mojo_handle, signals);
diff --git a/services/device/android/java/src/org/chromium/services/device/InterfaceRegistrar.java b/services/device/android/java/src/org/chromium/services/device/InterfaceRegistrar.java
index 7f447d8..98e17dc 100644
--- a/services/device/android/java/src/org/chromium/services/device/InterfaceRegistrar.java
+++ b/services/device/android/java/src/org/chromium/services/device/InterfaceRegistrar.java
@@ -19,8 +19,7 @@
@JNINamespace("device")
class InterfaceRegistrar {
@CalledByNative
- static void createInterfaceRegistryForContext(
- int nativeHandle, NfcDelegate nfcDelegate) {
+ static void createInterfaceRegistryForContext(long nativeHandle, NfcDelegate nfcDelegate) {
// Note: The bindings code manages the lifetime of this object, so it
// is not necessary to hold on to a reference to it explicitly.
InterfaceRegistry registry = InterfaceRegistry.create(
diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/InterfaceRegistrar.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/InterfaceRegistrar.java
index a89d786..daec82a4 100644
--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/InterfaceRegistrar.java
+++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/InterfaceRegistrar.java
@@ -14,12 +14,12 @@

@JNINamespace("shape_detection")
class InterfaceRegistrar {
- static MessagePipeHandle messagePipeHandleFromNative(int nativeHandle) {
+ static MessagePipeHandle messagePipeHandleFromNative(long nativeHandle) {
return CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessagePipeHandle();
}

@CalledByNative
- static void bindBarcodeDetectionProvider(int nativeHandle) {
+ static void bindBarcodeDetectionProvider(long nativeHandle) {
// Immediately wrap |nativeHandle| as it cannot be allowed to leak.
MessagePipeHandle handle = messagePipeHandleFromNative(nativeHandle);

@@ -33,13 +33,13 @@
}

@CalledByNative
- static void bindFaceDetectionProvider(int nativeHandle) {
+ static void bindFaceDetectionProvider(long nativeHandle) {
FaceDetectionProvider.MANAGER.bind(
new FaceDetectionProviderImpl(), messagePipeHandleFromNative(nativeHandle));
}

@CalledByNative
- static void bindTextDetection(int nativeHandle) {
+ static void bindTextDetection(long nativeHandle) {
// Immediately wrap |nativeHandle| as it cannot be allowed to leak.
MessagePipeHandle handle = messagePipeHandleFromNative(nativeHandle);

Reply all
Reply to author
Forward
0 new messages