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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 class ChildProcessHostDelegate; | 31 class ChildProcessHostDelegate; |
32 | 32 |
33 // Provides common functionality for hosting a child process and processing IPC | 33 // Provides common functionality for hosting a child process and processing IPC |
34 // messages between the host and the child process. Users are responsible | 34 // messages between the host and the child process. Users are responsible |
35 // for the actual launching and terminating of the child processes. | 35 // for the actual launching and terminating of the child processes. |
36 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost, | 36 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost, |
37 public IPC::Listener { | 37 public IPC::Listener { |
38 public: | 38 public: |
39 virtual ~ChildProcessHostImpl(); | 39 ~ChildProcessHostImpl() override; |
40 | 40 |
41 // Public and static for reuse by RenderMessageFilter. | 41 // Public and static for reuse by RenderMessageFilter. |
42 static void AllocateSharedMemory( | 42 static void AllocateSharedMemory( |
43 size_t buffer_size, base::ProcessHandle child_process, | 43 size_t buffer_size, base::ProcessHandle child_process, |
44 base::SharedMemoryHandle* handle); | 44 base::SharedMemoryHandle* handle); |
45 | 45 |
46 // Returns a unique ID to identify a child process. On construction, this | 46 // Returns a unique ID to identify a child process. On construction, this |
47 // function will be used to generate the id_, but it is also used to generate | 47 // function will be used to generate the id_, but it is also used to generate |
48 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs | 48 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs |
49 // must be unique for all child processes. | 49 // must be unique for all child processes. |
50 // | 50 // |
51 // This function is threadsafe since RenderProcessHost is on the UI thread, | 51 // This function is threadsafe since RenderProcessHost is on the UI thread, |
52 // but normally this will be used on the IO thread. | 52 // but normally this will be used on the IO thread. |
53 // | 53 // |
54 // This will never return ChildProcessHost::kInvalidUniqueID. | 54 // This will never return ChildProcessHost::kInvalidUniqueID. |
55 static int GenerateChildProcessUniqueId(); | 55 static int GenerateChildProcessUniqueId(); |
56 | 56 |
57 // ChildProcessHost implementation | 57 // ChildProcessHost implementation |
58 virtual bool Send(IPC::Message* message) override; | 58 bool Send(IPC::Message* message) override; |
59 virtual void ForceShutdown() override; | 59 void ForceShutdown() override; |
60 virtual std::string CreateChannel() override; | 60 std::string CreateChannel() override; |
61 virtual bool IsChannelOpening() override; | 61 bool IsChannelOpening() override; |
62 virtual void AddFilter(IPC::MessageFilter* filter) override; | 62 void AddFilter(IPC::MessageFilter* filter) override; |
63 #if defined(OS_POSIX) | 63 #if defined(OS_POSIX) |
64 virtual base::ScopedFD TakeClientFileDescriptor() override; | 64 base::ScopedFD TakeClientFileDescriptor() override; |
65 #endif | 65 #endif |
66 | 66 |
67 private: | 67 private: |
68 friend class ChildProcessHost; | 68 friend class ChildProcessHost; |
69 | 69 |
70 explicit ChildProcessHostImpl(ChildProcessHostDelegate* delegate); | 70 explicit ChildProcessHostImpl(ChildProcessHostDelegate* delegate); |
71 | 71 |
72 // IPC::Listener methods: | 72 // IPC::Listener methods: |
73 virtual bool OnMessageReceived(const IPC::Message& msg) override; | 73 bool OnMessageReceived(const IPC::Message& msg) override; |
74 virtual void OnChannelConnected(int32 peer_pid) override; | 74 void OnChannelConnected(int32 peer_pid) override; |
75 virtual void OnChannelError() override; | 75 void OnChannelError() override; |
76 virtual void OnBadMessageReceived(const IPC::Message& message) override; | 76 void OnBadMessageReceived(const IPC::Message& message) override; |
77 | 77 |
78 // Message handlers: | 78 // Message handlers: |
79 void OnShutdownRequest(); | 79 void OnShutdownRequest(); |
80 void OnAllocateSharedMemory(uint32 buffer_size, | 80 void OnAllocateSharedMemory(uint32 buffer_size, |
81 base::SharedMemoryHandle* handle); | 81 base::SharedMemoryHandle* handle); |
82 void OnAllocateGpuMemoryBuffer(uint32 width, | 82 void OnAllocateGpuMemoryBuffer(uint32 width, |
83 uint32 height, | 83 uint32 height, |
84 gfx::GpuMemoryBuffer::Format format, | 84 gfx::GpuMemoryBuffer::Format format, |
85 gfx::GpuMemoryBuffer::Usage usage, | 85 gfx::GpuMemoryBuffer::Usage usage, |
86 IPC::Message* reply); | 86 IPC::Message* reply); |
(...skipping 13 matching lines...) Expand all Loading... |
100 // thread, we don't have a IPC::ChannelProxy and so we manage filters | 100 // thread, we don't have a IPC::ChannelProxy and so we manage filters |
101 // manually. | 101 // manually. |
102 std::vector<scoped_refptr<IPC::MessageFilter> > filters_; | 102 std::vector<scoped_refptr<IPC::MessageFilter> > filters_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl); | 104 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl); |
105 }; | 105 }; |
106 | 106 |
107 } // namespace content | 107 } // namespace content |
108 | 108 |
109 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ | 109 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ |
OLD | NEW |