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/kill.h" | 10 #include "base/process/kill.h" |
11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
12 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "ipc/ipc_channel_proxy.h" | 14 #include "ipc/ipc_channel_proxy.h" |
15 #include "ipc/ipc_sender.h" | 15 #include "ipc/ipc_sender.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/surface/transport_dib.h" | 17 #include "ui/surface/transport_dib.h" |
18 | 18 |
19 class GURL; | 19 class GURL; |
20 struct ViewMsg_SwapOut_Params; | 20 struct ViewMsg_SwapOut_Params; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class TimeDelta; | 23 class TimeDelta; |
24 } | 24 } |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 class BrowserContext; | 27 class BrowserContext; |
28 class BrowserMessageFilter; | 28 class BrowserMessageFilter; |
29 class RenderProcessHostObserver; | |
29 class RenderWidgetHost; | 30 class RenderWidgetHost; |
30 class StoragePartition; | 31 class StoragePartition; |
31 | 32 |
32 typedef base::Thread* (*RendererMainThreadFactoryFunction)( | 33 typedef base::Thread* (*RendererMainThreadFactoryFunction)( |
33 const std::string& id); | 34 const std::string& id); |
34 | 35 |
35 // Interface that represents the browser side of the browser <-> renderer | 36 // Interface that represents the browser side of the browser <-> renderer |
36 // communication channel. There will generally be one RenderProcessHost per | 37 // communication channel. There will generally be one RenderProcessHost per |
37 // renderer process. | 38 // renderer process. |
38 class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, | 39 class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, |
39 public IPC::Listener, | 40 public IPC::Listener, |
40 public base::SupportsUserData { | 41 public base::SupportsUserData { |
41 public: | 42 public: |
42 typedef IDMap<RenderProcessHost>::iterator iterator; | 43 typedef IDMap<RenderProcessHost>::iterator iterator; |
43 | 44 |
44 // Details for RENDERER_PROCESS_CLOSED notifications. | 45 // Details for RENDERER_PROCESS_CLOSED notifications. |
45 struct RendererClosedDetails { | 46 struct RendererClosedDetails { |
46 RendererClosedDetails(base::ProcessHandle handle, | 47 RendererClosedDetails(base::ProcessHandle handle, |
47 base::TerminationStatus status, | 48 base::TerminationStatus status, |
48 int exit_code) { | 49 int exit_code) { |
49 this->handle = handle; | 50 this->handle = handle; |
50 this->status = status; | 51 this->status = status; |
51 this->exit_code = exit_code; | 52 this->exit_code = exit_code; |
52 } | 53 } |
53 base::ProcessHandle handle; | 54 base::ProcessHandle handle; |
54 base::TerminationStatus status; | 55 base::TerminationStatus status; |
55 int exit_code; | 56 int exit_code; |
56 }; | 57 }; |
57 | 58 |
59 // General functions --------------------------------------------------------- | |
60 | |
58 virtual ~RenderProcessHost() {} | 61 virtual ~RenderProcessHost() {} |
59 | 62 |
60 // Initialize the new renderer process, returning true on success. This must | 63 // Initialize the new renderer process, returning true on success. This must |
61 // be called once before the object can be used, but can be called after | 64 // be called once before the object can be used, but can be called after |
62 // that with no effect. Therefore, if the caller isn't sure about whether | 65 // that with no effect. Therefore, if the caller isn't sure about whether |
63 // the process has been created, it should just call Init(). | 66 // the process has been created, it should just call Init(). |
64 virtual bool Init() = 0; | 67 virtual bool Init() = 0; |
65 | 68 |
66 // Gets the next available routing id. | 69 // Gets the next available routing id. |
67 virtual int GetNextRoutingID() = 0; | 70 virtual int GetNextRoutingID() = 0; |
68 | 71 |
69 // These methods add or remove listener for a specific message routing ID. | 72 // These methods add or remove listener for a specific message routing ID. |
70 // Used for refcounting, each holder of this object must AddRoute and | 73 // Used for refcounting, each holder of this object must AddRoute and |
71 // RemoveRoute. This object should be allocated on the heap; when no | 74 // RemoveRoute. This object should be allocated on the heap; when no |
72 // listeners own it any more, it will delete itself. | 75 // listeners own it any more, it will delete itself. |
73 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) = 0; | 76 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) = 0; |
74 virtual void RemoveRoute(int32 routing_id) = 0; | 77 virtual void RemoveRoute(int32 routing_id) = 0; |
75 | 78 |
79 // Add and remove observers for lifecycle events. The order in which | |
80 // notifications are sent to observers is undefined. Observers must be sure to | |
81 // remove the observer before they go away. | |
82 virtual void AddObserver(RenderProcessHostObserver* observer) = 0; | |
83 virtual void RemoveObserver(RenderProcessHostObserver* observer) = 0; | |
84 | |
76 // Called to wait for the next UpdateRect message for the specified render | 85 // Called to wait for the next UpdateRect message for the specified render |
77 // widget. Returns true if successful, and the msg out-param will contain a | 86 // widget. Returns true if successful, and the msg out-param will contain a |
78 // copy of the received UpdateRect message. | 87 // copy of the received UpdateRect message. |
79 virtual bool WaitForBackingStoreMsg(int render_widget_id, | 88 virtual bool WaitForBackingStoreMsg(int render_widget_id, |
80 const base::TimeDelta& max_delay, | 89 const base::TimeDelta& max_delay, |
81 IPC::Message* msg) = 0; | 90 IPC::Message* msg) = 0; |
82 | 91 |
83 // Called when a received message cannot be decoded. | 92 // Called when a received message cannot be decoded. |
84 virtual void ReceivedBadMessage() = 0; | 93 virtual void ReceivedBadMessage() = 0; |
85 | 94 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 // to a RenderProcess which is instantiated in the same process | 218 // to a RenderProcess which is instantiated in the same process |
210 // with the Browser. All IPC between the Browser and the | 219 // with the Browser. All IPC between the Browser and the |
211 // Renderer is the same, it's just not crossing a process boundary. | 220 // Renderer is the same, it's just not crossing a process boundary. |
212 | 221 |
213 static bool run_renderer_in_process(); | 222 static bool run_renderer_in_process(); |
214 | 223 |
215 // This also calls out to ContentBrowserClient::GetApplicationLocale and | 224 // This also calls out to ContentBrowserClient::GetApplicationLocale and |
216 // modifies the current process' command line. | 225 // modifies the current process' command line. |
217 static void SetRunRendererInProcess(bool value); | 226 static void SetRunRendererInProcess(bool value); |
218 | 227 |
228 // This forces a renderer that is running "in process" to shut down. | |
229 static void ShutDownInProcessRenderer(); | |
jam
2013/11/18 19:16:20
nit: since this is only called inside content, put
Avi (use Gerrit)
2013/11/18 19:22:21
Right. I was thinking BrowserMainLoop was in chrom
| |
230 | |
219 // Allows iteration over all the RenderProcessHosts in the browser. Note | 231 // Allows iteration over all the RenderProcessHosts in the browser. Note |
220 // that each host may not be active, and therefore may have NULL channels. | 232 // that each host may not be active, and therefore may have NULL channels. |
221 static iterator AllHostsIterator(); | 233 static iterator AllHostsIterator(); |
222 | 234 |
223 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does | 235 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does |
224 // not correspond to a live RenderProcessHost. | 236 // not correspond to a live RenderProcessHost. |
225 static RenderProcessHost* FromID(int render_process_id); | 237 static RenderProcessHost* FromID(int render_process_id); |
226 | 238 |
227 // Returns whether the process-per-site model is in use (globally or just for | 239 // Returns whether the process-per-site model is in use (globally or just for |
228 // the current site), in which case we should ensure there is only one | 240 // the current site), in which case we should ensure there is only one |
(...skipping 26 matching lines...) Expand all Loading... | |
255 // module. | 267 // module. |
256 static size_t GetMaxRendererProcessCount(); | 268 static size_t GetMaxRendererProcessCount(); |
257 | 269 |
258 static void RegisterRendererMainThreadFactory( | 270 static void RegisterRendererMainThreadFactory( |
259 RendererMainThreadFactoryFunction create); | 271 RendererMainThreadFactoryFunction create); |
260 }; | 272 }; |
261 | 273 |
262 } // namespace content. | 274 } // namespace content. |
263 | 275 |
264 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | 276 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ |
OLD | NEW |