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_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/process.h" | 13 #include "base/process.h" |
14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "ipc/ipc_sync_channel.h" | 16 #include "ipc/ipc_sync_channel.h" |
17 #include "ui/gfx/surface/transport_dib.h" | 17 #include "ui/gfx/surface/transport_dib.h" |
18 | 18 |
19 class Profile; | 19 class Profile; |
20 struct ViewMsg_ClosePage_Params; | 20 struct ViewMsg_SwapOut_Params; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class SharedMemory; | 23 class SharedMemory; |
24 } | 24 } |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 class URLRequestContextGetter; | 27 class URLRequestContextGetter; |
28 } | 28 } |
29 | 29 |
30 // Virtual interface that represents the browser side of the browser <-> | 30 // Virtual interface that represents the browser side of the browser <-> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 void Attach(IPC::Channel::Listener* listener, int routing_id); | 94 void Attach(IPC::Channel::Listener* listener, int routing_id); |
95 | 95 |
96 // See Attach() | 96 // See Attach() |
97 void Release(int listener_id); | 97 void Release(int listener_id); |
98 | 98 |
99 // Listeners should call this when they've sent a "Close" message and | 99 // Listeners should call this when they've sent a "Close" message and |
100 // they're waiting for a "Close_ACK", so that if the renderer process | 100 // they're waiting for a "Close_ACK", so that if the renderer process |
101 // goes away we'll know that it was intentional rather than a crash. | 101 // goes away we'll know that it was intentional rather than a crash. |
102 void ReportExpectingClose(int32 listener_id); | 102 void ReportExpectingClose(int32 listener_id); |
103 | 103 |
| 104 // Track the count of pending views that are being swapped back in. Called |
| 105 // by listeners to register and unregister pending views to prevent the |
| 106 // process from exiting. |
| 107 void AddPendingView(); |
| 108 void RemovePendingView(); |
| 109 |
104 // Allows iteration over this RenderProcessHost's RenderViewHost listeners. | 110 // Allows iteration over this RenderProcessHost's RenderViewHost listeners. |
105 // Use from UI thread only. | 111 // Use from UI thread only. |
106 typedef IDMap<IPC::Channel::Listener>::const_iterator listeners_iterator; | 112 typedef IDMap<IPC::Channel::Listener>::const_iterator listeners_iterator; |
107 | 113 |
108 listeners_iterator ListenersIterator() { | 114 listeners_iterator ListenersIterator() { |
109 return listeners_iterator(&listeners_); | 115 return listeners_iterator(&listeners_); |
110 } | 116 } |
111 | 117 |
112 IPC::Channel::Listener* GetListenerByID(int routing_id) { | 118 IPC::Channel::Listener* GetListenerByID(int routing_id) { |
113 return listeners_.Lookup(routing_id); | 119 return listeners_.Lookup(routing_id); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 virtual bool Init( | 166 virtual bool Init( |
161 bool is_accessibility_enabled, bool is_extensions_process) = 0; | 167 bool is_accessibility_enabled, bool is_extensions_process) = 0; |
162 | 168 |
163 // Gets the next available routing id. | 169 // Gets the next available routing id. |
164 virtual int GetNextRoutingID() = 0; | 170 virtual int GetNextRoutingID() = 0; |
165 | 171 |
166 // Called on the UI thread to cancel any outstanding resource requests for | 172 // Called on the UI thread to cancel any outstanding resource requests for |
167 // the specified render widget. | 173 // the specified render widget. |
168 virtual void CancelResourceRequests(int render_widget_id) = 0; | 174 virtual void CancelResourceRequests(int render_widget_id) = 0; |
169 | 175 |
170 // Called on the UI thread to simulate a ClosePage_ACK message to the | 176 // Called on the UI thread to simulate a SwapOut_ACK message to the |
171 // ResourceDispatcherHost. Necessary for a cross-site request, in the case | 177 // ResourceDispatcherHost. Necessary for a cross-site request, in the case |
172 // that the original RenderViewHost is not live and thus cannot run an | 178 // that the original RenderViewHost is not live and thus cannot run an |
173 // onunload handler. | 179 // unload handler. |
174 virtual void CrossSiteClosePageACK( | 180 virtual void CrossSiteSwapOutACK( |
175 const ViewMsg_ClosePage_Params& params) = 0; | 181 const ViewMsg_SwapOut_Params& params) = 0; |
176 | 182 |
177 // Called on the UI thread to wait for the next UpdateRect message for the | 183 // Called on the UI thread to wait for the next UpdateRect message for the |
178 // specified render widget. Returns true if successful, and the msg out- | 184 // specified render widget. Returns true if successful, and the msg out- |
179 // param will contain a copy of the received UpdateRect message. | 185 // param will contain a copy of the received UpdateRect message. |
180 virtual bool WaitForUpdateMsg(int render_widget_id, | 186 virtual bool WaitForUpdateMsg(int render_widget_id, |
181 const base::TimeDelta& max_delay, | 187 const base::TimeDelta& max_delay, |
182 IPC::Message* msg) = 0; | 188 IPC::Message* msg) = 0; |
183 | 189 |
184 // Called when a received message cannot be decoded. | 190 // Called when a received message cannot be decoded. |
185 virtual void ReceivedBadMessage() = 0; | 191 virtual void ReceivedBadMessage() = 0; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 275 |
270 // The maximum page ID we've ever seen from the renderer process. | 276 // The maximum page ID we've ever seen from the renderer process. |
271 int32 max_page_id_; | 277 int32 max_page_id_; |
272 | 278 |
273 // True if fast shutdown has been performed on this RPH. | 279 // True if fast shutdown has been performed on this RPH. |
274 bool fast_shutdown_started_; | 280 bool fast_shutdown_started_; |
275 | 281 |
276 // True if we've posted a DeleteTask and will be deleted soon. | 282 // True if we've posted a DeleteTask and will be deleted soon. |
277 bool deleting_soon_; | 283 bool deleting_soon_; |
278 | 284 |
| 285 // The count of currently swapped out but pending RenderViews. We have |
| 286 // started to swap these in, so the renderer process should not exit if |
| 287 // this count is non-zero. |
| 288 int32 pending_views_; |
| 289 |
279 private: | 290 private: |
280 // The globally-unique identifier for this RPH. | 291 // The globally-unique identifier for this RPH. |
281 int id_; | 292 int id_; |
282 | 293 |
283 Profile* profile_; | 294 Profile* profile_; |
284 | 295 |
285 // set of listeners that expect the renderer process to close | 296 // set of listeners that expect the renderer process to close |
286 std::set<int> listeners_expecting_close_; | 297 std::set<int> listeners_expecting_close_; |
287 | 298 |
288 // True if the process can be shut down suddenly. If this is true, then we're | 299 // True if the process can be shut down suddenly. If this is true, then we're |
(...skipping 20 matching lines...) Expand all Loading... |
309 // Factory object for RenderProcessHosts. Using this factory allows tests to | 320 // Factory object for RenderProcessHosts. Using this factory allows tests to |
310 // swap out a different one to use a TestRenderProcessHost. | 321 // swap out a different one to use a TestRenderProcessHost. |
311 class RenderProcessHostFactory { | 322 class RenderProcessHostFactory { |
312 public: | 323 public: |
313 virtual ~RenderProcessHostFactory() {} | 324 virtual ~RenderProcessHostFactory() {} |
314 virtual RenderProcessHost* CreateRenderProcessHost( | 325 virtual RenderProcessHost* CreateRenderProcessHost( |
315 Profile* profile) const = 0; | 326 Profile* profile) const = 0; |
316 }; | 327 }; |
317 | 328 |
318 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ | 329 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ |
OLD | NEW |