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

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

Issue 10546079: Added sandboxed process service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comments and add 'jni+' into common/DEPS. Created 8 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/app/android/sandboxed_process_service.h"
6
7 #include "base/global_descriptors_posix.h"
8 #include "base/logging.h"
9 #include "content/common/android/surface_texture_peer.h"
10 #if !defined(ANDROID_UPSTREAM_BRINGUP)
11 #include "content/common/chrome_descriptors.h"
12 #endif
13 #include "content/public/app/android_library_loader_hooks.h"
14 #include "ipc/ipc_descriptors.h"
15 #include "jni/sandboxed_process_service_jni.h"
16
17 using base::android::AttachCurrentThread;
18 using base::android::CheckException;
19
20 namespace {
21
22 class SurfaceTexturePeerSandboxedImpl : public content::SurfaceTexturePeer {
23 public:
24 // |service| is the instance of
25 // org.chromium.content.app.SandboxedProcessService.
26 SurfaceTexturePeerSandboxedImpl(jobject service)
27 : service_(service) {
28 }
29
30 virtual ~SurfaceTexturePeerSandboxedImpl() {
31 }
32
33 virtual void EstablishSurfaceTexturePeer(base::ProcessHandle pid,
34 SurfaceTextureTarget type,
35 jobject j_surface_texture,
36 int primary_id,
37 int secondary_id) {
38 JNIEnv* env = base::android::AttachCurrentThread();
39 Java_SandboxedProcessService_establishSurfaceTexturePeer(env, service_,
40 pid, type, j_surface_texture, primary_id, secondary_id);
41 CheckException(env);
42 }
43
44 private:
45 // The instance of org.chromium.content.app.SandboxedProcessService.
46 jobject service_;
47
48 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl);
49 };
50
51 // Chrome actually uses the renderer code path for all of its sandboxed
52 // processes such as renderers, plugins, etc.
53 void InternalInitSandboxedProcess(int ipc_fd,
54 int crash_fd,
55 int chrome_pak_fd,
56 int locale_pak_fd,
57 JNIEnv* env,
58 jclass clazz,
59 jobject context,
60 jobject service) {
61 // Set up the IPC file descriptor mapping.
62 base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, ipc_fd);
63 #if defined(USE_LINUX_BREAKPAD)
64 if (crash_fd > 0) {
65 base::GlobalDescriptors::GetInstance()->Set(kCrashDumpSignal, crash_fd);
66 }
67 #endif
68 }
Yaron 2012/06/11 21:09:39 Did you intentionally omit: SurfaceTexturePeer::I
michaelbai 2012/06/11 21:21:30 Yes, this code was missing. On 2012/06/11 21:09:3
69
70 } // namespace <anonymous>
71
72 static void InitSandboxedProcess(JNIEnv* env,
73 jclass clazz,
74 jobject context,
75 jobject service,
76 jint ipc_fd,
77 jint crash_fd,
78 jint chrome_pak_fd,
Yaron 2012/06/11 20:45:51 You still have chrome in here.
michaelbai 2012/06/11 21:00:10 Removed
79 jint locale_pak_fd) {
80 InternalInitSandboxedProcess(static_cast<int>(ipc_fd),
81 static_cast<int>(crash_fd), static_cast<int>(chrome_pak_fd),
82 static_cast<int>(locale_pak_fd), env, clazz, context, service);
83
84 // sandboxed process can't be reused. There is no need to wait for the browser
85 // to unbind the service. Just exit and done.
86 LOG(INFO) << "SandboxedProcessService: Drop out of SandboxedProcessMain.";
87 }
88
89 static void ExitSandboxedProcess(JNIEnv* env, jclass clazz) {
90 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process.";
91 // TODO(tedchoc): These methods should also be in the content namespace to
92 // avoid specifying it in the LibraryLoaderExitHook call.
93 content::LibraryLoaderExitHook();
94 _exit(0);
95 }
96
97 namespace content {
98
99 bool RegisterSandboxedProcessService(JNIEnv* env) {
100 return RegisterNativesImpl(env);
101 }
102
103 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698