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

Side by Side Diff: content/browser/android/child_process_launcher_android.cc

Issue 2535923003: Use JNI UnguessableToken in ScopedSurfaceRequest (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/android/child_process_launcher_android.h" 5 #include "content/browser/android/child_process_launcher_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/android/context_utils.h" 13 #include "base/android/context_utils.h"
14 #include "base/android/jni_android.h" 14 #include "base/android/jni_android.h"
15 #include "base/android/jni_array.h" 15 #include "base/android/jni_array.h"
16 #include "base/android/unguessable_token_android.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "content/browser/android/scoped_surface_request_manager.h" 18 #include "content/browser/android/scoped_surface_request_manager.h"
18 #include "content/browser/frame_host/render_frame_host_impl.h" 19 #include "content/browser/frame_host/render_frame_host_impl.h"
19 #include "content/browser/media/android/browser_media_player_manager.h" 20 #include "content/browser/media/android/browser_media_player_manager.h"
20 #include "content/browser/media/android/media_web_contents_observer_android.h" 21 #include "content/browser/media/android/media_web_contents_observer_android.h"
21 #include "content/browser/web_contents/web_contents_impl.h" 22 #include "content/browser/web_contents/web_contents_impl.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
24 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
25 #include "gpu/ipc/common/gpu_surface_tracker.h" 26 #include "gpu/ipc/common/gpu_surface_tracker.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (jsurface.is_null()) 190 if (jsurface.is_null())
190 return; 191 return;
191 192
192 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 193 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
193 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 194 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
194 &SetSurfacePeer, jsurface, pid, primary_id, secondary_id)); 195 &SetSurfacePeer, jsurface, pid, primary_id, secondary_id));
195 } 196 }
196 197
197 void CompleteScopedSurfaceRequest(JNIEnv* env, 198 void CompleteScopedSurfaceRequest(JNIEnv* env,
198 const JavaParamRef<jclass>& clazz, 199 const JavaParamRef<jclass>& clazz,
199 jlong request_token_high, 200 const JavaParamRef<jobject>& token,
200 jlong request_token_low,
201 const JavaParamRef<jobject>& surface) { 201 const JavaParamRef<jobject>& surface) {
202 if (request_token_high == 0 && request_token_low == 0) { 202 base::UnguessableToken requestToken =
203 base::android::UnguessableTokenAndroid::FromJavaUnguessableToken(env,
204 token);
205 if (!requestToken) {
203 DLOG(ERROR) << "Received invalid surface request token."; 206 DLOG(ERROR) << "Received invalid surface request token.";
204 return; 207 return;
205 } 208 }
206 209
207 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 210 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
208 211
209 ScopedJavaGlobalRef<jobject> jsurface; 212 ScopedJavaGlobalRef<jobject> jsurface;
210 jsurface.Reset(env, surface); 213 jsurface.Reset(env, surface);
211 ScopedSurfaceRequestManager::GetInstance()->FulfillScopedSurfaceRequest( 214 ScopedSurfaceRequestManager::GetInstance()->FulfillScopedSurfaceRequest(
212 base::UnguessableToken::Deserialize(request_token_high, 215 requestToken, gl::ScopedJavaSurface(jsurface));
213 request_token_low),
214 gl::ScopedJavaSurface(jsurface));
215 } 216 }
216 217
217 void CreateSurfaceTextureSurface(int surface_texture_id, 218 void CreateSurfaceTextureSurface(int surface_texture_id,
218 int client_id, 219 int client_id,
219 gl::SurfaceTexture* surface_texture) { 220 gl::SurfaceTexture* surface_texture) {
220 JNIEnv* env = AttachCurrentThread(); 221 JNIEnv* env = AttachCurrentThread();
221 DCHECK(env); 222 DCHECK(env);
222 Java_ChildProcessLauncher_createSurfaceTextureSurface( 223 Java_ChildProcessLauncher_createSurfaceTextureSurface(
223 env, surface_texture_id, client_id, surface_texture->j_surface_texture()); 224 env, surface_texture_id, client_id, surface_texture->j_surface_texture());
224 } 225 }
(...skipping 26 matching lines...) Expand all
251 gl::ScopedJavaSurface surface_view = 252 gl::ScopedJavaSurface surface_view =
252 gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface(surface_id); 253 gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface(surface_id);
253 return base::android::ScopedJavaLocalRef<jobject>(surface_view.j_surface()); 254 return base::android::ScopedJavaLocalRef<jobject>(surface_view.j_surface());
254 } 255 }
255 256
256 bool RegisterChildProcessLauncher(JNIEnv* env) { 257 bool RegisterChildProcessLauncher(JNIEnv* env) {
257 return RegisterNativesImpl(env); 258 return RegisterNativesImpl(env);
258 } 259 }
259 260
260 } // namespace content 261 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698