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 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 class BrowserContext; | 28 class BrowserContext; |
29 } | 29 } |
30 | 30 |
31 namespace net { | 31 namespace net { |
32 class URLRequestContextGetter; | 32 class URLRequestContextGetter; |
33 } | 33 } |
34 | 34 |
| 35 class GURL; |
| 36 |
35 // Virtual interface that represents the browser side of the browser <-> | 37 // Virtual interface that represents the browser side of the browser <-> |
36 // renderer communication channel. There will generally be one | 38 // renderer communication channel. There will generally be one |
37 // RenderProcessHost per renderer process. | 39 // RenderProcessHost per renderer process. |
38 // | 40 // |
39 // The concrete implementation of this class for normal use is the | 41 // The concrete implementation of this class for normal use is the |
40 // BrowserRenderProcessHost. It may also be implemented by a testing interface | 42 // BrowserRenderProcessHost. It may also be implemented by a testing interface |
41 // for mocking purposes. | 43 // for mocking purposes. |
42 class CONTENT_EXPORT RenderProcessHost : public IPC::Channel::Sender, | 44 class CONTENT_EXPORT RenderProcessHost : public IPC::Channel::Sender, |
43 public IPC::Channel::Listener { | 45 public IPC::Channel::Listener { |
44 public: | 46 public: |
45 typedef IDMap<RenderProcessHost>::iterator iterator; | 47 typedef IDMap<RenderProcessHost>::iterator iterator; |
46 | 48 |
47 // We classify renderers according to their highest privilege, and try | |
48 // to group pages into renderers with similar privileges. | |
49 // Note: it may be possible for a renderer to have multiple privileges, | |
50 // in which case we call it an "extension" renderer. | |
51 enum Type { | |
52 TYPE_NORMAL, // Normal renderer, no extra privileges. | |
53 TYPE_WEBUI, // Renderer with WebUI privileges, like New Tab. | |
54 TYPE_EXTENSION, // Renderer with extension privileges. | |
55 }; | |
56 | |
57 // Details for RENDERER_PROCESS_CLOSED notifications. | 49 // Details for RENDERER_PROCESS_CLOSED notifications. |
58 struct RendererClosedDetails { | 50 struct RendererClosedDetails { |
59 RendererClosedDetails(base::TerminationStatus status, | 51 RendererClosedDetails(base::TerminationStatus status, |
60 int exit_code, | 52 int exit_code, |
61 bool was_extension_renderer) { | 53 bool was_extension_renderer) { |
62 this->status = status; | 54 this->status = status; |
63 this->exit_code = exit_code; | 55 this->exit_code = exit_code; |
64 this->was_extension_renderer = was_extension_renderer; | 56 this->was_extension_renderer = was_extension_renderer; |
65 } | 57 } |
66 base::TerminationStatus status; | 58 base::TerminationStatus status; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does | 259 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does |
268 // not correspond to a live RenderProcessHost. | 260 // not correspond to a live RenderProcessHost. |
269 static RenderProcessHost* FromID(int render_process_id); | 261 static RenderProcessHost* FromID(int render_process_id); |
270 | 262 |
271 // Returns true if the caller should attempt to use an existing | 263 // Returns true if the caller should attempt to use an existing |
272 // RenderProcessHost rather than creating a new one. | 264 // RenderProcessHost rather than creating a new one. |
273 static bool ShouldTryToUseExistingProcessHost(); | 265 static bool ShouldTryToUseExistingProcessHost(); |
274 | 266 |
275 // Get an existing RenderProcessHost associated with the given browser | 267 // Get an existing RenderProcessHost associated with the given browser |
276 // context, if possible. The renderer process is chosen randomly from | 268 // context, if possible. The renderer process is chosen randomly from |
277 // suitable renderers that share the same context and type. | 269 // suitable renderers that share the same context and type (determined by the |
| 270 // site url). |
278 // Returns NULL if no suitable renderer process is available, in which case | 271 // Returns NULL if no suitable renderer process is available, in which case |
279 // the caller is free to create a new renderer. | 272 // the caller is free to create a new renderer. |
280 static RenderProcessHost* GetExistingProcessHost( | 273 static RenderProcessHost* GetExistingProcessHost( |
281 content::BrowserContext* browser_context, Type type); | 274 content::BrowserContext* browser_context, const GURL& site_url); |
282 | 275 |
283 // Overrides the default heuristic for limiting the max renderer process | 276 // Overrides the default heuristic for limiting the max renderer process |
284 // count. This is useful for unit testing process limit behaviors. | 277 // count. This is useful for unit testing process limit behaviors. |
285 // A value of zero means to use the default heuristic. | 278 // A value of zero means to use the default heuristic. |
286 static void SetMaxRendererProcessCount(size_t count); | 279 static void SetMaxRendererProcessCount(size_t count); |
287 | 280 |
288 protected: | 281 protected: |
289 // A proxy for our IPC::Channel that lives on the IO thread (see | 282 // A proxy for our IPC::Channel that lives on the IO thread (see |
290 // browser_process.h) | 283 // browser_process.h) |
291 scoped_ptr<IPC::ChannelProxy> channel_; | 284 scoped_ptr<IPC::ChannelProxy> channel_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // Factory object for RenderProcessHosts. Using this factory allows tests to | 338 // Factory object for RenderProcessHosts. Using this factory allows tests to |
346 // swap out a different one to use a TestRenderProcessHost. | 339 // swap out a different one to use a TestRenderProcessHost. |
347 class RenderProcessHostFactory { | 340 class RenderProcessHostFactory { |
348 public: | 341 public: |
349 virtual ~RenderProcessHostFactory() {} | 342 virtual ~RenderProcessHostFactory() {} |
350 virtual RenderProcessHost* CreateRenderProcessHost( | 343 virtual RenderProcessHost* CreateRenderProcessHost( |
351 content::BrowserContext* browser_context) const = 0; | 344 content::BrowserContext* browser_context) const = 0; |
352 }; | 345 }; |
353 | 346 |
354 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ | 347 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ |
OLD | NEW |