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

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

Issue 12321131: Renamed Sandboxed process to Child process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebaesed and removed stub SandboxedProcessService Created 7 years, 9 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
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 <cpu-features.h>
8
9 #include "base/android/jni_array.h"
10 #include "base/logging.h"
11 #include "base/posix/global_descriptors.h"
12 #include "content/common/android/surface_texture_peer.h"
13 #include "content/common/child_process.h"
14 #include "content/common/child_thread.h"
15 #include "content/public/app/android_library_loader_hooks.h"
16 #include "content/public/common/content_descriptors.h"
17 #include "ipc/ipc_descriptors.h"
18 #include "jni/SandboxedProcessService_jni.h"
19
20 using base::android::AttachCurrentThread;
21 using base::android::CheckException;
22 using base::android::JavaIntArrayToIntVector;
23
24 namespace {
25
26 class SurfaceTexturePeerSandboxedImpl : public content::SurfaceTexturePeer {
27 public:
28 // |service| is the instance of
29 // org.chromium.content.app.SandboxedProcessService.
30 SurfaceTexturePeerSandboxedImpl(jobject service)
31 : service_(service) {
32 }
33
34 virtual ~SurfaceTexturePeerSandboxedImpl() {
35 }
36
37 virtual void EstablishSurfaceTexturePeer(
38 base::ProcessHandle pid,
39 scoped_refptr<content::SurfaceTextureBridge> surface_texture_bridge,
40 int primary_id,
41 int secondary_id) {
42 JNIEnv* env = base::android::AttachCurrentThread();
43 content::Java_SandboxedProcessService_establishSurfaceTexturePeer(
44 env, service_, pid,
45 surface_texture_bridge->j_surface_texture().obj(), primary_id,
46 secondary_id);
47 CheckException(env);
48 }
49
50 private:
51 // The instance of org.chromium.content.app.SandboxedProcessService.
52 jobject service_;
53
54 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl);
55 };
56
57 // Chrome actually uses the renderer code path for all of its sandboxed
58 // processes such as renderers, plugins, etc.
59 void InternalInitSandboxedProcess(const std::vector<int>& file_ids,
60 const std::vector<int>& file_fds,
61 JNIEnv* env,
62 jclass clazz,
63 jobject context,
64 jobject service,
65 jint cpu_count,
66 jlong cpu_features) {
67 // Set the CPU properties.
68 android_setCpu(cpu_count, cpu_features);
69 // Register the file descriptors.
70 // This includes the IPC channel, the crash dump signals and resource related
71 // files.
72 DCHECK(file_fds.size() == file_ids.size());
73 for (size_t i = 0; i < file_ids.size(); ++i)
74 base::GlobalDescriptors::GetInstance()->Set(file_ids[i], file_fds[i]);
75
76 content::SurfaceTexturePeer::InitInstance(
77 new SurfaceTexturePeerSandboxedImpl(service));
78
79 }
80
81 void QuitSandboxMainThreadMessageLoop() {
82 MessageLoop::current()->Quit();
83 }
84
85 } // namespace <anonymous>
86
87 namespace content {
88
89 void InitSandboxedProcess(JNIEnv* env,
90 jclass clazz,
91 jobject context,
92 jobject service,
93 jintArray j_file_ids,
94 jintArray j_file_fds,
95 jint cpu_count,
96 jlong cpu_features) {
97 std::vector<int> file_ids;
98 std::vector<int> file_fds;
99 JavaIntArrayToIntVector(env, j_file_ids, &file_ids);
100 JavaIntArrayToIntVector(env, j_file_fds, &file_fds);
101
102 InternalInitSandboxedProcess(
103 file_ids, file_fds, env, clazz, context, service,
104 cpu_count, cpu_features);
105 }
106
107 void ExitSandboxedProcess(JNIEnv* env, jclass clazz) {
108 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process.";
109 LibraryLoaderExitHook();
110 _exit(0);
111 }
112
113 bool RegisterSandboxedProcessService(JNIEnv* env) {
114 return RegisterNativesImpl(env);
115 }
116
117 void ShutdownSandboxMainThread(JNIEnv* env, jobject obj) {
118 ChildProcess* current_process = ChildProcess::current();
119 if (!current_process)
120 return;
121 ChildThread* main_child_thread = current_process->main_thread();
122 if (main_child_thread && main_child_thread->message_loop())
123 main_child_thread->message_loop()->PostTask(FROM_HERE,
124 base::Bind(&QuitSandboxMainThreadMessageLoop));
125 }
126
127 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698