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 to wait for the next UpdateRect message for the specified render | 73 // Called to wait for the next UpdateRect message for the specified render |
68 // widget. Returns true if successful, and the msg out-param will contain a | 74 // widget. Returns true if successful, and the msg out-param will contain a |
69 // copy of the received UpdateRect message. | 75 // copy of the received UpdateRect message. |
70 virtual bool WaitForBackingStoreMsg(int render_widget_id, | 76 virtual bool WaitForBackingStoreMsg(int render_widget_id, |
71 const base::TimeDelta& max_delay, | 77 const base::TimeDelta& max_delay, |
72 IPC::Message* msg) = 0; | 78 IPC::Message* msg) = 0; |
73 | 79 |
74 // Called when a received message cannot be decoded. | 80 // Called when a received message cannot be decoded. |
75 virtual void ReceivedBadMessage() = 0; | 81 virtual void ReceivedBadMessage() = 0; |
76 | 82 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 virtual bool InSameStoragePartition(StoragePartition* partition) const = 0; | 139 virtual bool InSameStoragePartition(StoragePartition* partition) const = 0; |
134 | 140 |
135 // Returns the unique ID for this child process. This can be used later in | 141 // Returns the unique ID for this child process. This can be used later in |
136 // a call to FromID() to get back to this object (this is used to avoid | 142 // a call to FromID() to get back to this object (this is used to avoid |
137 // sending non-threadsafe pointers to other threads). | 143 // sending non-threadsafe pointers to other threads). |
138 // | 144 // |
139 // This ID will be unique for all child processes, including workers, plugins, | 145 // This ID will be unique for all child processes, including workers, plugins, |
140 // etc. | 146 // etc. |
141 virtual int GetID() const = 0; | 147 virtual int GetID() const = 0; |
142 | 148 |
143 // Returns the render widget host for the routing id passed in. | |
144 virtual RenderWidgetHost* GetRenderWidgetHostByID(int routing_id) = 0; | |
145 | |
146 // Returns true iff channel_ has been set to non-NULL. Use this for checking | 149 // Returns true iff channel_ has been set to non-NULL. Use this for checking |
147 // if there is connection or not. Virtual for mocking out for tests. | 150 // if there is connection or not. Virtual for mocking out for tests. |
148 virtual bool HasConnection() const = 0; | 151 virtual bool HasConnection() const = 0; |
149 | 152 |
150 // Call this to allow queueing of IPC messages that are sent before the | 153 // Call this to allow queueing of IPC messages that are sent before the |
151 // process is launched. | 154 // process is launched. |
152 virtual void EnableSendQueue() = 0; | 155 virtual void EnableSendQueue() = 0; |
153 | 156 |
154 // Returns the renderer channel. | 157 // Returns the renderer channel. |
155 virtual IPC::ChannelProxy* GetChannel() = 0; | 158 virtual IPC::ChannelProxy* GetChannel() = 0; |
156 | 159 |
157 // Returns the list of attached render widget hosts. | |
158 virtual RenderWidgetHostsIterator GetRenderWidgetHostsIterator() = 0; | |
159 | |
160 // Try to shutdown the associated render process as fast as possible | 160 // Try to shutdown the associated render process as fast as possible |
161 virtual bool FastShutdownForPageCount(size_t count) = 0; | 161 virtual bool FastShutdownForPageCount(size_t count) = 0; |
162 | 162 |
163 // TODO(ananta) | 163 // TODO(ananta) |
164 // Revisit whether the virtual functions declared from here on need to be | 164 // Revisit whether the virtual functions declared from here on need to be |
165 // part of the interface. | 165 // part of the interface. |
166 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; | 166 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; |
167 virtual bool IgnoreInputEvents() const = 0; | 167 virtual bool IgnoreInputEvents() const = 0; |
168 | 168 |
169 // Used for refcounting, each holder of this object must Attach and Release | |
170 // just like it would for a COM object. This object should be allocated on | |
171 // the heap; when no listeners own it any more, it will delete itself. | |
172 virtual void Attach(content::RenderWidgetHost* host, int routing_id) = 0; | |
173 | |
174 // See Attach() | |
175 virtual void Release(int routing_id) = 0; | |
176 | |
177 // Schedules the host for deletion and removes it from the all_hosts list. | 169 // Schedules the host for deletion and removes it from the all_hosts list. |
178 virtual void Cleanup() = 0; | 170 virtual void Cleanup() = 0; |
179 | 171 |
180 // Track the count of pending views that are being swapped back in. Called | 172 // Track the count of pending views that are being swapped back in. Called |
181 // by listeners to register and unregister pending views to prevent the | 173 // by listeners to register and unregister pending views to prevent the |
182 // process from exiting. | 174 // process from exiting. |
183 virtual void AddPendingView() = 0; | 175 virtual void AddPendingView() = 0; |
184 virtual void RemovePendingView() = 0; | 176 virtual void RemovePendingView() = 0; |
185 | 177 |
186 // Sets a flag indicating that the process can be abnormally terminated. | 178 // Sets a flag indicating that the process can be abnormally terminated. |
(...skipping 67 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 |