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_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ |
6 #define CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | 6 #define CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 | 32 |
33 // Interface that represents the browser side of the browser <-> renderer | 33 // Interface that represents the browser side of the browser <-> renderer |
34 // communication channel. There will generally be one RenderProcessHost per | 34 // communication channel. There will generally be one RenderProcessHost per |
35 // renderer process. | 35 // renderer process. |
36 class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, | 36 class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, |
37 public IPC::Listener { | 37 public IPC::Listener { |
38 public: | 38 public: |
39 typedef IDMap<RenderProcessHost>::iterator iterator; | 39 typedef IDMap<RenderProcessHost>::iterator iterator; |
40 typedef IDMap<RenderWidgetHost>::const_iterator RenderWidgetHostsIterator; | |
41 | 40 |
42 // Details for RENDERER_PROCESS_CLOSED notifications. | 41 // Details for RENDERER_PROCESS_CLOSED notifications. |
43 struct RendererClosedDetails { | 42 struct RendererClosedDetails { |
44 RendererClosedDetails(base::ProcessHandle handle, | 43 RendererClosedDetails(base::ProcessHandle handle, |
45 base::TerminationStatus status, | 44 base::TerminationStatus status, |
46 int exit_code) { | 45 int exit_code) { |
47 this->handle = handle; | 46 this->handle = handle; |
48 this->status = status; | 47 this->status = status; |
49 this->exit_code = exit_code; | 48 this->exit_code = exit_code; |
50 } | 49 } |
51 base::ProcessHandle handle; | 50 base::ProcessHandle handle; |
52 base::TerminationStatus status; | 51 base::TerminationStatus status; |
53 int exit_code; | 52 int exit_code; |
54 }; | 53 }; |
55 | 54 |
56 virtual ~RenderProcessHost() {} | 55 virtual ~RenderProcessHost() {} |
57 | 56 |
58 // Initialize the new renderer process, returning true on success. This must | 57 // Initialize the new renderer process, returning true on success. This must |
59 // be called once before the object can be used, but can be called after | 58 // be called once before the object can be used, but can be called after |
60 // that with no effect. Therefore, if the caller isn't sure about whether | 59 // that with no effect. Therefore, if the caller isn't sure about whether |
61 // the process has been created, it should just call Init(). | 60 // the process has been created, it should just call Init(). |
62 virtual bool Init() = 0; | 61 virtual bool Init() = 0; |
63 | 62 |
64 // Gets the next available routing id. | 63 // Gets the next available routing id. |
65 virtual int GetNextRoutingID() = 0; | 64 virtual int GetNextRoutingID() = 0; |
66 | 65 |
| 66 // These methods add or remove listener for a specific message routing ID. |
| 67 // Used for refcounting, each holder of this object must AddRoute and |
| 68 // RemoveRoute. This object should be allocated on the heap; when no |
| 69 // listeners own it any more, it will delete itself. |
| 70 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) = 0; |
| 71 virtual void RemoveRoute(int32 routing_id) = 0; |
| 72 |
67 // Called on the UI thread to simulate a SwapOut_ACK message to the | 73 // Called on the UI thread to simulate a SwapOut_ACK message to the |
68 // ResourceDispatcherHost. Necessary for a cross-site request, in the case | 74 // ResourceDispatcherHost. Necessary for a cross-site request, in the case |
69 // that the original RenderViewHost is not live and thus cannot run an | 75 // that the original RenderViewHost is not live and thus cannot run an |
70 // unload handler. | 76 // unload handler. |
71 virtual void SimulateSwapOutACK(const ViewMsg_SwapOut_Params& params) = 0; | 77 virtual void SimulateSwapOutACK(const ViewMsg_SwapOut_Params& params) = 0; |
72 | 78 |
73 // Called to wait for the next UpdateRect message for the specified render | 79 // Called to wait for the next UpdateRect message for the specified render |
74 // widget. Returns true if successful, and the msg out-param will contain a | 80 // widget. Returns true if successful, and the msg out-param will contain a |
75 // copy of the received UpdateRect message. | 81 // copy of the received UpdateRect message. |
76 virtual bool WaitForBackingStoreMsg(int render_widget_id, | 82 virtual bool WaitForBackingStoreMsg(int render_widget_id, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 virtual bool InSameStoragePartition(StoragePartition* partition) const = 0; | 145 virtual bool InSameStoragePartition(StoragePartition* partition) const = 0; |
140 | 146 |
141 // Returns the unique ID for this child process. This can be used later in | 147 // Returns the unique ID for this child process. This can be used later in |
142 // a call to FromID() to get back to this object (this is used to avoid | 148 // a call to FromID() to get back to this object (this is used to avoid |
143 // sending non-threadsafe pointers to other threads). | 149 // sending non-threadsafe pointers to other threads). |
144 // | 150 // |
145 // This ID will be unique for all child processes, including workers, plugins, | 151 // This ID will be unique for all child processes, including workers, plugins, |
146 // etc. | 152 // etc. |
147 virtual int GetID() const = 0; | 153 virtual int GetID() const = 0; |
148 | 154 |
149 // Returns the render widget host for the routing id passed in. | |
150 virtual RenderWidgetHost* GetRenderWidgetHostByID(int routing_id) = 0; | |
151 | |
152 // Returns true iff channel_ has been set to non-NULL. Use this for checking | 155 // Returns true iff channel_ has been set to non-NULL. Use this for checking |
153 // if there is connection or not. Virtual for mocking out for tests. | 156 // if there is connection or not. Virtual for mocking out for tests. |
154 virtual bool HasConnection() const = 0; | 157 virtual bool HasConnection() const = 0; |
155 | 158 |
156 // Call this to allow queueing of IPC messages that are sent before the | 159 // Call this to allow queueing of IPC messages that are sent before the |
157 // process is launched. | 160 // process is launched. |
158 virtual void EnableSendQueue() = 0; | 161 virtual void EnableSendQueue() = 0; |
159 | 162 |
160 // Returns the renderer channel. | 163 // Returns the renderer channel. |
161 virtual IPC::ChannelProxy* GetChannel() = 0; | 164 virtual IPC::ChannelProxy* GetChannel() = 0; |
162 | 165 |
163 // Returns the list of attached render widget hosts. | |
164 virtual RenderWidgetHostsIterator GetRenderWidgetHostsIterator() = 0; | |
165 | |
166 // Try to shutdown the associated render process as fast as possible | 166 // Try to shutdown the associated render process as fast as possible |
167 virtual bool FastShutdownForPageCount(size_t count) = 0; | 167 virtual bool FastShutdownForPageCount(size_t count) = 0; |
168 | 168 |
169 // TODO(ananta) | 169 // TODO(ananta) |
170 // Revisit whether the virtual functions declared from here on need to be | 170 // Revisit whether the virtual functions declared from here on need to be |
171 // part of the interface. | 171 // part of the interface. |
172 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; | 172 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; |
173 virtual bool IgnoreInputEvents() const = 0; | 173 virtual bool IgnoreInputEvents() const = 0; |
174 | 174 |
175 // Used for refcounting, each holder of this object must Attach and Release | |
176 // just like it would for a COM object. This object should be allocated on | |
177 // the heap; when no listeners own it any more, it will delete itself. | |
178 virtual void Attach(content::RenderWidgetHost* host, int routing_id) = 0; | |
179 | |
180 // See Attach() | |
181 virtual void Release(int routing_id) = 0; | |
182 | |
183 // Schedules the host for deletion and removes it from the all_hosts list. | 175 // Schedules the host for deletion and removes it from the all_hosts list. |
184 virtual void Cleanup() = 0; | 176 virtual void Cleanup() = 0; |
185 | 177 |
186 // Track the count of pending views that are being swapped back in. Called | 178 // Track the count of pending views that are being swapped back in. Called |
187 // by listeners to register and unregister pending views to prevent the | 179 // by listeners to register and unregister pending views to prevent the |
188 // process from exiting. | 180 // process from exiting. |
189 virtual void AddPendingView() = 0; | 181 virtual void AddPendingView() = 0; |
190 virtual void RemovePendingView() = 0; | 182 virtual void RemovePendingView() = 0; |
191 | 183 |
192 // Sets a flag indicating that the process can be abnormally terminated. | 184 // Sets a flag indicating that the process can be abnormally terminated. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 static void SetMaxRendererProcessCount(size_t count); | 246 static void SetMaxRendererProcessCount(size_t count); |
255 | 247 |
256 // Returns the current max number of renderer processes used by the content | 248 // Returns the current max number of renderer processes used by the content |
257 // module. | 249 // module. |
258 static size_t GetMaxRendererProcessCount(); | 250 static size_t GetMaxRendererProcessCount(); |
259 }; | 251 }; |
260 | 252 |
261 } // namespace content. | 253 } // namespace content. |
262 | 254 |
263 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | 255 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ |
OLD | NEW |