| 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/common/child_process_host_impl.h" | 5 #include "content/common/child_process_host_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // intolerant of a non-executable heap to work properly on 10.7. This | 142 // intolerant of a non-executable heap to work properly on 10.7. This |
| 143 // results in Chromium Helper EH.app or Google Chrome Helper EH.app. | 143 // results in Chromium Helper EH.app or Google Chrome Helper EH.app. |
| 144 child_path = TransformPathForFeature(child_path, "EH"); | 144 child_path = TransformPathForFeature(child_path, "EH"); |
| 145 } | 145 } |
| 146 #endif | 146 #endif |
| 147 | 147 |
| 148 return child_path; | 148 return child_path; |
| 149 } | 149 } |
| 150 | 150 |
| 151 // static | 151 // static |
| 152 IPC::AttachmentBroker* ChildProcessHost::GetAttachmentBroker() { | 152 IPC::AttachmentBrokerPrivileged* ChildProcessHost::GetAttachmentBroker() { |
| 153 #if defined(OS_WIN) | 153 #if USE_ATTACHMENT_BROKER |
| 154 return &g_attachment_broker.Get(); | 154 return &g_attachment_broker.Get(); |
| 155 #else | 155 #else |
| 156 return nullptr; | 156 return nullptr; |
| 157 #endif // defined(OS_WIN) | 157 #endif // USE_ATTACHMENT_BROKER |
| 158 } | 158 } |
| 159 | 159 |
| 160 ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate) | 160 ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate) |
| 161 : delegate_(delegate), | 161 : delegate_(delegate), |
| 162 opening_channel_(false) { | 162 opening_channel_(false) { |
| 163 #if defined(OS_WIN) | 163 #if defined(OS_WIN) |
| 164 AddFilter(new FontCacheDispatcher()); | 164 AddFilter(new FontCacheDispatcher()); |
| 165 #endif | 165 #endif |
| 166 } | 166 } |
| 167 | 167 |
| 168 ChildProcessHostImpl::~ChildProcessHostImpl() { | 168 ChildProcessHostImpl::~ChildProcessHostImpl() { |
| 169 #if USE_ATTACHMENT_BROKER |
| 170 g_attachment_broker.Get().DeregisterCommunicationChannel(channel_.get()); |
| 171 #endif |
| 169 for (size_t i = 0; i < filters_.size(); ++i) { | 172 for (size_t i = 0; i < filters_.size(); ++i) { |
| 170 filters_[i]->OnChannelClosing(); | 173 filters_[i]->OnChannelClosing(); |
| 171 filters_[i]->OnFilterRemoved(); | 174 filters_[i]->OnFilterRemoved(); |
| 172 } | 175 } |
| 173 } | 176 } |
| 174 | 177 |
| 175 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) { | 178 void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) { |
| 176 filters_.push_back(filter); | 179 filters_.push_back(filter); |
| 177 | 180 |
| 178 if (channel_) | 181 if (channel_) |
| 179 filter->OnFilterAdded(channel_.get()); | 182 filter->OnFilterAdded(channel_.get()); |
| 180 } | 183 } |
| 181 | 184 |
| 182 void ChildProcessHostImpl::ForceShutdown() { | 185 void ChildProcessHostImpl::ForceShutdown() { |
| 183 Send(new ChildProcessMsg_Shutdown()); | 186 Send(new ChildProcessMsg_Shutdown()); |
| 184 } | 187 } |
| 185 | 188 |
| 186 std::string ChildProcessHostImpl::CreateChannel() { | 189 std::string ChildProcessHostImpl::CreateChannel() { |
| 187 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string()); | 190 channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string()); |
| 188 channel_ = | 191 channel_ = |
| 189 IPC::Channel::CreateServer(channel_id_, this, GetAttachmentBroker()); | 192 IPC::Channel::CreateServer(channel_id_, this, GetAttachmentBroker()); |
| 190 if (!channel_->Connect()) | 193 if (!channel_->Connect()) |
| 191 return std::string(); | 194 return std::string(); |
| 195 #if USE_ATTACHMENT_BROKER |
| 196 g_attachment_broker.Get().RegisterCommunicationChannel(channel_.get()); |
| 197 #endif |
| 192 | 198 |
| 193 for (size_t i = 0; i < filters_.size(); ++i) | 199 for (size_t i = 0; i < filters_.size(); ++i) |
| 194 filters_[i]->OnFilterAdded(channel_.get()); | 200 filters_[i]->OnFilterAdded(channel_.get()); |
| 195 | 201 |
| 196 // Make sure these messages get sent first. | 202 // Make sure these messages get sent first. |
| 197 #if defined(IPC_MESSAGE_LOG_ENABLED) | 203 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 198 bool enabled = IPC::Logging::GetInstance()->Enabled(); | 204 bool enabled = IPC::Logging::GetInstance()->Enabled(); |
| 199 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); | 205 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); |
| 200 #endif | 206 #endif |
| 201 | 207 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 377 } |
| 372 | 378 |
| 373 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( | 379 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( |
| 374 gfx::GpuMemoryBufferId id, | 380 gfx::GpuMemoryBufferId id, |
| 375 uint32 sync_point) { | 381 uint32 sync_point) { |
| 376 // Note: Nothing to do here as ownership of shared memory backed | 382 // Note: Nothing to do here as ownership of shared memory backed |
| 377 // GpuMemoryBuffers is passed with IPC. | 383 // GpuMemoryBuffers is passed with IPC. |
| 378 } | 384 } |
| 379 | 385 |
| 380 } // namespace content | 386 } // namespace content |
| OLD | NEW |