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::GetTaskRunnerForThread(BrowserThread::IO))); |
178 } | 178 } |
179 | 179 |
180 UtilityProcessHostImpl::~UtilityProcessHostImpl() { | 180 UtilityProcessHostImpl::~UtilityProcessHostImpl() { |
181 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 181 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
182 if (is_batch_mode_) | 182 if (is_batch_mode_) |
183 EndBatchMode(); | 183 EndBatchMode(); |
184 } | 184 } |
185 | 185 |
186 base::WeakPtr<UtilityProcessHost> UtilityProcessHostImpl::AsWeakPtr() { | 186 base::WeakPtr<UtilityProcessHost> UtilityProcessHostImpl::AsWeakPtr() { |
187 return weak_ptr_factory_.GetWeakPtr(); | 187 return weak_ptr_factory_.GetWeakPtr(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 env_ = env; | 232 env_ = env; |
233 } | 233 } |
234 | 234 |
235 #endif // OS_POSIX | 235 #endif // OS_POSIX |
236 | 236 |
237 bool UtilityProcessHostImpl::Start() { | 237 bool UtilityProcessHostImpl::Start() { |
238 return StartProcess(); | 238 return StartProcess(); |
239 } | 239 } |
240 | 240 |
241 shell::InterfaceRegistry* UtilityProcessHostImpl::GetInterfaceRegistry() { | 241 shell::InterfaceRegistry* UtilityProcessHostImpl::GetInterfaceRegistry() { |
242 return mojo_child_connection_->connection()->GetInterfaceRegistry(); | 242 return mojo_child_connection_->GetInterfaceRegistry(); |
243 } | 243 } |
244 | 244 |
245 shell::InterfaceProvider* UtilityProcessHostImpl::GetRemoteInterfaces() { | 245 shell::InterfaceProvider* UtilityProcessHostImpl::GetRemoteInterfaces() { |
246 return mojo_child_connection_->connection()->GetRemoteInterfaces(); | 246 return mojo_child_connection_->GetRemoteInterfaces(); |
247 } | 247 } |
248 | 248 |
249 void UtilityProcessHostImpl::SetName(const base::string16& name) { | 249 void UtilityProcessHostImpl::SetName(const base::string16& name) { |
250 name_ = name; | 250 name_ = name; |
251 } | 251 } |
252 | 252 |
253 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 253 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
254 // static | 254 // static |
255 void UtilityProcessHostImpl::EarlyZygoteLaunch() { | 255 void UtilityProcessHostImpl::EarlyZygoteLaunch() { |
256 DCHECK(!g_utility_zygote); | 256 DCHECK(!g_utility_zygote); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 base::WeakPtr<UtilityProcessHostImpl> host, | 424 base::WeakPtr<UtilityProcessHostImpl> host, |
425 int error_code) { | 425 int error_code) { |
426 if (!host) | 426 if (!host) |
427 return; | 427 return; |
428 | 428 |
429 host->OnProcessLaunchFailed(error_code); | 429 host->OnProcessLaunchFailed(error_code); |
430 delete host.get(); | 430 delete host.get(); |
431 } | 431 } |
432 | 432 |
433 } // namespace content | 433 } // namespace content |
OLD | NEW |