OLD | NEW |
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/logging.h" | 16 #include "base/logging.h" |
| 17 #include "content/browser/android/scoped_surface_request_manager.h" |
17 #include "content/browser/file_descriptor_info_impl.h" | 18 #include "content/browser/file_descriptor_info_impl.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/common/child_process_host_impl.h" | 23 #include "content/common/child_process_host_impl.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
25 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/common/content_client.h" | 27 #include "content/public/common/content_client.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 ScopedJavaGlobalRef<jobject> jsurface; | 231 ScopedJavaGlobalRef<jobject> jsurface; |
231 jsurface.Reset(env, surface); | 232 jsurface.Reset(env, surface); |
232 if (jsurface.is_null()) | 233 if (jsurface.is_null()) |
233 return; | 234 return; |
234 | 235 |
235 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 236 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
236 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 237 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
237 &SetSurfacePeer, jsurface, pid, primary_id, secondary_id)); | 238 &SetSurfacePeer, jsurface, pid, primary_id, secondary_id)); |
238 } | 239 } |
239 | 240 |
| 241 void CompleteScopedSurfaceRequest(JNIEnv* env, |
| 242 const JavaParamRef<jclass>& clazz, |
| 243 jlong request_token_high, |
| 244 jlong request_token_low, |
| 245 const JavaParamRef<jobject>& surface) { |
| 246 if (request_token_high == 0 && request_token_low == 0) { |
| 247 DLOG(ERROR) << "Received invalid surface request token."; |
| 248 return; |
| 249 } |
| 250 |
| 251 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 252 |
| 253 ScopedJavaGlobalRef<jobject> jsurface; |
| 254 jsurface.Reset(env, surface); |
| 255 ScopedSurfaceRequestManager::GetInstance()->FulfillScopedSurfaceRequest( |
| 256 base::UnguessableToken::Deserialize(request_token_high, |
| 257 request_token_low), |
| 258 gl::ScopedJavaSurface(jsurface)); |
| 259 } |
| 260 |
240 void RegisterViewSurface(int surface_id, const JavaRef<jobject>& j_surface) { | 261 void RegisterViewSurface(int surface_id, const JavaRef<jobject>& j_surface) { |
241 JNIEnv* env = AttachCurrentThread(); | 262 JNIEnv* env = AttachCurrentThread(); |
242 DCHECK(env); | 263 DCHECK(env); |
243 Java_ChildProcessLauncher_registerViewSurface(env, surface_id, j_surface); | 264 Java_ChildProcessLauncher_registerViewSurface(env, surface_id, j_surface); |
244 } | 265 } |
245 | 266 |
246 void UnregisterViewSurface(int surface_id) { | 267 void UnregisterViewSurface(int surface_id) { |
247 JNIEnv* env = AttachCurrentThread(); | 268 JNIEnv* env = AttachCurrentThread(); |
248 DCHECK(env); | 269 DCHECK(env); |
249 Java_ChildProcessLauncher_unregisterViewSurface(env, surface_id); | 270 Java_ChildProcessLauncher_unregisterViewSurface(env, surface_id); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { | 306 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
286 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 307 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
287 switches::kSingleProcess); | 308 switches::kSingleProcess); |
288 } | 309 } |
289 | 310 |
290 bool RegisterChildProcessLauncher(JNIEnv* env) { | 311 bool RegisterChildProcessLauncher(JNIEnv* env) { |
291 return RegisterNativesImpl(env); | 312 return RegisterNativesImpl(env); |
292 } | 313 } |
293 | 314 |
294 } // namespace content | 315 } // namespace content |
OLD | NEW |