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

Side by Side Diff: content/app/android/sandboxed_process_service.cc

Issue 10696025: Upstream ChildProcessLauncher changes for Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add additional assert and comments Created 8 years, 5 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
« no previous file with comments | « base/android/jni_array.cc ('k') | content/browser/android/sandboxed_process_launcher.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 (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/app/android/sandboxed_process_service.h" 5 #include "content/app/android/sandboxed_process_service.h"
6 6
7 #include "base/android/jni_array.h"
7 #include "base/global_descriptors_posix.h" 8 #include "base/global_descriptors_posix.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "content/common/android/surface_texture_peer.h" 10 #include "content/common/android/surface_texture_peer.h"
10 #include "content/public/app/android_library_loader_hooks.h" 11 #include "content/public/app/android_library_loader_hooks.h"
11 #include "content/public/common/content_descriptors.h" 12 #include "content/public/common/content_descriptors.h"
12 #include "ipc/ipc_descriptors.h" 13 #include "ipc/ipc_descriptors.h"
13 #include "jni/sandboxed_process_service_jni.h" 14 #include "jni/sandboxed_process_service_jni.h"
14 15
15 using base::android::AttachCurrentThread; 16 using base::android::AttachCurrentThread;
16 using base::android::CheckException; 17 using base::android::CheckException;
18 using base::android::JavaIntArrayToIntVector;
17 19
18 namespace { 20 namespace {
19 21
20 class SurfaceTexturePeerSandboxedImpl : public content::SurfaceTexturePeer { 22 class SurfaceTexturePeerSandboxedImpl : public content::SurfaceTexturePeer {
21 public: 23 public:
22 // |service| is the instance of 24 // |service| is the instance of
23 // org.chromium.content.app.SandboxedProcessService. 25 // org.chromium.content.app.SandboxedProcessService.
24 SurfaceTexturePeerSandboxedImpl(jobject service) 26 SurfaceTexturePeerSandboxedImpl(jobject service)
25 : service_(service) { 27 : service_(service) {
26 } 28 }
27 29
28 virtual ~SurfaceTexturePeerSandboxedImpl() { 30 virtual ~SurfaceTexturePeerSandboxedImpl() {
29 } 31 }
30 32
31 virtual void EstablishSurfaceTexturePeer(base::ProcessHandle pid, 33 virtual void EstablishSurfaceTexturePeer(base::ProcessHandle pid,
32 SurfaceTextureTarget type, 34 SurfaceTextureTarget type,
33 jobject j_surface_texture, 35 jobject j_surface_texture,
34 int primary_id, 36 int primary_id,
35 int secondary_id) { 37 int secondary_id) {
36 JNIEnv* env = base::android::AttachCurrentThread(); 38 JNIEnv* env = base::android::AttachCurrentThread();
37 content::Java_SandboxedProcessService_establishSurfaceTexturePeer( 39 content::Java_SandboxedProcessService_establishSurfaceTexturePeer(
38 env, service_, pid, type, j_surface_texture, primary_id, secondary_id); 40 env, service_, pid, type, j_surface_texture, primary_id, secondary_id);
39 CheckException(env); 41 CheckException(env);
40 } 42 }
41 43
42 private: 44 private:
43 // The instance of org.chromium.content.app.SandboxedProcessService. 45 // The instance of org.chromium.content.app.SandboxedProcessService.
44 jobject service_; 46 jobject service_;
45 47
46 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl); 48 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl);
47 }; 49 };
48 50
49 // Chrome actually uses the renderer code path for all of its sandboxed 51 // Chrome actually uses the renderer code path for all of its sandboxed
50 // processes such as renderers, plugins, etc. 52 // processes such as renderers, plugins, etc.
51 void InternalInitSandboxedProcess(int ipc_fd, 53 void InternalInitSandboxedProcess(int ipc_fd,
52 int crash_fd, 54 const std::vector<int>& extra_file_ids,
55 const std::vector<int>& extra_file_fds,
53 JNIEnv* env, 56 JNIEnv* env,
54 jclass clazz, 57 jclass clazz,
55 jobject context, 58 jobject context,
56 jobject service) { 59 jobject service) {
57 // Set up the IPC file descriptor mapping. 60 // Set up the IPC file descriptor mapping.
58 base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, ipc_fd); 61 base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, ipc_fd);
59 #if defined(USE_LINUX_BREAKPAD) 62 // Register the extra file descriptors.
60 if (crash_fd > 0) { 63 // This usually include the crash dump signals and resource related files.
61 base::GlobalDescriptors::GetInstance()->Set(kCrashDumpSignal, crash_fd); 64 DCHECK(extra_file_fds.size() == extra_file_ids.size());
65 for (size_t i = 0; i < extra_file_ids.size(); ++i) {
66 base::GlobalDescriptors::GetInstance()->Set(extra_file_ids[i],
67 extra_file_fds[i]);
62 } 68 }
63 #endif 69
64 content::SurfaceTexturePeer::InitInstance( 70 content::SurfaceTexturePeer::InitInstance(
65 new SurfaceTexturePeerSandboxedImpl(service)); 71 new SurfaceTexturePeerSandboxedImpl(service));
66 72
67 } 73 }
68 74
69 } // namespace <anonymous> 75 } // namespace <anonymous>
70 76
71 namespace content { 77 namespace content {
72 78
73 void InitSandboxedProcess(JNIEnv* env, 79 void InitSandboxedProcess(JNIEnv* env,
74 jclass clazz, 80 jclass clazz,
75 jobject context, 81 jobject context,
76 jobject service, 82 jobject service,
77 jint ipc_fd, 83 jint ipc_fd,
78 jint crash_fd) { 84 jintArray j_extra_file_ids,
85 jintArray j_extra_file_fds) {
86 std::vector<int> extra_file_ids;
87 std::vector<int> extra_file_fds;
88 JavaIntArrayToIntVector(env, j_extra_file_ids, &extra_file_ids);
89 JavaIntArrayToIntVector(env, j_extra_file_fds, &extra_file_fds);
90
79 InternalInitSandboxedProcess(static_cast<int>(ipc_fd), 91 InternalInitSandboxedProcess(static_cast<int>(ipc_fd),
80 static_cast<int>(crash_fd), env, clazz, context, service); 92 extra_file_ids, extra_file_fds,
81 93 env, clazz, context, service);
82 // sandboxed process can't be reused. There is no need to wait for the browser
83 // to unbind the service. Just exit and done.
84 LOG(INFO) << "SandboxedProcessService: Drop out of SandboxedProcessMain.";
85 } 94 }
86 95
87 void ExitSandboxedProcess(JNIEnv* env, jclass clazz) { 96 void ExitSandboxedProcess(JNIEnv* env, jclass clazz) {
88 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process."; 97 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process.";
89 LibraryLoaderExitHook(); 98 LibraryLoaderExitHook();
90 _exit(0); 99 _exit(0);
91 } 100 }
92 101
93 bool RegisterSandboxedProcessService(JNIEnv* env) { 102 bool RegisterSandboxedProcessService(JNIEnv* env) {
94 return RegisterNativesImpl(env); 103 return RegisterNativesImpl(env);
95 } 104 }
96 105
97 } // namespace content 106 } // namespace content
OLDNEW
« no previous file with comments | « base/android/jni_array.cc ('k') | content/browser/android/sandboxed_process_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698