OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CONTENT_COMMON_CHILD_PROCESS_HOST_H_ |
6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_H_ | 6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 virtual bool Send(IPC::Message* message) OVERRIDE; | 84 virtual bool Send(IPC::Message* message) OVERRIDE; |
85 | 85 |
86 // Adds an IPC message filter. A reference will be kept to the filter. | 86 // Adds an IPC message filter. A reference will be kept to the filter. |
87 void AddFilter(IPC::ChannelProxy::MessageFilter* filter); | 87 void AddFilter(IPC::ChannelProxy::MessageFilter* filter); |
88 | 88 |
89 // Public and static for reuse by RenderMessageFilter. | 89 // Public and static for reuse by RenderMessageFilter. |
90 static void OnAllocateSharedMemory( | 90 static void OnAllocateSharedMemory( |
91 uint32 buffer_size, base::ProcessHandle child_process, | 91 uint32 buffer_size, base::ProcessHandle child_process, |
92 base::SharedMemoryHandle* handle); | 92 base::SharedMemoryHandle* handle); |
93 | 93 |
| 94 // Generates a unique channel name for a child process. |
| 95 // The "instance" pointer value is baked into the channel id. |
| 96 static std::string GenerateRandomChannelID(void* instance); |
| 97 |
| 98 // Returns a unique ID to identify a child process. On construction, this |
| 99 // function will be used to generate the id_, but it is also used to generate |
| 100 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs |
| 101 // must be unique for all child processes. |
| 102 // |
| 103 // This function is threadsafe since RenderProcessHost is on the UI thread, |
| 104 // but normally this will be used on the IO thread. |
| 105 static int GenerateChildProcessUniqueId(); |
| 106 |
94 protected: | 107 protected: |
95 ChildProcessHost(); | 108 ChildProcessHost(); |
96 | 109 |
97 // Derived classes return true if it's ok to shut down the child process. | 110 // Derived classes return true if it's ok to shut down the child process. |
98 virtual bool CanShutdown() = 0; | 111 virtual bool CanShutdown() = 0; |
99 | 112 |
100 // Send the shutdown message to the child process. | 113 // Send the shutdown message to the child process. |
101 // Does not check if CanShutdown is true. | 114 // Does not check if CanShutdown is true. |
102 virtual void ForceShutdown(); | 115 virtual void ForceShutdown(); |
103 | 116 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 172 |
160 // Holds all the IPC message filters. Since this object lives on the IO | 173 // Holds all the IPC message filters. Since this object lives on the IO |
161 // thread, we don't have a IPC::ChannelProxy and so we manage filters | 174 // thread, we don't have a IPC::ChannelProxy and so we manage filters |
162 // manually. | 175 // manually. |
163 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; | 176 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; |
164 | 177 |
165 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); | 178 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
166 }; | 179 }; |
167 | 180 |
168 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_H_ | 181 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_H_ |
OLD | NEW |