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 "components/nacl/browser/nacl_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // NOTE: changes to this class need to be reviewed by the security team. | 153 // NOTE: changes to this class need to be reviewed by the security team. |
154 class NaClSandboxedProcessLauncherDelegate | 154 class NaClSandboxedProcessLauncherDelegate |
155 : public content::SandboxedProcessLauncherDelegate { | 155 : public content::SandboxedProcessLauncherDelegate { |
156 public: | 156 public: |
157 NaClSandboxedProcessLauncherDelegate(ChildProcessHost* host) | 157 NaClSandboxedProcessLauncherDelegate(ChildProcessHost* host) |
158 #if defined(OS_POSIX) | 158 #if defined(OS_POSIX) |
159 : ipc_fd_(host->TakeClientFileDescriptor()) | 159 : ipc_fd_(host->TakeClientFileDescriptor()) |
160 #endif | 160 #endif |
161 {} | 161 {} |
162 | 162 |
163 virtual ~NaClSandboxedProcessLauncherDelegate() {} | 163 ~NaClSandboxedProcessLauncherDelegate() override {} |
164 | 164 |
165 #if defined(OS_WIN) | 165 #if defined(OS_WIN) |
166 virtual void PostSpawnTarget(base::ProcessHandle process) { | 166 virtual void PostSpawnTarget(base::ProcessHandle process) { |
167 // For Native Client sel_ldr processes on 32-bit Windows, reserve 1 GB of | 167 // For Native Client sel_ldr processes on 32-bit Windows, reserve 1 GB of |
168 // address space to prevent later failure due to address space fragmentation | 168 // address space to prevent later failure due to address space fragmentation |
169 // from .dll loading. The NaCl process will attempt to locate this space by | 169 // from .dll loading. The NaCl process will attempt to locate this space by |
170 // scanning the address space using VirtualQuery. | 170 // scanning the address space using VirtualQuery. |
171 // TODO(bbudge) Handle the --no-sandbox case. | 171 // TODO(bbudge) Handle the --no-sandbox case. |
172 // http://code.google.com/p/nativeclient/issues/detail?id=2131 | 172 // http://code.google.com/p/nativeclient/issues/detail?id=2131 |
173 const SIZE_T kNaClSandboxSize = 1 << 30; | 173 const SIZE_T kNaClSandboxSize = 1 << 30; |
174 if (!nacl::AllocateAddressSpaceASLR(process, kNaClSandboxSize)) { | 174 if (!nacl::AllocateAddressSpaceASLR(process, kNaClSandboxSize)) { |
175 DLOG(WARNING) << "Failed to reserve address space for Native Client"; | 175 DLOG(WARNING) << "Failed to reserve address space for Native Client"; |
176 } | 176 } |
177 } | 177 } |
178 #elif defined(OS_POSIX) | 178 #elif defined(OS_POSIX) |
179 virtual bool ShouldUseZygote() override { | 179 bool ShouldUseZygote() override { return true; } |
180 return true; | 180 base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } |
181 } | |
182 virtual base::ScopedFD TakeIpcFd() override { | |
183 return ipc_fd_.Pass(); | |
184 } | |
185 #endif // OS_WIN | 181 #endif // OS_WIN |
186 | 182 |
187 private: | 183 private: |
188 #if defined(OS_POSIX) | 184 #if defined(OS_POSIX) |
189 base::ScopedFD ipc_fd_; | 185 base::ScopedFD ipc_fd_; |
190 #endif // OS_POSIX | 186 #endif // OS_POSIX |
191 }; | 187 }; |
192 | 188 |
193 void SetCloseOnExec(NaClHandle fd) { | 189 void SetCloseOnExec(NaClHandle fd) { |
194 #if defined(OS_POSIX) | 190 #if defined(OS_POSIX) |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 process_handle.Take(), info, | 1190 process_handle.Take(), info, |
1195 base::MessageLoopProxy::current(), | 1191 base::MessageLoopProxy::current(), |
1196 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1192 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1197 weak_factory_.GetWeakPtr())); | 1193 weak_factory_.GetWeakPtr())); |
1198 return true; | 1194 return true; |
1199 } | 1195 } |
1200 } | 1196 } |
1201 #endif | 1197 #endif |
1202 | 1198 |
1203 } // namespace nacl | 1199 } // namespace nacl |
OLD | NEW |