Commit 1662bf88 authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

JNI refactor: @NativeMethods conversion (//mojo).

This CL was generated by
//base/android/jni_generator/jni_refactorer.py.

Bug: 929661
Change-Id: Ia3a1f45ce0255362c44b51dded3abd640ad1d966
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809335Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697825}
parent 901bcc21
......@@ -61,8 +61,10 @@ android_library("system_impl_java") {
deps = [
"//base:base_java",
"//base:jni_java",
"//mojo/public/java:system_java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
}
# Targets should also depend on :test_support for the native side.
......
......@@ -6,6 +6,7 @@ package org.chromium.mojo.system.impl;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.mojo.system.RunLoop;
/**
......@@ -21,31 +22,31 @@ class BaseRunLoop implements RunLoop {
BaseRunLoop(CoreImpl core) {
this.mCore = core;
this.mRunLoopID = nativeCreateBaseRunLoop();
this.mRunLoopID = BaseRunLoopJni.get().createBaseRunLoop(BaseRunLoop.this);
}
@Override
public void run() {
assert mRunLoopID != 0 : "The run loop cannot run once closed";
nativeRun();
BaseRunLoopJni.get().run(BaseRunLoop.this);
}
@Override
public void runUntilIdle() {
assert mRunLoopID != 0 : "The run loop cannot run once closed";
nativeRunUntilIdle();
BaseRunLoopJni.get().runUntilIdle(BaseRunLoop.this);
}
@Override
public void quit() {
assert mRunLoopID != 0 : "The run loop cannot be quitted run once closed";
nativeQuit();
BaseRunLoopJni.get().quit(BaseRunLoop.this);
}
@Override
public void postDelayedTask(Runnable runnable, long delay) {
assert mRunLoopID != 0 : "The run loop cannot run tasks once closed";
nativePostDelayedTask(mRunLoopID, runnable, delay);
BaseRunLoopJni.get().postDelayedTask(BaseRunLoop.this, mRunLoopID, runnable, delay);
}
@Override
......@@ -56,7 +57,7 @@ class BaseRunLoop implements RunLoop {
// We don't want to de-register a different run loop!
assert mCore.getCurrentRunLoop() == this : "Only the current run loop can be closed";
mCore.clearCurrentRunLoop();
nativeDeleteMessageLoop(mRunLoopID);
BaseRunLoopJni.get().deleteMessageLoop(BaseRunLoop.this, mRunLoopID);
mRunLoopID = 0;
}
......@@ -65,10 +66,13 @@ class BaseRunLoop implements RunLoop {
runnable.run();
}
private native long nativeCreateBaseRunLoop();
private native void nativeRun();
private native void nativeRunUntilIdle();
private native void nativeQuit();
private native void nativePostDelayedTask(long runLoopID, Runnable runnable, long delay);
private native void nativeDeleteMessageLoop(long runLoopID);
@NativeMethods
interface Natives {
long createBaseRunLoop(BaseRunLoop caller);
void run(BaseRunLoop caller);
void runUntilIdle(BaseRunLoop caller);
void quit(BaseRunLoop caller);
void postDelayedTask(BaseRunLoop caller, long runLoopID, Runnable runnable, long delay);
void deleteMessageLoop(BaseRunLoop caller, long runLoopID);
}
}
......@@ -6,6 +6,7 @@ package org.chromium.mojo.system.impl;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.mojo.system.Core;
import org.chromium.mojo.system.Handle;
import org.chromium.mojo.system.MojoResult;
......@@ -13,7 +14,7 @@ import org.chromium.mojo.system.Watcher;
@JNINamespace("mojo::android")
class WatcherImpl implements Watcher {
private long mImplPtr = nativeCreateWatcher();
private long mImplPtr = WatcherImplJni.get().createWatcher(WatcherImpl.this);
private Callback mCallback;
@Override
......@@ -24,8 +25,8 @@ class WatcherImpl implements Watcher {
if (!(handle instanceof HandleBase)) {
return MojoResult.INVALID_ARGUMENT;
}
int result =
nativeStart(mImplPtr, ((HandleBase) handle).getMojoHandle(), signals.getFlags());
int result = WatcherImplJni.get().start(WatcherImpl.this, mImplPtr,
((HandleBase) handle).getMojoHandle(), signals.getFlags());
if (result == MojoResult.OK) mCallback = callback;
return result;
}
......@@ -36,7 +37,7 @@ class WatcherImpl implements Watcher {
return;
}
mCallback = null;
nativeCancel(mImplPtr);
WatcherImplJni.get().cancel(WatcherImpl.this, mImplPtr);
}
@Override
......@@ -44,7 +45,7 @@ class WatcherImpl implements Watcher {
if (mImplPtr == 0) {
return;
}
nativeDelete(mImplPtr);
WatcherImplJni.get().delete(WatcherImpl.this, mImplPtr);
mImplPtr = 0;
}
......@@ -53,11 +54,11 @@ class WatcherImpl implements Watcher {
mCallback.onResult(result);
}
private native long nativeCreateWatcher();
private native int nativeStart(long implPtr, int mojoHandle, int flags);
private native void nativeCancel(long implPtr);
private native void nativeDelete(long implPtr);
@NativeMethods
interface Natives {
long createWatcher(WatcherImpl caller);
int start(WatcherImpl caller, long implPtr, int mojoHandle, int flags);
void cancel(WatcherImpl caller, long implPtr);
void delete(WatcherImpl caller, long implPtr);
}
}
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