OLD | NEW |
---|---|
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 <cpu-features.h> | |
8 # | |
bulach
2012/12/10 14:03:07
nit: spurious #
digit1
2012/12/10 14:44:56
Done.
| |
7 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/posix/global_descriptors.h" | 11 #include "base/posix/global_descriptors.h" |
10 #include "content/common/android/surface_texture_peer.h" | 12 #include "content/common/android/surface_texture_peer.h" |
11 #include "content/common/child_process.h" | 13 #include "content/common/child_process.h" |
12 #include "content/common/child_thread.h" | 14 #include "content/common/child_thread.h" |
13 #include "content/public/app/android_library_loader_hooks.h" | 15 #include "content/public/app/android_library_loader_hooks.h" |
14 #include "content/public/common/content_descriptors.h" | 16 #include "content/public/common/content_descriptors.h" |
15 #include "ipc/ipc_descriptors.h" | 17 #include "ipc/ipc_descriptors.h" |
16 #include "jni/SandboxedProcessService_jni.h" | 18 #include "jni/SandboxedProcessService_jni.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl); | 55 DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerSandboxedImpl); |
54 }; | 56 }; |
55 | 57 |
56 // Chrome actually uses the renderer code path for all of its sandboxed | 58 // Chrome actually uses the renderer code path for all of its sandboxed |
57 // processes such as renderers, plugins, etc. | 59 // processes such as renderers, plugins, etc. |
58 void InternalInitSandboxedProcess(const std::vector<int>& file_ids, | 60 void InternalInitSandboxedProcess(const std::vector<int>& file_ids, |
59 const std::vector<int>& file_fds, | 61 const std::vector<int>& file_fds, |
60 JNIEnv* env, | 62 JNIEnv* env, |
61 jclass clazz, | 63 jclass clazz, |
62 jobject context, | 64 jobject context, |
63 jobject service) { | 65 jobject service, |
66 jint cpu_count, | |
67 jlong cpu_features | |
68 ) { | |
bulach
2012/12/10 14:03:07
nit: move this ) { one line up
digit1
2012/12/10 14:44:56
Done.
| |
69 // Set the CPU properties. | |
70 android_setCpu(cpu_count, cpu_features); | |
64 // Register the file descriptors. | 71 // Register the file descriptors. |
65 // This includes the IPC channel, the crash dump signals and resource related | 72 // This includes the IPC channel, the crash dump signals and resource related |
66 // files. | 73 // files. |
67 DCHECK(file_fds.size() == file_ids.size()); | 74 DCHECK(file_fds.size() == file_ids.size()); |
68 for (size_t i = 0; i < file_ids.size(); ++i) | 75 for (size_t i = 0; i < file_ids.size(); ++i) |
69 base::GlobalDescriptors::GetInstance()->Set(file_ids[i], file_fds[i]); | 76 base::GlobalDescriptors::GetInstance()->Set(file_ids[i], file_fds[i]); |
70 | 77 |
71 content::SurfaceTexturePeer::InitInstance( | 78 content::SurfaceTexturePeer::InitInstance( |
72 new SurfaceTexturePeerSandboxedImpl(service)); | 79 new SurfaceTexturePeerSandboxedImpl(service)); |
73 | 80 |
74 } | 81 } |
75 | 82 |
76 void QuitSandboxMainThreadMessageLoop() { | 83 void QuitSandboxMainThreadMessageLoop() { |
77 MessageLoop::current()->Quit(); | 84 MessageLoop::current()->Quit(); |
78 } | 85 } |
79 | 86 |
80 } // namespace <anonymous> | 87 } // namespace <anonymous> |
81 | 88 |
82 namespace content { | 89 namespace content { |
83 | 90 |
84 void InitSandboxedProcess(JNIEnv* env, | 91 void InitSandboxedProcess(JNIEnv* env, |
85 jclass clazz, | 92 jclass clazz, |
86 jobject context, | 93 jobject context, |
87 jobject service, | 94 jobject service, |
88 jintArray j_file_ids, | 95 jintArray j_file_ids, |
89 jintArray j_file_fds) { | 96 jintArray j_file_fds, |
97 jint cpuCount, | |
98 jlong cpuFeatures | |
99 ) { | |
bulach
2012/12/10 14:03:07
nit: nit: move this ) { one line up. also, hacker_
digit1
2012/12/10 14:44:56
Done.
| |
90 std::vector<int> file_ids; | 100 std::vector<int> file_ids; |
91 std::vector<int> file_fds; | 101 std::vector<int> file_fds; |
92 JavaIntArrayToIntVector(env, j_file_ids, &file_ids); | 102 JavaIntArrayToIntVector(env, j_file_ids, &file_ids); |
93 JavaIntArrayToIntVector(env, j_file_fds, &file_fds); | 103 JavaIntArrayToIntVector(env, j_file_fds, &file_fds); |
94 | 104 |
95 InternalInitSandboxedProcess( | 105 InternalInitSandboxedProcess( |
96 file_ids, file_fds, env, clazz, context, service); | 106 file_ids, file_fds, env, clazz, context, service, |
107 cpuCount, cpuFeatures); | |
97 } | 108 } |
98 | 109 |
99 void ExitSandboxedProcess(JNIEnv* env, jclass clazz) { | 110 void ExitSandboxedProcess(JNIEnv* env, jclass clazz) { |
100 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process."; | 111 LOG(INFO) << "SandboxedProcessService: Exiting sandboxed process."; |
101 LibraryLoaderExitHook(); | 112 LibraryLoaderExitHook(); |
102 _exit(0); | 113 _exit(0); |
103 } | 114 } |
104 | 115 |
105 bool RegisterSandboxedProcessService(JNIEnv* env) { | 116 bool RegisterSandboxedProcessService(JNIEnv* env) { |
106 return RegisterNativesImpl(env); | 117 return RegisterNativesImpl(env); |
107 } | 118 } |
108 | 119 |
109 void ShutdownSandboxMainThread(JNIEnv* env, jobject obj) { | 120 void ShutdownSandboxMainThread(JNIEnv* env, jobject obj) { |
110 ChildProcess* current_process = ChildProcess::current(); | 121 ChildProcess* current_process = ChildProcess::current(); |
111 if (!current_process) | 122 if (!current_process) |
112 return; | 123 return; |
113 ChildThread* main_child_thread = current_process->main_thread(); | 124 ChildThread* main_child_thread = current_process->main_thread(); |
114 if (main_child_thread && main_child_thread->message_loop()) | 125 if (main_child_thread && main_child_thread->message_loop()) |
115 main_child_thread->message_loop()->PostTask(FROM_HERE, | 126 main_child_thread->message_loop()->PostTask(FROM_HERE, |
116 base::Bind(&QuitSandboxMainThreadMessageLoop)); | 127 base::Bind(&QuitSandboxMainThreadMessageLoop)); |
117 } | 128 } |
118 | 129 |
119 } // namespace content | 130 } // namespace content |
OLD | NEW |