| 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/browser/utility_process_host_impl.h" | 5 #include "content/browser/utility_process_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "content/public/browser/zygote_handle_linux.h" | 47 #include "content/public/browser/zygote_handle_linux.h" |
| 48 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 48 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 49 | 49 |
| 50 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 51 #include "sandbox/win/src/sandbox_policy.h" | 51 #include "sandbox/win/src/sandbox_policy.h" |
| 52 #include "sandbox/win/src/sandbox_types.h" | 52 #include "sandbox/win/src/sandbox_types.h" |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 namespace content { | 55 namespace content { |
| 56 | 56 |
| 57 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
| 58 namespace { | |
| 59 ZygoteHandle g_utility_zygote; | |
| 60 } // namespace | |
| 61 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
| 62 | |
| 63 // NOTE: changes to this class need to be reviewed by the security team. | 57 // NOTE: changes to this class need to be reviewed by the security team. |
| 64 class UtilitySandboxedProcessLauncherDelegate | 58 class UtilitySandboxedProcessLauncherDelegate |
| 65 : public SandboxedProcessLauncherDelegate { | 59 : public SandboxedProcessLauncherDelegate { |
| 66 public: | 60 public: |
| 67 UtilitySandboxedProcessLauncherDelegate(const base::FilePath& exposed_dir, | 61 UtilitySandboxedProcessLauncherDelegate(const base::FilePath& exposed_dir, |
| 68 bool launch_elevated, | 62 bool launch_elevated, |
| 69 bool no_sandbox, | 63 bool no_sandbox, |
| 70 const base::EnvironmentMap& env) | 64 const base::EnvironmentMap& env) |
| 71 : exposed_dir_(exposed_dir), | 65 : exposed_dir_(exposed_dir), |
| 72 #if defined(OS_WIN) | 66 #if defined(OS_WIN) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 const std::string& interface_name, | 224 const std::string& interface_name, |
| 231 mojo::ScopedMessagePipeHandle interface_pipe) { | 225 mojo::ScopedMessagePipeHandle interface_pipe) { |
| 232 process_->child_connection()->BindInterface(interface_name, | 226 process_->child_connection()->BindInterface(interface_name, |
| 233 std::move(interface_pipe)); | 227 std::move(interface_pipe)); |
| 234 } | 228 } |
| 235 | 229 |
| 236 void UtilityProcessHostImpl::SetName(const base::string16& name) { | 230 void UtilityProcessHostImpl::SetName(const base::string16& name) { |
| 237 name_ = name; | 231 name_ = name; |
| 238 } | 232 } |
| 239 | 233 |
| 240 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
| 241 // static | |
| 242 void UtilityProcessHostImpl::EarlyZygoteLaunch() { | |
| 243 DCHECK(!g_utility_zygote); | |
| 244 g_utility_zygote = CreateZygote(); | |
| 245 } | |
| 246 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
| 247 | |
| 248 bool UtilityProcessHostImpl::StartProcess() { | 234 bool UtilityProcessHostImpl::StartProcess() { |
| 249 if (started_) | 235 if (started_) |
| 250 return true; | 236 return true; |
| 251 started_ = true; | 237 started_ = true; |
| 252 | 238 |
| 253 if (is_batch_mode_) | 239 if (is_batch_mode_) |
| 254 return true; | 240 return true; |
| 255 | 241 |
| 256 process_->SetName(name_); | 242 process_->SetName(name_); |
| 257 process_->GetHost()->CreateChannelMojo(); | 243 process_->GetHost()->CreateChannelMojo(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 base::WeakPtr<UtilityProcessHostImpl> host, | 389 base::WeakPtr<UtilityProcessHostImpl> host, |
| 404 int error_code) { | 390 int error_code) { |
| 405 if (!host) | 391 if (!host) |
| 406 return; | 392 return; |
| 407 | 393 |
| 408 host->OnProcessLaunchFailed(error_code); | 394 host->OnProcessLaunchFailed(error_code); |
| 409 delete host.get(); | 395 delete host.get(); |
| 410 } | 396 } |
| 411 | 397 |
| 412 } // namespace content | 398 } // namespace content |
| OLD | NEW |