| 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 #ifndef CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ | 5 #ifndef CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ |
| 6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ | 6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class ChildProcessHostDelegate; | 34 class ChildProcessHostDelegate; |
| 35 | 35 |
| 36 // Provides common functionality for hosting a child process and processing IPC | 36 // Provides common functionality for hosting a child process and processing IPC |
| 37 // messages between the host and the child process. Users are responsible | 37 // messages between the host and the child process. Users are responsible |
| 38 // for the actual launching and terminating of the child processes. | 38 // for the actual launching and terminating of the child processes. |
| 39 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost, | 39 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost, |
| 40 public IPC::Listener { | 40 public IPC::Listener { |
| 41 public: | 41 public: |
| 42 ~ChildProcessHostImpl() override; | 42 ~ChildProcessHostImpl() override; |
| 43 | 43 |
| 44 // Public and static for reuse by RenderMessageFilter. |
| 45 static void AllocateSharedMemory( |
| 46 size_t buffer_size, base::ProcessHandle child_process, |
| 47 base::SharedMemoryHandle* handle); |
| 48 |
| 44 // Returns a unique ID to identify a child process. On construction, this | 49 // Returns a unique ID to identify a child process. On construction, this |
| 45 // function will be used to generate the id_, but it is also used to generate | 50 // function will be used to generate the id_, but it is also used to generate |
| 46 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs | 51 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs |
| 47 // must be unique for all child processes. | 52 // must be unique for all child processes. |
| 48 // | 53 // |
| 49 // This function is threadsafe since RenderProcessHost is on the UI thread, | 54 // This function is threadsafe since RenderProcessHost is on the UI thread, |
| 50 // but normally this will be used on the IO thread. | 55 // but normally this will be used on the IO thread. |
| 51 // | 56 // |
| 52 // This will never return ChildProcessHost::kInvalidUniqueID. | 57 // This will never return ChildProcessHost::kInvalidUniqueID. |
| 53 static int GenerateChildProcessUniqueId(); | 58 static int GenerateChildProcessUniqueId(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 81 explicit ChildProcessHostImpl(ChildProcessHostDelegate* delegate); | 86 explicit ChildProcessHostImpl(ChildProcessHostDelegate* delegate); |
| 82 | 87 |
| 83 // IPC::Listener methods: | 88 // IPC::Listener methods: |
| 84 bool OnMessageReceived(const IPC::Message& msg) override; | 89 bool OnMessageReceived(const IPC::Message& msg) override; |
| 85 void OnChannelConnected(int32_t peer_pid) override; | 90 void OnChannelConnected(int32_t peer_pid) override; |
| 86 void OnChannelError() override; | 91 void OnChannelError() override; |
| 87 void OnBadMessageReceived(const IPC::Message& message) override; | 92 void OnBadMessageReceived(const IPC::Message& message) override; |
| 88 | 93 |
| 89 // Message handlers: | 94 // Message handlers: |
| 90 void OnShutdownRequest(); | 95 void OnShutdownRequest(); |
| 96 void OnAllocateSharedMemory(uint32_t buffer_size, |
| 97 base::SharedMemoryHandle* handle); |
| 91 void OnAllocateGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 98 void OnAllocateGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 92 uint32_t width, | 99 uint32_t width, |
| 93 uint32_t height, | 100 uint32_t height, |
| 94 gfx::BufferFormat format, | 101 gfx::BufferFormat format, |
| 95 gfx::BufferUsage usage, | 102 gfx::BufferUsage usage, |
| 96 gfx::GpuMemoryBufferHandle* handle); | 103 gfx::GpuMemoryBufferHandle* handle); |
| 97 void OnDeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 104 void OnDeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 98 const gpu::SyncToken& sync_token); | 105 const gpu::SyncToken& sync_token); |
| 99 | 106 |
| 100 // Initializes the IPC channel and returns true on success. |channel_| must be | 107 // Initializes the IPC channel and returns true on success. |channel_| must be |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 // thread, we don't have a IPC::ChannelProxy and so we manage filters | 118 // thread, we don't have a IPC::ChannelProxy and so we manage filters |
| 112 // manually. | 119 // manually. |
| 113 std::vector<scoped_refptr<IPC::MessageFilter> > filters_; | 120 std::vector<scoped_refptr<IPC::MessageFilter> > filters_; |
| 114 | 121 |
| 115 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl); | 122 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl); |
| 116 }; | 123 }; |
| 117 | 124 |
| 118 } // namespace content | 125 } // namespace content |
| 119 | 126 |
| 120 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ | 127 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ |
| OLD | NEW |