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 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // for mocking purposes. | 43 // for mocking purposes. |
44 class CONTENT_EXPORT RenderProcessHost : public IPC::Channel::Sender, | 44 class CONTENT_EXPORT RenderProcessHost : public IPC::Channel::Sender, |
45 public IPC::Channel::Listener { | 45 public IPC::Channel::Listener { |
46 public: | 46 public: |
47 typedef IDMap<RenderProcessHost>::iterator iterator; | 47 typedef IDMap<RenderProcessHost>::iterator iterator; |
48 | 48 |
49 // Details for RENDERER_PROCESS_CLOSED notifications. | 49 // Details for RENDERER_PROCESS_CLOSED notifications. |
50 struct RendererClosedDetails { | 50 struct RendererClosedDetails { |
51 RendererClosedDetails(base::TerminationStatus status, | 51 RendererClosedDetails(base::TerminationStatus status, |
52 int exit_code, | 52 int exit_code, |
53 bool was_extension_renderer) { | 53 bool was_alive) { |
54 this->status = status; | 54 this->status = status; |
55 this->exit_code = exit_code; | 55 this->exit_code = exit_code; |
56 this->was_extension_renderer = was_extension_renderer; | 56 this->was_alive = was_alive; |
57 } | 57 } |
58 base::TerminationStatus status; | 58 base::TerminationStatus status; |
59 int exit_code; | 59 int exit_code; |
60 bool was_extension_renderer; | 60 bool was_alive; |
61 }; | 61 }; |
62 | 62 |
63 explicit RenderProcessHost(content::BrowserContext* browser_context); | 63 explicit RenderProcessHost(content::BrowserContext* browser_context); |
64 virtual ~RenderProcessHost(); | 64 virtual ~RenderProcessHost(); |
65 | 65 |
66 // Returns the user browser context associated with this renderer process. | 66 // Returns the user browser context associated with this renderer process. |
67 content::BrowserContext* browser_context() const { return browser_context_; } | 67 content::BrowserContext* browser_context() const { return browser_context_; } |
68 | 68 |
69 // Returns the unique ID for this child process. This can be used later in | 69 // Returns the unique ID for this child process. This can be used later in |
70 // a call to FromID() to get back to this object (this is used to avoid | 70 // a call to FromID() to get back to this object (this is used to avoid |
71 // sending non-threadsafe pointers to other threads). | 71 // sending non-threadsafe pointers to other threads). |
72 // | 72 // |
73 // This ID will be unique for all child processes, including workers, plugins, | 73 // This ID will be unique for all child processes, including workers, plugins, |
74 // etc. It is generated by ChildProcessInfo. | 74 // etc. It is generated by ChildProcessInfo. |
75 int id() const { return id_; } | 75 int id() const { return id_; } |
76 | 76 |
77 // Returns true iff channel_ has been set to non-NULL. Use this for checking | 77 // Returns true iff channel_ has been set to non-NULL. Use this for checking |
78 // if there is connection or not. Virtual for mocking out for tests. | 78 // if there is connection or not. Virtual for mocking out for tests. |
79 virtual bool HasConnection() const; | 79 virtual bool HasConnection() const; |
80 | 80 |
81 bool sudden_termination_allowed() const { | 81 bool sudden_termination_allowed() const { |
82 return sudden_termination_allowed_; | 82 return sudden_termination_allowed_; |
83 } | 83 } |
84 void set_sudden_termination_allowed(bool enabled) { | 84 void set_sudden_termination_allowed(bool enabled) { |
85 sudden_termination_allowed_ = enabled; | 85 sudden_termination_allowed_ = enabled; |
86 } | 86 } |
87 | 87 |
88 bool is_extension_process() const { return is_extension_process_; } | |
89 void mark_is_extension_process() { is_extension_process_ = true; } | |
90 | |
91 // Used for refcounting, each holder of this object must Attach and Release | 88 // Used for refcounting, each holder of this object must Attach and Release |
92 // just like it would for a COM object. This object should be allocated on | 89 // just like it would for a COM object. This object should be allocated on |
93 // the heap; when no listeners own it any more, it will delete itself. | 90 // the heap; when no listeners own it any more, it will delete itself. |
94 void Attach(IPC::Channel::Listener* listener, int routing_id); | 91 void Attach(IPC::Channel::Listener* listener, int routing_id); |
95 | 92 |
96 // See Attach() | 93 // See Attach() |
97 void Release(int listener_id); | 94 void Release(int listener_id); |
98 | 95 |
99 // Schedules the host for deletion and removes it from the all_hosts list. | 96 // Schedules the host for deletion and removes it from the all_hosts list. |
100 void Cleanup(); | 97 void Cleanup(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 286 |
290 // The maximum page ID we've ever seen from the renderer process. | 287 // The maximum page ID we've ever seen from the renderer process. |
291 int32 max_page_id_; | 288 int32 max_page_id_; |
292 | 289 |
293 // True if fast shutdown has been performed on this RPH. | 290 // True if fast shutdown has been performed on this RPH. |
294 bool fast_shutdown_started_; | 291 bool fast_shutdown_started_; |
295 | 292 |
296 // True if we've posted a DeleteTask and will be deleted soon. | 293 // True if we've posted a DeleteTask and will be deleted soon. |
297 bool deleting_soon_; | 294 bool deleting_soon_; |
298 | 295 |
299 // True iff this process is being used as an extension process. Not valid | |
300 // when running in single-process mode. | |
301 bool is_extension_process_; | |
302 | |
303 // The count of currently swapped out but pending RenderViews. We have | 296 // The count of currently swapped out but pending RenderViews. We have |
304 // started to swap these in, so the renderer process should not exit if | 297 // started to swap these in, so the renderer process should not exit if |
305 // this count is non-zero. | 298 // this count is non-zero. |
306 int32 pending_views_; | 299 int32 pending_views_; |
307 | 300 |
308 private: | 301 private: |
309 // The globally-unique identifier for this RPH. | 302 // The globally-unique identifier for this RPH. |
310 int id_; | 303 int id_; |
311 | 304 |
312 content::BrowserContext* browser_context_; | 305 content::BrowserContext* browser_context_; |
(...skipping 25 matching lines...) Expand all Loading... |
338 // Factory object for RenderProcessHosts. Using this factory allows tests to | 331 // Factory object for RenderProcessHosts. Using this factory allows tests to |
339 // swap out a different one to use a TestRenderProcessHost. | 332 // swap out a different one to use a TestRenderProcessHost. |
340 class RenderProcessHostFactory { | 333 class RenderProcessHostFactory { |
341 public: | 334 public: |
342 virtual ~RenderProcessHostFactory() {} | 335 virtual ~RenderProcessHostFactory() {} |
343 virtual RenderProcessHost* CreateRenderProcessHost( | 336 virtual RenderProcessHost* CreateRenderProcessHost( |
344 content::BrowserContext* browser_context) const = 0; | 337 content::BrowserContext* browser_context) const = 0; |
345 }; | 338 }; |
346 | 339 |
347 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ | 340 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ |
OLD | NEW |