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

Side by Side Diff: content/public/android/java/src/org/chromium/content/app/SandboxedProcessService.java

Issue 11503013: android: Pass CPU properties from browser to renderer process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unused Java native method + fix comment Created 7 years, 11 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 | Annotate | Revision Log
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 package org.chromium.content.app; 5 package org.chromium.content.app;
6 6
7 import android.app.Service; 7 import android.app.Service;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.graphics.SurfaceTexture; 10 import android.graphics.SurfaceTexture;
(...skipping 29 matching lines...) Expand all
40 public class SandboxedProcessService extends Service { 40 public class SandboxedProcessService extends Service {
41 private static final String MAIN_THREAD_NAME = "SandboxedProcessMain"; 41 private static final String MAIN_THREAD_NAME = "SandboxedProcessMain";
42 private static final String TAG = "SandboxedProcessService"; 42 private static final String TAG = "SandboxedProcessService";
43 private ISandboxedProcessCallback mCallback; 43 private ISandboxedProcessCallback mCallback;
44 44
45 // This is the native "Main" thread for the renderer / utility process. 45 // This is the native "Main" thread for the renderer / utility process.
46 private Thread mSandboxMainThread; 46 private Thread mSandboxMainThread;
47 // Parameters received via IPC, only accessed while holding the mSandboxMain Thread monitor. 47 // Parameters received via IPC, only accessed while holding the mSandboxMain Thread monitor.
48 private String mNativeLibraryName; // Must be passed in via the bind comman d. 48 private String mNativeLibraryName; // Must be passed in via the bind comman d.
49 private String[] mCommandLineParams; 49 private String[] mCommandLineParams;
50 private int mCpuCount;
51 private long mCpuFeatures;
50 // Pairs IDs and file descriptors that should be registered natively. 52 // Pairs IDs and file descriptors that should be registered natively.
51 private ArrayList<Integer> mFileIds; 53 private ArrayList<Integer> mFileIds;
52 private ArrayList<ParcelFileDescriptor> mFileFds; 54 private ArrayList<ParcelFileDescriptor> mFileFds;
53 55
54 private static Context sContext = null; 56 private static Context sContext = null;
55 private boolean mLibraryInitialized = false; 57 private boolean mLibraryInitialized = false;
56 58
57 // Binder object used by clients for this service. 59 // Binder object used by clients for this service.
58 private final ISandboxedProcessService.Stub mBinder = new ISandboxedProcessS ervice.Stub() { 60 private final ISandboxedProcessService.Stub mBinder = new ISandboxedProcessS ervice.Stub() {
59 // NOTE: Implement any ISandboxedProcessService methods here. 61 // NOTE: Implement any ISandboxedProcessService methods here.
60 @Override 62 @Override
61 public int setupConnection(Bundle args, ISandboxedProcessCallback callba ck) { 63 public int setupConnection(Bundle args, ISandboxedProcessCallback callba ck) {
62 mCallback = callback; 64 mCallback = callback;
63 synchronized (mSandboxMainThread) { 65 synchronized (mSandboxMainThread) {
64 // Allow the command line to be set via bind() intent or setupCo nnection, but 66 // Allow the command line to be set via bind() intent or setupCo nnection, but
65 // the FD can only be transferred here. 67 // the FD can only be transferred here.
66 if (mCommandLineParams == null) { 68 if (mCommandLineParams == null) {
67 mCommandLineParams = args.getStringArray( 69 mCommandLineParams = args.getStringArray(
68 SandboxedProcessConnection.EXTRA_COMMAND_LINE); 70 SandboxedProcessConnection.EXTRA_COMMAND_LINE);
69 } 71 }
70 // We must have received the command line by now 72 // We must have received the command line by now
71 assert mCommandLineParams != null; 73 assert mCommandLineParams != null;
74 mCpuCount = args.getInt(SandboxedProcessConnection.EXTRA_CPU_COU NT);
75 mCpuFeatures = args.getLong(SandboxedProcessConnection.EXTRA_CPU _FEATURES);
76 assert mCpuCount > 0;
72 mFileIds = new ArrayList<Integer>(); 77 mFileIds = new ArrayList<Integer>();
73 mFileFds = new ArrayList<ParcelFileDescriptor>(); 78 mFileFds = new ArrayList<ParcelFileDescriptor>();
74 for (int i = 0;; i++) { 79 for (int i = 0;; i++) {
75 String fdName = SandboxedProcessConnection.EXTRA_FILES_PREFI X + i 80 String fdName = SandboxedProcessConnection.EXTRA_FILES_PREFI X + i
76 + SandboxedProcessConnection.EXTRA_FILES_FD_SUFFIX; 81 + SandboxedProcessConnection.EXTRA_FILES_FD_SUFFIX;
77 ParcelFileDescriptor parcel = args.getParcelable(fdName); 82 ParcelFileDescriptor parcel = args.getParcelable(fdName);
78 if (parcel == null) { 83 if (parcel == null) {
79 // End of the file list. 84 // End of the file list.
80 break; 85 break;
81 } 86 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 140 }
136 assert mFileIds.size() == mFileFds.size(); 141 assert mFileIds.size() == mFileFds.size();
137 int[] fileIds = new int[mFileIds.size()]; 142 int[] fileIds = new int[mFileIds.size()];
138 int[] fileFds = new int[mFileFds.size()]; 143 int[] fileFds = new int[mFileFds.size()];
139 for (int i = 0; i < mFileIds.size(); ++i) { 144 for (int i = 0; i < mFileIds.size(); ++i) {
140 fileIds[i] = mFileIds.get(i); 145 fileIds[i] = mFileIds.get(i);
141 fileFds[i] = mFileFds.get(i).detachFd(); 146 fileFds[i] = mFileFds.get(i).detachFd();
142 } 147 }
143 ContentMain.initApplicationContext(sContext.getApplicationCo ntext()); 148 ContentMain.initApplicationContext(sContext.getApplicationCo ntext());
144 nativeInitSandboxedProcess(sContext.getApplicationContext(), 149 nativeInitSandboxedProcess(sContext.getApplicationContext(),
145 SandboxedProcessService.this, fileIds, fileFds); 150 SandboxedProcessService.this, fileIds, fileFds,
151 mCpuCount, mCpuFeatures);
146 ContentMain.start(); 152 ContentMain.start();
147 nativeExitSandboxedProcess(); 153 nativeExitSandboxedProcess();
148 } catch (InterruptedException e) { 154 } catch (InterruptedException e) {
149 Log.w(TAG, MAIN_THREAD_NAME + " startup failed: " + e); 155 Log.w(TAG, MAIN_THREAD_NAME + " startup failed: " + e);
150 } 156 }
151 } 157 }
152 }, MAIN_THREAD_NAME); 158 }, MAIN_THREAD_NAME);
153 mSandboxMainThread.start(); 159 mSandboxMainThread.start();
154 } 160 }
155 161
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 * The main entry point for a sandboxed process. This should be called from a new thread since 248 * The main entry point for a sandboxed process. This should be called from a new thread since
243 * it will not return until the sandboxed process exits. See sandboxed_proce ss_service.{h,cc} 249 * it will not return until the sandboxed process exits. See sandboxed_proce ss_service.{h,cc}
244 * 250 *
245 * @param applicationContext The Application Context of the current process. 251 * @param applicationContext The Application Context of the current process.
246 * @param service The current SandboxedProcessService object. 252 * @param service The current SandboxedProcessService object.
247 * @param fileIds A list of file IDs that should be registered for access by the renderer. 253 * @param fileIds A list of file IDs that should be registered for access by the renderer.
248 * @param fileFds A list of file descriptors that should be registered for a ccess by the 254 * @param fileFds A list of file descriptors that should be registered for a ccess by the
249 * renderer. 255 * renderer.
250 */ 256 */
251 private static native void nativeInitSandboxedProcess(Context applicationCon text, 257 private static native void nativeInitSandboxedProcess(Context applicationCon text,
252 SandboxedProcessService service, int[] extraFileIds, int[] extraFile Fds); 258 SandboxedProcessService service, int[] extraFileIds, int[] extraFile Fds,
259 int cpuCount, long cpuFeatures);
253 260
254 /** 261 /**
255 * Force the sandboxed process to exit. 262 * Force the sandboxed process to exit.
256 */ 263 */
257 private static native void nativeExitSandboxedProcess(); 264 private static native void nativeExitSandboxedProcess();
258 265
259 private native void nativeShutdownSandboxMainThread(); 266 private native void nativeShutdownSandboxMainThread();
260 } 267 }
OLDNEW
« no previous file with comments | « content/content_app.gypi ('k') | content/public/android/java/src/org/chromium/content/browser/SandboxedProcessConnection.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698