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 |
11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/process.h" | 13 #include "base/process.h" |
14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "ipc/ipc_channel_proxy.h" | 16 #include "ipc/ipc_channel_proxy.h" |
17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
18 #include "ui/gfx/surface/transport_dib.h" | 18 #include "ui/gfx/surface/transport_dib.h" |
19 | 19 |
20 class Profile; | 20 class Profile; |
21 struct ViewMsg_SwapOut_Params; | 21 struct ViewMsg_SwapOut_Params; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class SharedMemory; | 24 class SharedMemory; |
25 } | 25 } |
26 | 26 |
27 namespace content { | |
28 class BrowserContext; | |
29 } | |
30 | |
27 namespace net { | 31 namespace net { |
28 class URLRequestContextGetter; | 32 class URLRequestContextGetter; |
29 } | 33 } |
30 | 34 |
31 // Virtual interface that represents the browser side of the browser <-> | 35 // Virtual interface that represents the browser side of the browser <-> |
32 // renderer communication channel. There will generally be one | 36 // renderer communication channel. There will generally be one |
33 // RenderProcessHost per renderer process. | 37 // RenderProcessHost per renderer process. |
34 // | 38 // |
35 // The concrete implementation of this class for normal use is the | 39 // The concrete implementation of this class for normal use is the |
36 // BrowserRenderProcessHost. It may also be implemented by a testing interface | 40 // BrowserRenderProcessHost. It may also be implemented by a testing interface |
(...skipping 20 matching lines...) Expand all Loading... | |
57 bool was_extension_renderer) { | 61 bool was_extension_renderer) { |
58 this->status = status; | 62 this->status = status; |
59 this->exit_code = exit_code; | 63 this->exit_code = exit_code; |
60 this->was_extension_renderer = was_extension_renderer; | 64 this->was_extension_renderer = was_extension_renderer; |
61 } | 65 } |
62 base::TerminationStatus status; | 66 base::TerminationStatus status; |
63 int exit_code; | 67 int exit_code; |
64 bool was_extension_renderer; | 68 bool was_extension_renderer; |
65 }; | 69 }; |
66 | 70 |
67 explicit RenderProcessHost(Profile* profile); | 71 explicit RenderProcessHost(content::BrowserContext* context); |
68 virtual ~RenderProcessHost(); | 72 virtual ~RenderProcessHost(); |
69 | 73 |
70 // Returns the user profile associated with this renderer process. | 74 // Returns the user context associated with this renderer process. |
75 content::BrowserContext* context() const { return context_; } | |
jam
2011/07/22 16:58:38
nit: browser_context everywhere in this file
| |
76 | |
77 // Returns the profile. | |
78 // TEMPORARY; http://crbug.com/76788 | |
71 Profile* profile() const { return profile_; } | 79 Profile* profile() const { return profile_; } |
72 | 80 |
73 // Returns the unique ID for this child process. This can be used later in | 81 // Returns the unique ID for this child process. This can be used later in |
74 // a call to FromID() to get back to this object (this is used to avoid | 82 // a call to FromID() to get back to this object (this is used to avoid |
75 // sending non-threadsafe pointers to other threads). | 83 // sending non-threadsafe pointers to other threads). |
76 // | 84 // |
77 // This ID will be unique for all child processes, including workers, plugins, | 85 // This ID will be unique for all child processes, including workers, plugins, |
78 // etc. It is generated by ChildProcessInfo. | 86 // etc. It is generated by ChildProcessInfo. |
79 int id() const { return id_; } | 87 int id() const { return id_; } |
80 | 88 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 static iterator AllHostsIterator(); | 263 static iterator AllHostsIterator(); |
256 | 264 |
257 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does | 265 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does |
258 // not correspond to a live RenderProcessHost. | 266 // not correspond to a live RenderProcessHost. |
259 static RenderProcessHost* FromID(int render_process_id); | 267 static RenderProcessHost* FromID(int render_process_id); |
260 | 268 |
261 // Returns true if the caller should attempt to use an existing | 269 // Returns true if the caller should attempt to use an existing |
262 // RenderProcessHost rather than creating a new one. | 270 // RenderProcessHost rather than creating a new one. |
263 static bool ShouldTryToUseExistingProcessHost(); | 271 static bool ShouldTryToUseExistingProcessHost(); |
264 | 272 |
265 // Get an existing RenderProcessHost associated with the given profile, if | 273 // Get an existing RenderProcessHost associated with the given context, if |
266 // possible. The renderer process is chosen randomly from suitable renderers | 274 // possible. The renderer process is chosen randomly from suitable renderers |
267 // that share the same profile and type. | 275 // that share the same context and type. |
268 // Returns NULL if no suitable renderer process is available, in which case | 276 // Returns NULL if no suitable renderer process is available, in which case |
269 // the caller is free to create a new renderer. | 277 // the caller is free to create a new renderer. |
270 static RenderProcessHost* GetExistingProcessHost(Profile* profile, Type type); | 278 static RenderProcessHost* GetExistingProcessHost( |
279 content::BrowserContext* context, Type type); | |
271 | 280 |
272 // Overrides the default heuristic for limiting the max renderer process | 281 // Overrides the default heuristic for limiting the max renderer process |
273 // count. This is useful for unit testing process limit behaviors. | 282 // count. This is useful for unit testing process limit behaviors. |
274 // A value of zero means to use the default heuristic. | 283 // A value of zero means to use the default heuristic. |
275 static void SetMaxRendererProcessCount(size_t count); | 284 static void SetMaxRendererProcessCount(size_t count); |
276 | 285 |
277 protected: | 286 protected: |
278 // A proxy for our IPC::Channel that lives on the IO thread (see | 287 // A proxy for our IPC::Channel that lives on the IO thread (see |
279 // browser_process.h) | 288 // browser_process.h) |
280 scoped_ptr<IPC::ChannelProxy> channel_; | 289 scoped_ptr<IPC::ChannelProxy> channel_; |
(...skipping 17 matching lines...) Expand all Loading... | |
298 | 307 |
299 // The count of currently swapped out but pending RenderViews. We have | 308 // The count of currently swapped out but pending RenderViews. We have |
300 // started to swap these in, so the renderer process should not exit if | 309 // started to swap these in, so the renderer process should not exit if |
301 // this count is non-zero. | 310 // this count is non-zero. |
302 int32 pending_views_; | 311 int32 pending_views_; |
303 | 312 |
304 private: | 313 private: |
305 // The globally-unique identifier for this RPH. | 314 // The globally-unique identifier for this RPH. |
306 int id_; | 315 int id_; |
307 | 316 |
317 content::BrowserContext* context_; | |
318 | |
319 // TEMPORARY; http://crbug.com/76788 | |
308 Profile* profile_; | 320 Profile* profile_; |
309 | 321 |
310 // set of listeners that expect the renderer process to close | 322 // set of listeners that expect the renderer process to close |
311 std::set<int> listeners_expecting_close_; | 323 std::set<int> listeners_expecting_close_; |
312 | 324 |
313 // True if the process can be shut down suddenly. If this is true, then we're | 325 // True if the process can be shut down suddenly. If this is true, then we're |
314 // sure that all the RenderViews in the process can be shutdown suddenly. If | 326 // sure that all the RenderViews in the process can be shutdown suddenly. If |
315 // it's false, then specific RenderViews might still be allowed to be shutdown | 327 // it's false, then specific RenderViews might still be allowed to be shutdown |
316 // suddenly by checking their SuddenTerminationAllowed() flag. This can occur | 328 // suddenly by checking their SuddenTerminationAllowed() flag. This can occur |
317 // if one tab has an unload event listener but another tab in the same process | 329 // if one tab has an unload event listener but another tab in the same process |
(...skipping 12 matching lines...) Expand all Loading... | |
330 | 342 |
331 DISALLOW_COPY_AND_ASSIGN(RenderProcessHost); | 343 DISALLOW_COPY_AND_ASSIGN(RenderProcessHost); |
332 }; | 344 }; |
333 | 345 |
334 // Factory object for RenderProcessHosts. Using this factory allows tests to | 346 // Factory object for RenderProcessHosts. Using this factory allows tests to |
335 // swap out a different one to use a TestRenderProcessHost. | 347 // swap out a different one to use a TestRenderProcessHost. |
336 class RenderProcessHostFactory { | 348 class RenderProcessHostFactory { |
337 public: | 349 public: |
338 virtual ~RenderProcessHostFactory() {} | 350 virtual ~RenderProcessHostFactory() {} |
339 virtual RenderProcessHost* CreateRenderProcessHost( | 351 virtual RenderProcessHost* CreateRenderProcessHost( |
340 Profile* profile) const = 0; | 352 content::BrowserContext* context) const = 0; |
341 }; | 353 }; |
342 | 354 |
343 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ | 355 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ |
OLD | NEW |