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

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

Issue 2285593002: Add ScopedSurfaceRequestManager (Closed)
Patch Set: Simplified manager interface. Renamed to Conduit. Created 4 years, 3 months 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/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 DVLOG(1) << "Cannot find media player for player_id " << player_id; 84 DVLOG(1) << "Cannot find media player for player_id " << player_id;
84 return; 85 return;
85 } 86 }
86 87
87 if (player != player_manager->GetFullscreenPlayer()) { 88 if (player != player_manager->GetFullscreenPlayer()) {
88 gl::ScopedJavaSurface scoped_surface(surface); 89 gl::ScopedJavaSurface scoped_surface(surface);
89 player->SetVideoSurface(std::move(scoped_surface)); 90 player->SetVideoSurface(std::move(scoped_surface));
90 } 91 }
91 } 92 }
92 93
94 static void GetAndCompleteScopedSurfaceRequest(
95 const base::android::JavaRef<jobject>& surface,
liberato (no reviews please) 2016/08/30 17:58:35 perhaps switch |surface| and |request_id|. they'r
tguilbert 2016/08/30 22:53:09 Deleted this method.
96 uint64_t request_id) {
97 ScopedSurfaceRequestManager::ScopedSurfaceRequestCB surface_request =
98 ScopedSurfaceRequestManager::GetInstance()
99 ->GetAndUnregisterScopedSurfaceRequest(request_id);
100
101 if (!surface_request.is_null()) {
102 gl::ScopedJavaSurface scoped_surface(surface);
103 surface_request.Run(std::move(scoped_surface));
104 }
watk 2016/08/29 19:42:25 Two things: 1) why not call FulfillRequest? 2) doe
tguilbert 2016/08/30 22:53:09 1) Updated to call Fulfill. 2) I have added DCHECK
105 }
106
93 void LaunchDownloadProcess(base::CommandLine* cmd_line) { 107 void LaunchDownloadProcess(base::CommandLine* cmd_line) {
94 std::unique_ptr<base::CommandLine> cmd_line_deleter(cmd_line); 108 std::unique_ptr<base::CommandLine> cmd_line_deleter(cmd_line);
95 109
96 JNIEnv* env = AttachCurrentThread(); 110 JNIEnv* env = AttachCurrentThread();
97 DCHECK(env); 111 DCHECK(env);
98 112
99 // Create the Command line String[] 113 // Create the Command line String[]
100 ScopedJavaLocalRef<jobjectArray> j_argv = 114 ScopedJavaLocalRef<jobjectArray> j_argv =
101 ToJavaArrayOfStrings(env, cmd_line->argv()); 115 ToJavaArrayOfStrings(env, cmd_line->argv());
102 116
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ScopedJavaGlobalRef<jobject> jsurface; 243 ScopedJavaGlobalRef<jobject> jsurface;
230 jsurface.Reset(env, surface); 244 jsurface.Reset(env, surface);
231 if (jsurface.is_null()) 245 if (jsurface.is_null())
232 return; 246 return;
233 247
234 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 248 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
235 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 249 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
236 &SetSurfacePeer, jsurface, pid, primary_id, secondary_id)); 250 &SetSurfacePeer, jsurface, pid, primary_id, secondary_id));
237 } 251 }
238 252
253 void CompleteScopedSurfaceRequest(JNIEnv* env,
liberato (no reviews please) 2016/08/30 17:58:35 /Complete/Fulfill ?
tguilbert 2016/08/30 22:53:09 I don't know if it is easier to follow the sequenc
254 const JavaParamRef<jclass>& clazz,
255 jlong request_id,
256 const JavaParamRef<jobject>& surface) {
257 ScopedJavaGlobalRef<jobject> jsurface;
258 jsurface.Reset(env, surface);
259 if (jsurface.is_null())
260 return;
261
262 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
263 BrowserThread::PostTask(
264 BrowserThread::UI, FROM_HERE,
watk 2016/08/29 19:42:26 Do we have guarantees about which thread MPR runs
liberato (no reviews please) 2016/08/30 17:58:35 conversely, why post here if there will not be any
tguilbert 2016/08/30 22:53:09 I think I have addressed this in this new patch, b
265 base::Bind(&GetAndCompleteScopedSurfaceRequest, jsurface, request_id));
266 }
267
239 void RegisterViewSurface(int surface_id, jobject j_surface) { 268 void RegisterViewSurface(int surface_id, jobject j_surface) {
240 JNIEnv* env = AttachCurrentThread(); 269 JNIEnv* env = AttachCurrentThread();
241 DCHECK(env); 270 DCHECK(env);
242 Java_ChildProcessLauncher_registerViewSurface(env, surface_id, j_surface); 271 Java_ChildProcessLauncher_registerViewSurface(env, surface_id, j_surface);
243 } 272 }
244 273
245 void UnregisterViewSurface(int surface_id) { 274 void UnregisterViewSurface(int surface_id) {
246 JNIEnv* env = AttachCurrentThread(); 275 JNIEnv* env = AttachCurrentThread();
247 DCHECK(env); 276 DCHECK(env);
248 Java_ChildProcessLauncher_unregisterViewSurface(env, surface_id); 277 Java_ChildProcessLauncher_unregisterViewSurface(env, surface_id);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { 313 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
285 return base::CommandLine::ForCurrentProcess()->HasSwitch( 314 return base::CommandLine::ForCurrentProcess()->HasSwitch(
286 switches::kSingleProcess); 315 switches::kSingleProcess);
287 } 316 }
288 317
289 bool RegisterChildProcessLauncher(JNIEnv* env) { 318 bool RegisterChildProcessLauncher(JNIEnv* env) {
290 return RegisterNativesImpl(env); 319 return RegisterNativesImpl(env);
291 } 320 }
292 321
293 } // namespace content 322 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698