Commit 00975954 authored by tguilbert's avatar tguilbert Committed by Commit bot

Use JNI UnguessableToken in ScopedSurfaceRequest

d8b550c7 introduced a JNI wrapper for
base::UnguessableToken. This change uses the wrapper to send parcelled
tokens when fulfilling a ScopedSurfaceRequest, instead of two jlongs.

BUG=
TEST= verified we could still play HLS.

Review-Url: https://codereview.chromium.org/2535923003
Cr-Commit-Position: refs/heads/master@{#434815}
parent 9843095b
......@@ -10,6 +10,7 @@
#include "base/android/jni_array.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/android/memory_pressure_listener_android.h"
#include "base/android/unguessable_token_android.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/posix/global_descriptors.h"
......@@ -110,8 +111,8 @@ class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager,
content::
Java_ChildProcessServiceImpl_forwardSurfaceTextureForSurfaceRequest(
env, service_impl_, request_token.GetHighForSerialization(),
request_token.GetLowForSerialization(),
env, service_impl_,
base::android::UnguessableTokenAndroid::Create(env, request_token),
surface_texture->j_surface_texture());
}
......
......@@ -13,6 +13,7 @@
#include "base/android/context_utils.h"
#include "base/android/jni_android.h"
#include "base/android/jni_array.h"
#include "base/android/unguessable_token_android.h"
#include "base/logging.h"
#include "content/browser/android/scoped_surface_request_manager.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
......@@ -196,10 +197,12 @@ void EstablishSurfacePeer(JNIEnv* env,
void CompleteScopedSurfaceRequest(JNIEnv* env,
const JavaParamRef<jclass>& clazz,
jlong request_token_high,
jlong request_token_low,
const JavaParamRef<jobject>& token,
const JavaParamRef<jobject>& surface) {
if (request_token_high == 0 && request_token_low == 0) {
base::UnguessableToken requestToken =
base::android::UnguessableTokenAndroid::FromJavaUnguessableToken(env,
token);
if (!requestToken) {
DLOG(ERROR) << "Received invalid surface request token.";
return;
}
......@@ -209,9 +212,7 @@ void CompleteScopedSurfaceRequest(JNIEnv* env,
ScopedJavaGlobalRef<jobject> jsurface;
jsurface.Reset(env, surface);
ScopedSurfaceRequestManager::GetInstance()->FulfillScopedSurfaceRequest(
base::UnguessableToken::Deserialize(request_token_high,
request_token_low),
gl::ScopedJavaSurface(jsurface));
requestToken, gl::ScopedJavaSurface(jsurface));
}
void CreateSurfaceTextureSurface(int surface_texture_id,
......
......@@ -20,6 +20,7 @@ import org.chromium.base.BaseSwitches;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.UnguessableToken;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
......@@ -371,7 +372,7 @@ public class ChildProcessServiceImpl {
@SuppressWarnings("unused")
@CalledByNative
private void forwardSurfaceTextureForSurfaceRequest(
long requestTokenHigh, long requestTokenLow, SurfaceTexture surfaceTexture) {
UnguessableToken requestToken, SurfaceTexture surfaceTexture) {
if (mCallback == null) {
Log.e(TAG, "No callback interface has been provided.");
return;
......@@ -380,7 +381,7 @@ public class ChildProcessServiceImpl {
Surface surface = new Surface(surfaceTexture);
try {
mCallback.forwardSurfaceForSurfaceRequest(requestTokenHigh, requestTokenLow, surface);
mCallback.forwardSurfaceForSurfaceRequest(requestToken, surface);
} catch (RemoteException e) {
Log.e(TAG, "Unable to call forwardSurfaceForSurfaceRequest: %s", e);
return;
......
......@@ -21,6 +21,7 @@ import org.chromium.base.CpuFeatures;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.UnguessableToken;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
......@@ -844,7 +845,7 @@ public class ChildProcessLauncher {
@Override
public void forwardSurfaceForSurfaceRequest(
long requestTokenHigh, long requestTokenLow, Surface surface) {
UnguessableToken requestToken, Surface surface) {
// Do not allow a malicious renderer to connect to a producer. This is only used
// from stream textures managed by the GPU process.
if (callbackType != CALLBACK_FOR_GPU_PROCESS) {
......@@ -852,7 +853,7 @@ public class ChildProcessLauncher {
return;
}
nativeCompleteScopedSurfaceRequest(requestTokenHigh, requestTokenLow, surface);
nativeCompleteScopedSurfaceRequest(requestToken, surface);
}
@Override
......@@ -995,7 +996,7 @@ public class ChildProcessLauncher {
private static native void nativeEstablishSurfacePeer(
int pid, Surface surface, int primaryID, int secondaryID);
private static native void nativeCompleteScopedSurfaceRequest(
long requestTokenHigh, long requestTokenLow, Surface surface);
UnguessableToken requestToken, Surface surface);
private static native boolean nativeIsSingleProcess();
private static native Surface nativeGetViewSurface(int surfaceId);
}
......@@ -14,7 +14,7 @@ interface IChildProcessCallback {
int pid, in Surface surface, int primaryID, int secondaryID);
void forwardSurfaceForSurfaceRequest(
long requestTokenHigh, long requestTokenLow, in Surface surface);
in UnguessableToken requestToken, in Surface surface);
SurfaceWrapper getViewSurface(int surfaceId);
......
......@@ -8,3 +8,4 @@
interface org.chromium.content.common.IChildProcessCallback;
interface org.chromium.content.common.IChildProcessService;
parcelable org.chromium.base.UnguessableToken;
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