| 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/browser_child_process_host_impl.h" | 5 #include "content/browser/browser_child_process_host_impl.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // list. | 121 // list. |
| 122 BrowserChildProcessList copy = g_child_process_list.Get(); | 122 BrowserChildProcessList copy = g_child_process_list.Get(); |
| 123 for (BrowserChildProcessList::iterator it = copy.begin(); | 123 for (BrowserChildProcessList::iterator it = copy.begin(); |
| 124 it != copy.end(); ++it) { | 124 it != copy.end(); ++it) { |
| 125 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl. | 125 delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl. |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 void BrowserChildProcessHostImpl::Launch( | 129 void BrowserChildProcessHostImpl::Launch( |
| 130 SandboxedProcessLauncherDelegate* delegate, | 130 SandboxedProcessLauncherDelegate* delegate, |
| 131 base::CommandLine* cmd_line) { | 131 base::CommandLine* cmd_line, |
| 132 bool terminate_on_shutdown) { |
| 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 133 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 133 | 134 |
| 134 GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 135 GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
| 135 cmd_line, data_.id); | 136 cmd_line, data_.id); |
| 136 | 137 |
| 137 const base::CommandLine& browser_command_line = | 138 const base::CommandLine& browser_command_line = |
| 138 *base::CommandLine::ForCurrentProcess(); | 139 *base::CommandLine::ForCurrentProcess(); |
| 139 static const char* kForwardSwitches[] = { | 140 static const char* kForwardSwitches[] = { |
| 140 switches::kDisableLogging, | 141 switches::kDisableLogging, |
| 141 switches::kEnableLogging, | 142 switches::kEnableLogging, |
| 142 switches::kIPCConnectionTimeout, | 143 switches::kIPCConnectionTimeout, |
| 143 switches::kLoggingLevel, | 144 switches::kLoggingLevel, |
| 144 switches::kTraceToConsole, | 145 switches::kTraceToConsole, |
| 145 switches::kV, | 146 switches::kV, |
| 146 switches::kVModule, | 147 switches::kVModule, |
| 147 }; | 148 }; |
| 148 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, | 149 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, |
| 149 arraysize(kForwardSwitches)); | 150 arraysize(kForwardSwitches)); |
| 150 | 151 |
| 151 child_process_.reset(new ChildProcessLauncher( | 152 child_process_.reset(new ChildProcessLauncher( |
| 152 delegate, | 153 delegate, |
| 153 cmd_line, | 154 cmd_line, |
| 154 data_.id, | 155 data_.id, |
| 155 this)); | 156 this, |
| 157 terminate_on_shutdown)); |
| 156 } | 158 } |
| 157 | 159 |
| 158 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const { | 160 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const { |
| 159 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 161 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 160 return data_; | 162 return data_; |
| 161 } | 163 } |
| 162 | 164 |
| 163 ChildProcessHost* BrowserChildProcessHostImpl::GetHost() const { | 165 ChildProcessHost* BrowserChildProcessHostImpl::GetHost() const { |
| 164 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 166 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 165 return child_process_host_.get(); | 167 return child_process_host_.get(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 187 void BrowserChildProcessHostImpl::ForceShutdown() { | 189 void BrowserChildProcessHostImpl::ForceShutdown() { |
| 188 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 190 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 189 g_child_process_list.Get().remove(this); | 191 g_child_process_list.Get().remove(this); |
| 190 child_process_host_->ForceShutdown(); | 192 child_process_host_->ForceShutdown(); |
| 191 } | 193 } |
| 192 | 194 |
| 193 void BrowserChildProcessHostImpl::SetBackgrounded(bool backgrounded) { | 195 void BrowserChildProcessHostImpl::SetBackgrounded(bool backgrounded) { |
| 194 child_process_->SetProcessBackgrounded(backgrounded); | 196 child_process_->SetProcessBackgrounded(backgrounded); |
| 195 } | 197 } |
| 196 | 198 |
| 197 void BrowserChildProcessHostImpl::SetTerminateChildOnShutdown( | |
| 198 bool terminate_on_shutdown) { | |
| 199 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 200 child_process_->SetTerminateChildOnShutdown(terminate_on_shutdown); | |
| 201 } | |
| 202 | |
| 203 void BrowserChildProcessHostImpl::AddFilter(BrowserMessageFilter* filter) { | 199 void BrowserChildProcessHostImpl::AddFilter(BrowserMessageFilter* filter) { |
| 204 child_process_host_->AddFilter(filter->GetFilter()); | 200 child_process_host_->AddFilter(filter->GetFilter()); |
| 205 } | 201 } |
| 206 | 202 |
| 207 void BrowserChildProcessHostImpl::NotifyProcessInstanceCreated( | 203 void BrowserChildProcessHostImpl::NotifyProcessInstanceCreated( |
| 208 const ChildProcessData& data) { | 204 const ChildProcessData& data) { |
| 209 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 205 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 210 FOR_EACH_OBSERVER(BrowserChildProcessObserver, g_observers.Get(), | 206 FOR_EACH_OBSERVER(BrowserChildProcessObserver, g_observers.Get(), |
| 211 BrowserChildProcessInstanceCreated(data)); | 207 BrowserChildProcessInstanceCreated(data)); |
| 212 } | 208 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 342 |
| 347 #if defined(OS_WIN) | 343 #if defined(OS_WIN) |
| 348 | 344 |
| 349 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { | 345 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { |
| 350 OnChildDisconnected(); | 346 OnChildDisconnected(); |
| 351 } | 347 } |
| 352 | 348 |
| 353 #endif | 349 #endif |
| 354 | 350 |
| 355 } // namespace content | 351 } // namespace content |
| OLD | NEW |