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

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: Sync 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
« no previous file with comments | « content/app/android/sandboxed_process_service.h ('k') | content/browser/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 JNIEnv* env,
56 jclass clazz,
57 jobject context,
58 jobject service) {
59 // Set up the IPC file descriptor mapping.
60 base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, ipc_fd);
61 #if defined(USE_LINUX_BREAKPAD)
62 if (crash_fd > 0) {
63 base::GlobalDescriptors::GetInstance()->Set(kCrashDumpSignal, crash_fd);
64 }
65 #endif
66 content::SurfaceTexturePeer::InitInstance(
67 new SurfaceTexturePeerSandboxedImpl(service));
68
69 }
70
71 } // namespace <anonymous>
72
73 static void InitSandboxedProcess(JNIEnv* env,
74 jclass clazz,
75 jobject context,
76 jobject service,
77 jint ipc_fd,
78 jint crash_fd) {
79 InternalInitSandboxedProcess(static_cast<int>(ipc_fd),
80 static_cast<int>(crash_fd), env, clazz, context, service);
81
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 }
86
87 static void ExitSandboxedProcess(JNIEnv* env, jclass clazz) {
88 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process.";
89 // TODO(tedchoc): These methods should also be in the content namespace to
90 // avoid specifying it in the LibraryLoaderExitHook call.
91 content::LibraryLoaderExitHook();
92 _exit(0);
93 }
94
95 namespace content {
96
97 bool RegisterSandboxedProcessService(JNIEnv* env) {
98 return RegisterNativesImpl(env);
99 }
100
101 } // namespace content
OLDNEW
« no previous file with comments | « content/app/android/sandboxed_process_service.h ('k') | content/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698