| 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 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) = 0; |
| 68 virtual void RemoveRoute(int32 routing_id) = 0; |
| 69 |
| 67 // Called on the UI thread to simulate a SwapOut_ACK message to the | 70 // Called on the UI thread to simulate a SwapOut_ACK message to the |
| 68 // ResourceDispatcherHost. Necessary for a cross-site request, in the case | 71 // ResourceDispatcherHost. Necessary for a cross-site request, in the case |
| 69 // that the original RenderViewHost is not live and thus cannot run an | 72 // that the original RenderViewHost is not live and thus cannot run an |
| 70 // unload handler. | 73 // unload handler. |
| 71 virtual void SimulateSwapOutACK(const ViewMsg_SwapOut_Params& params) = 0; | 74 virtual void SimulateSwapOutACK(const ViewMsg_SwapOut_Params& params) = 0; |
| 72 | 75 |
| 73 // Called to wait for the next UpdateRect message for the specified render | 76 // 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 | 77 // widget. Returns true if successful, and the msg out-param will contain a |
| 75 // copy of the received UpdateRect message. | 78 // copy of the received UpdateRect message. |
| 76 virtual bool WaitForBackingStoreMsg(int render_widget_id, | 79 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; | 142 virtual bool InSameStoragePartition(StoragePartition* partition) const = 0; |
| 140 | 143 |
| 141 // Returns the unique ID for this child process. This can be used later in | 144 // 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 | 145 // a call to FromID() to get back to this object (this is used to avoid |
| 143 // sending non-threadsafe pointers to other threads). | 146 // sending non-threadsafe pointers to other threads). |
| 144 // | 147 // |
| 145 // This ID will be unique for all child processes, including workers, plugins, | 148 // This ID will be unique for all child processes, including workers, plugins, |
| 146 // etc. | 149 // etc. |
| 147 virtual int GetID() const = 0; | 150 virtual int GetID() const = 0; |
| 148 | 151 |
| 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 | 152 // 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. | 153 // if there is connection or not. Virtual for mocking out for tests. |
| 154 virtual bool HasConnection() const = 0; | 154 virtual bool HasConnection() const = 0; |
| 155 | 155 |
| 156 // Call this to allow queueing of IPC messages that are sent before the | 156 // Call this to allow queueing of IPC messages that are sent before the |
| 157 // process is launched. | 157 // process is launched. |
| 158 virtual void EnableSendQueue() = 0; | 158 virtual void EnableSendQueue() = 0; |
| 159 | 159 |
| 160 // Returns the renderer channel. | 160 // Returns the renderer channel. |
| 161 virtual IPC::ChannelProxy* GetChannel() = 0; | 161 virtual IPC::ChannelProxy* GetChannel() = 0; |
| 162 | 162 |
| 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 | 163 // Try to shutdown the associated render process as fast as possible |
| 167 virtual bool FastShutdownForPageCount(size_t count) = 0; | 164 virtual bool FastShutdownForPageCount(size_t count) = 0; |
| 168 | 165 |
| 169 // TODO(ananta) | 166 // TODO(ananta) |
| 170 // Revisit whether the virtual functions declared from here on need to be | 167 // Revisit whether the virtual functions declared from here on need to be |
| 171 // part of the interface. | 168 // part of the interface. |
| 172 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; | 169 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; |
| 173 virtual bool IgnoreInputEvents() const = 0; | 170 virtual bool IgnoreInputEvents() const = 0; |
| 174 | 171 |
| 175 // Used for refcounting, each holder of this object must Attach and Release | 172 // 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 | 173 // 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. | 174 // the heap; when no listeners own it any more, it will delete itself. |
| 178 virtual void Attach(content::RenderWidgetHost* host, int routing_id) = 0; | 175 // virtual void Attach(content::RenderWidgetHost* host, int routing_id) = 0; |
| 179 | 176 |
| 180 // See Attach() | 177 // See Attach() |
| 181 virtual void Release(int routing_id) = 0; | 178 // virtual void Release(int routing_id) = 0; |
| 182 | 179 |
| 183 // Schedules the host for deletion and removes it from the all_hosts list. | 180 // Schedules the host for deletion and removes it from the all_hosts list. |
| 184 virtual void Cleanup() = 0; | 181 virtual void Cleanup() = 0; |
| 185 | 182 |
| 186 // Track the count of pending views that are being swapped back in. Called | 183 // 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 | 184 // by listeners to register and unregister pending views to prevent the |
| 188 // process from exiting. | 185 // process from exiting. |
| 189 virtual void AddPendingView() = 0; | 186 virtual void AddPendingView() = 0; |
| 190 virtual void RemovePendingView() = 0; | 187 virtual void RemovePendingView() = 0; |
| 191 | 188 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 static void SetMaxRendererProcessCount(size_t count); | 251 static void SetMaxRendererProcessCount(size_t count); |
| 255 | 252 |
| 256 // Returns the current max number of renderer processes used by the content | 253 // Returns the current max number of renderer processes used by the content |
| 257 // module. | 254 // module. |
| 258 static size_t GetMaxRendererProcessCount(); | 255 static size_t GetMaxRendererProcessCount(); |
| 259 }; | 256 }; |
| 260 | 257 |
| 261 } // namespace content. | 258 } // namespace content. |
| 262 | 259 |
| 263 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | 260 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ |
| OLD | NEW |