Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: content/common/child_process_host_impl.cc

Issue 2478343002: Removing the ChildProcessHostMsg_SyncAllocateSharedMemory IPC message. (Closed)
Patch Set: Synced Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 bool ChildProcessHostImpl::Send(IPC::Message* message) { 180 bool ChildProcessHostImpl::Send(IPC::Message* message) {
181 if (!channel_) { 181 if (!channel_) {
182 delete message; 182 delete message;
183 return false; 183 return false;
184 } 184 }
185 return channel_->Send(message); 185 return channel_->Send(message);
186 } 186 }
187 187
188 void ChildProcessHostImpl::AllocateSharedMemory(
189 size_t buffer_size, base::ProcessHandle child_process_handle,
190 base::SharedMemoryHandle* shared_memory_handle) {
191 base::SharedMemory shared_buf;
192 if (!shared_buf.CreateAnonymous(buffer_size)) {
193 *shared_memory_handle = base::SharedMemory::NULLHandle();
194 NOTREACHED() << "Cannot create shared memory buffer";
195 return;
196 }
197 shared_buf.GiveToProcess(child_process_handle, shared_memory_handle);
198 }
199
200 int ChildProcessHostImpl::GenerateChildProcessUniqueId() { 188 int ChildProcessHostImpl::GenerateChildProcessUniqueId() {
201 // This function must be threadsafe. 189 // This function must be threadsafe.
202 // 190 //
203 // Historically, this function returned ids started with 1, so in several 191 // Historically, this function returned ids started with 1, so in several
204 // places in the code a value of 0 (rather than kInvalidUniqueID) was used as 192 // places in the code a value of 0 (rather than kInvalidUniqueID) was used as
205 // an invalid value. So we retain those semantics. 193 // an invalid value. So we retain those semantics.
206 int id = g_unique_id.GetNext() + 1; 194 int id = g_unique_id.GetNext() + 1;
207 195
208 CHECK_NE(0, id); 196 CHECK_NE(0, id);
209 CHECK_NE(kInvalidUniqueID, id); 197 CHECK_NE(kInvalidUniqueID, id);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 handled = true; 236 handled = true;
249 break; 237 break;
250 } 238 }
251 } 239 }
252 240
253 if (!handled) { 241 if (!handled) {
254 handled = true; 242 handled = true;
255 IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg) 243 IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg)
256 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, 244 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
257 OnShutdownRequest) 245 OnShutdownRequest)
258 // NB: The SyncAllocateSharedMemory, SyncAllocateGpuMemoryBuffer, and 246 // NB: The SyncAllocateGpuMemoryBuffer and DeletedGpuMemoryBuffer IPCs are
259 // DeletedGpuMemoryBuffer IPCs are handled here for non-renderer child 247 // handled here for non-renderer child processes. For renderer processes,
260 // processes. For renderer processes, they are handled in 248 // they are handled in RenderMessageFilter.
261 // RenderMessageFilter.
262 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
263 OnAllocateSharedMemory)
264 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, 249 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
265 OnAllocateGpuMemoryBuffer) 250 OnAllocateGpuMemoryBuffer)
266 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer, 251 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer,
267 OnDeletedGpuMemoryBuffer) 252 OnDeletedGpuMemoryBuffer)
268 IPC_MESSAGE_UNHANDLED(handled = false) 253 IPC_MESSAGE_UNHANDLED(handled = false)
269 IPC_END_MESSAGE_MAP() 254 IPC_END_MESSAGE_MAP()
270 255
271 if (!handled) 256 if (!handled)
272 handled = delegate_->OnMessageReceived(msg); 257 handled = delegate_->OnMessageReceived(msg);
273 } 258 }
(...skipping 26 matching lines...) Expand all
300 filters_[i]->OnChannelError(); 285 filters_[i]->OnChannelError();
301 286
302 // This will delete host_, which will also destroy this! 287 // This will delete host_, which will also destroy this!
303 delegate_->OnChildDisconnected(); 288 delegate_->OnChildDisconnected();
304 } 289 }
305 290
306 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { 291 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) {
307 delegate_->OnBadMessageReceived(message); 292 delegate_->OnBadMessageReceived(message);
308 } 293 }
309 294
310 void ChildProcessHostImpl::OnAllocateSharedMemory(
311 uint32_t buffer_size,
312 base::SharedMemoryHandle* handle) {
313 AllocateSharedMemory(buffer_size, peer_process_.Handle(), handle);
314 }
315
316 void ChildProcessHostImpl::OnShutdownRequest() { 295 void ChildProcessHostImpl::OnShutdownRequest() {
317 if (delegate_->CanShutdown()) 296 if (delegate_->CanShutdown())
318 Send(new ChildProcessMsg_Shutdown()); 297 Send(new ChildProcessMsg_Shutdown());
319 } 298 }
320 299
321 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer( 300 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer(
322 gfx::GpuMemoryBufferId id, 301 gfx::GpuMemoryBufferId id,
323 uint32_t width, 302 uint32_t width,
324 uint32_t height, 303 uint32_t height,
325 gfx::BufferFormat format, 304 gfx::BufferFormat format,
(...skipping 11 matching lines...) Expand all
337 } 316 }
338 317
339 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( 318 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer(
340 gfx::GpuMemoryBufferId id, 319 gfx::GpuMemoryBufferId id,
341 const gpu::SyncToken& sync_token) { 320 const gpu::SyncToken& sync_token) {
342 // Note: Nothing to do here as ownership of shared memory backed 321 // Note: Nothing to do here as ownership of shared memory backed
343 // GpuMemoryBuffers is passed with IPC. 322 // GpuMemoryBuffers is passed with IPC.
344 } 323 }
345 324
346 } // namespace content 325 } // namespace content
OLDNEW
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698