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

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: Init 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
69 #if !defined(ANDROID_UPSTREAM_BRINGUP)
Yaron 2012/06/11 19:46:22 Please remove this. It has to refactored anyway (c
jam 2012/06/11 20:13:17 +1. content also doesn't know about how embedders
michaelbai 2012/06/11 20:30:16 Done.
michaelbai 2012/06/11 20:30:16 I left them here as a remainder here for somebody
70 CHECK(chrome_pak_fd) << "Invalid chrome pak descriptor.";
71 CHECK(locale_pak_fd) << "Invalid locale pak descriptor.";
72 base::GlobalDescriptors::GetInstance()->Set(
73 kAndroidChromePakDescriptor, chrome_pak_fd);
74 base::GlobalDescriptors::GetInstance()->Set(
75 kAndroidLocalePakDescriptor, locale_pak_fd);
76 SurfaceTexturePeer::InitInstance(
77 new SurfaceTexturePeerSandboxedImpl(service));
78 #endif
79 }
80
81 } // namespace <anonymous>
82
83 static void InitSandboxedProcess(JNIEnv* env,
84 jclass clazz,
85 jobject context,
86 jobject service,
87 jint ipc_fd,
88 jint crash_fd,
89 jint chrome_pak_fd,
90 jint locale_pak_fd) {
91 InternalInitSandboxedProcess(static_cast<int>(ipc_fd),
92 static_cast<int>(crash_fd), static_cast<int>(chrome_pak_fd),
93 static_cast<int>(locale_pak_fd), env, clazz, context, service);
94
95 // sandboxed process can't be reused. There is no need to wait for the browser
96 // to unbind the service. Just exit and done.
97 LOG(INFO) << "SandboxedProcessService: Drop out of SandboxedProcessMain.";
98 }
99
100 static void ExitSandboxedProcess(JNIEnv* env, jclass clazz) {
101 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process.";
102 // TODO(tedchoc): These methods should also be in the content namespace to
103 // avoid specifying it in the LibraryLoaderExitHook call.
104 content::LibraryLoaderExitHook();
105 _exit(0);
106 }
107
108 namespace content {
109
110 bool RegisterSandboxedProcessService(JNIEnv* env) {
111 return RegisterNativesImpl(env);
112 }
113
114 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698