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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java

Issue 1889703002: Android Java Surfaces can now be looked up via GpuSurfaceTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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
« no previous file with comments | « content/browser/gpu/gpu_surface_tracker.cc ('k') | gpu/ipc/common/gpu_surface_lookup.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.pm.ApplicationInfo; 10 import android.content.pm.ApplicationInfo;
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (!surface.isValid()) 477 if (!surface.isValid())
478 throw new RuntimeException("Attempting to register invalid Surface." ); 478 throw new RuntimeException("Attempting to register invalid Surface." );
479 sViewSurfaceMap.put(surfaceId, surface); 479 sViewSurfaceMap.put(surfaceId, surface);
480 } 480 }
481 481
482 @CalledByNative 482 @CalledByNative
483 private static void unregisterViewSurface(int surfaceId) { 483 private static void unregisterViewSurface(int surfaceId) {
484 sViewSurfaceMap.remove(surfaceId); 484 sViewSurfaceMap.remove(surfaceId);
485 } 485 }
486 486
487 @CalledByNative
488 private static Surface getViewSurface(int surfaceId) {
489 Surface surface = sViewSurfaceMap.get(surfaceId);
490 if (surface == null) {
491 Log.e(TAG, "Invalid surfaceId.");
492 return null;
493 }
494 if (!surface.isValid()) {
495 Log.e(TAG, "Requested surface is not valid.");
496 return null;
497 }
498 return surface;
499 }
500
487 private static void registerSurfaceTextureSurface( 501 private static void registerSurfaceTextureSurface(
488 int surfaceTextureId, int clientId, Surface surface) { 502 int surfaceTextureId, int clientId, Surface surface) {
489 Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId , clientId); 503 Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId , clientId);
490 sSurfaceTextureSurfaceMap.put(key, surface); 504 sSurfaceTextureSurfaceMap.put(key, surface);
491 } 505 }
492 506
493 private static void unregisterSurfaceTextureSurface(int surfaceTextureId, in t clientId) { 507 private static void unregisterSurfaceTextureSurface(int surfaceTextureId, in t clientId) {
494 Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId , clientId); 508 Pair<Integer, Integer> key = new Pair<Integer, Integer>(surfaceTextureId , clientId);
495 Surface surface = sSurfaceTextureSurfaceMap.remove(key); 509 Surface surface = sSurfaceTextureSurfaceMap.remove(key);
496 if (surface == null) return; 510 if (surface == null) return;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 nativeEstablishSurfacePeer(pid, surface, primaryID, secondaryID) ; 833 nativeEstablishSurfacePeer(pid, surface, primaryID, secondaryID) ;
820 } 834 }
821 835
822 @Override 836 @Override
823 public SurfaceWrapper getViewSurface(int surfaceId) { 837 public SurfaceWrapper getViewSurface(int surfaceId) {
824 // Do not allow a malicious renderer to get to our view surface. 838 // Do not allow a malicious renderer to get to our view surface.
825 if (callbackType != CALLBACK_FOR_GPU_PROCESS) { 839 if (callbackType != CALLBACK_FOR_GPU_PROCESS) {
826 Log.e(TAG, "Illegal callback for non-GPU process."); 840 Log.e(TAG, "Illegal callback for non-GPU process.");
827 return null; 841 return null;
828 } 842 }
829 843 Surface surface = ChildProcessLauncher.getViewSurface(surfaceId) ;
830 Surface surface = sViewSurfaceMap.get(surfaceId);
831 if (surface == null) { 844 if (surface == null) {
832 Log.e(TAG, "Invalid surfaceId.");
833 return null;
834 }
835 if (!surface.isValid()) {
836 Log.e(TAG, "Requested surface is not valid.");
837 return null; 845 return null;
838 } 846 }
839 return new SurfaceWrapper(surface); 847 return new SurfaceWrapper(surface);
840 } 848 }
841 849
842 @Override 850 @Override
843 public void registerSurfaceTextureSurface( 851 public void registerSurfaceTextureSurface(
844 int surfaceTextureId, int clientId, Surface surface) { 852 int surfaceTextureId, int clientId, Surface surface) {
845 if (callbackType != CALLBACK_FOR_GPU_PROCESS) { 853 if (callbackType != CALLBACK_FOR_GPU_PROCESS) {
846 Log.e(TAG, "Illegal callback for non-GPU process."); 854 Log.e(TAG, "Illegal callback for non-GPU process.");
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 } 951 }
944 952
945 return true; 953 return true;
946 } 954 }
947 955
948 private static native void nativeOnChildProcessStarted(long clientContext, i nt pid); 956 private static native void nativeOnChildProcessStarted(long clientContext, i nt pid);
949 private static native void nativeEstablishSurfacePeer( 957 private static native void nativeEstablishSurfacePeer(
950 int pid, Surface surface, int primaryID, int secondaryID); 958 int pid, Surface surface, int primaryID, int secondaryID);
951 private static native boolean nativeIsSingleProcess(); 959 private static native boolean nativeIsSingleProcess();
952 } 960 }
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_surface_tracker.cc ('k') | gpu/ipc/common/gpu_surface_lookup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698