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