| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 child_flags_(ChildProcessHost::CHILD_NORMAL), | 165 child_flags_(ChildProcessHost::CHILD_NORMAL), |
| 166 #endif | 166 #endif |
| 167 started_(false), | 167 started_(false), |
| 168 name_(base::ASCIIToUTF16("utility process")), | 168 name_(base::ASCIIToUTF16("utility process")), |
| 169 child_token_(mojo::edk::GenerateRandomToken()), | 169 child_token_(mojo::edk::GenerateRandomToken()), |
| 170 weak_ptr_factory_(this) { | 170 weak_ptr_factory_(this) { |
| 171 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this, | 171 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this, |
| 172 child_token_)); | 172 child_token_)); |
| 173 mojo_child_connection_.reset(new MojoChildConnection( | 173 mojo_child_connection_.reset(new MojoChildConnection( |
| 174 kUtilityMojoApplicationName, | 174 kUtilityMojoApplicationName, |
| 175 base::StringPrintf("%d_0", process_->GetData().id), | 175 base::StringPrintf("%d_0", process_->GetData().id), child_token_, |
| 176 child_token_, | 176 MojoShellContext::GetConnectorForIOThread(), |
| 177 MojoShellContext::GetConnectorForIOThread())); | 177 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
| 178 ->task_runner())); |
| 178 } | 179 } |
| 179 | 180 |
| 180 UtilityProcessHostImpl::~UtilityProcessHostImpl() { | 181 UtilityProcessHostImpl::~UtilityProcessHostImpl() { |
| 181 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 182 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 182 if (is_batch_mode_) | 183 if (is_batch_mode_) |
| 183 EndBatchMode(); | 184 EndBatchMode(); |
| 184 } | 185 } |
| 185 | 186 |
| 186 base::WeakPtr<UtilityProcessHost> UtilityProcessHostImpl::AsWeakPtr() { | 187 base::WeakPtr<UtilityProcessHost> UtilityProcessHostImpl::AsWeakPtr() { |
| 187 return weak_ptr_factory_.GetWeakPtr(); | 188 return weak_ptr_factory_.GetWeakPtr(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 env_ = env; | 233 env_ = env; |
| 233 } | 234 } |
| 234 | 235 |
| 235 #endif // OS_POSIX | 236 #endif // OS_POSIX |
| 236 | 237 |
| 237 bool UtilityProcessHostImpl::Start() { | 238 bool UtilityProcessHostImpl::Start() { |
| 238 return StartProcess(); | 239 return StartProcess(); |
| 239 } | 240 } |
| 240 | 241 |
| 241 shell::InterfaceRegistry* UtilityProcessHostImpl::GetInterfaceRegistry() { | 242 shell::InterfaceRegistry* UtilityProcessHostImpl::GetInterfaceRegistry() { |
| 242 return mojo_child_connection_->connection()->GetInterfaceRegistry(); | 243 return mojo_child_connection_->GetInterfaceRegistry(); |
| 243 } | 244 } |
| 244 | 245 |
| 245 shell::InterfaceProvider* UtilityProcessHostImpl::GetRemoteInterfaces() { | 246 shell::InterfaceProvider* UtilityProcessHostImpl::GetRemoteInterfaces() { |
| 246 return mojo_child_connection_->connection()->GetRemoteInterfaces(); | 247 return mojo_child_connection_->GetRemoteInterfaces(); |
| 247 } | 248 } |
| 248 | 249 |
| 249 void UtilityProcessHostImpl::SetName(const base::string16& name) { | 250 void UtilityProcessHostImpl::SetName(const base::string16& name) { |
| 250 name_ = name; | 251 name_ = name; |
| 251 } | 252 } |
| 252 | 253 |
| 253 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 254 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
| 254 // static | 255 // static |
| 255 void UtilityProcessHostImpl::EarlyZygoteLaunch() { | 256 void UtilityProcessHostImpl::EarlyZygoteLaunch() { |
| 256 DCHECK(!g_utility_zygote); | 257 DCHECK(!g_utility_zygote); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 base::WeakPtr<UtilityProcessHostImpl> host, | 425 base::WeakPtr<UtilityProcessHostImpl> host, |
| 425 int error_code) { | 426 int error_code) { |
| 426 if (!host) | 427 if (!host) |
| 427 return; | 428 return; |
| 428 | 429 |
| 429 host->OnProcessLaunchFailed(error_code); | 430 host->OnProcessLaunchFailed(error_code); |
| 430 delete host.get(); | 431 delete host.get(); |
| 431 } | 432 } |
| 432 | 433 |
| 433 } // namespace content | 434 } // namespace content |
| OLD | NEW |