Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(863)

Side by Side Diff: content/browser/renderer_host/render_process_host.h

Issue 7464009: Removal of Profile from content part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: slight tweaking for comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/profiles/profile.h"
16 #include "ipc/ipc_channel_proxy.h" 17 #include "ipc/ipc_channel_proxy.h"
17 #include "ui/gfx/native_widget_types.h" 18 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gfx/surface/transport_dib.h" 19 #include "ui/gfx/surface/transport_dib.h"
19 20
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
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* browser_context);
68 virtual ~RenderProcessHost(); 72 virtual ~RenderProcessHost();
69 73
70 // Returns the user profile associated with this renderer process. 74 // Returns the user browser context associated with this renderer process.
71 Profile* profile() const { return profile_; } 75 content::BrowserContext* browser_context() const { return browser_context_; }
76
77 // Returns the profile.
78 // TEMPORARY; http://crbug.com/76788
79 Profile* profile() const {
80 return Profile::FromBrowserContext(browser_context());
81 }
72 82
73 // Returns the unique ID for this child process. This can be used later in 83 // 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 84 // a call to FromID() to get back to this object (this is used to avoid
75 // sending non-threadsafe pointers to other threads). 85 // sending non-threadsafe pointers to other threads).
76 // 86 //
77 // This ID will be unique for all child processes, including workers, plugins, 87 // This ID will be unique for all child processes, including workers, plugins,
78 // etc. It is generated by ChildProcessInfo. 88 // etc. It is generated by ChildProcessInfo.
79 int id() const { return id_; } 89 int id() const { return id_; }
80 90
81 // Returns true iff channel_ has been set to non-NULL. Use this for checking 91 // Returns true iff channel_ has been set to non-NULL. Use this for checking
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 static iterator AllHostsIterator(); 265 static iterator AllHostsIterator();
256 266
257 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does 267 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does
258 // not correspond to a live RenderProcessHost. 268 // not correspond to a live RenderProcessHost.
259 static RenderProcessHost* FromID(int render_process_id); 269 static RenderProcessHost* FromID(int render_process_id);
260 270
261 // Returns true if the caller should attempt to use an existing 271 // Returns true if the caller should attempt to use an existing
262 // RenderProcessHost rather than creating a new one. 272 // RenderProcessHost rather than creating a new one.
263 static bool ShouldTryToUseExistingProcessHost(); 273 static bool ShouldTryToUseExistingProcessHost();
264 274
265 // Get an existing RenderProcessHost associated with the given profile, if 275 // Get an existing RenderProcessHost associated with the given browser
266 // possible. The renderer process is chosen randomly from suitable renderers 276 // context, if possible. The renderer process is chosen randomly from
267 // that share the same profile and type. 277 // suitable renderers that share the same context and type.
268 // Returns NULL if no suitable renderer process is available, in which case 278 // Returns NULL if no suitable renderer process is available, in which case
269 // the caller is free to create a new renderer. 279 // the caller is free to create a new renderer.
270 static RenderProcessHost* GetExistingProcessHost(Profile* profile, Type type); 280 static RenderProcessHost* GetExistingProcessHost(
281 content::BrowserContext* browser_context, Type type);
271 282
272 // Overrides the default heuristic for limiting the max renderer process 283 // Overrides the default heuristic for limiting the max renderer process
273 // count. This is useful for unit testing process limit behaviors. 284 // count. This is useful for unit testing process limit behaviors.
274 // A value of zero means to use the default heuristic. 285 // A value of zero means to use the default heuristic.
275 static void SetMaxRendererProcessCount(size_t count); 286 static void SetMaxRendererProcessCount(size_t count);
276 287
277 protected: 288 protected:
278 // A proxy for our IPC::Channel that lives on the IO thread (see 289 // A proxy for our IPC::Channel that lives on the IO thread (see
279 // browser_process.h) 290 // browser_process.h)
280 scoped_ptr<IPC::ChannelProxy> channel_; 291 scoped_ptr<IPC::ChannelProxy> channel_;
(...skipping 17 matching lines...) Expand all
298 309
299 // The count of currently swapped out but pending RenderViews. We have 310 // 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 311 // started to swap these in, so the renderer process should not exit if
301 // this count is non-zero. 312 // this count is non-zero.
302 int32 pending_views_; 313 int32 pending_views_;
303 314
304 private: 315 private:
305 // The globally-unique identifier for this RPH. 316 // The globally-unique identifier for this RPH.
306 int id_; 317 int id_;
307 318
308 Profile* profile_; 319 content::BrowserContext* browser_context_;
309 320
310 // set of listeners that expect the renderer process to close 321 // set of listeners that expect the renderer process to close
311 std::set<int> listeners_expecting_close_; 322 std::set<int> listeners_expecting_close_;
312 323
313 // True if the process can be shut down suddenly. If this is true, then we're 324 // 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 325 // 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 326 // it's false, then specific RenderViews might still be allowed to be shutdown
316 // suddenly by checking their SuddenTerminationAllowed() flag. This can occur 327 // 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 328 // if one tab has an unload event listener but another tab in the same process
318 // doesn't. 329 // doesn't.
(...skipping 11 matching lines...) Expand all
330 341
331 DISALLOW_COPY_AND_ASSIGN(RenderProcessHost); 342 DISALLOW_COPY_AND_ASSIGN(RenderProcessHost);
332 }; 343 };
333 344
334 // Factory object for RenderProcessHosts. Using this factory allows tests to 345 // Factory object for RenderProcessHosts. Using this factory allows tests to
335 // swap out a different one to use a TestRenderProcessHost. 346 // swap out a different one to use a TestRenderProcessHost.
336 class RenderProcessHostFactory { 347 class RenderProcessHostFactory {
337 public: 348 public:
338 virtual ~RenderProcessHostFactory() {} 349 virtual ~RenderProcessHostFactory() {}
339 virtual RenderProcessHost* CreateRenderProcessHost( 350 virtual RenderProcessHost* CreateRenderProcessHost(
340 Profile* profile) const = 0; 351 content::BrowserContext* browser_context) const = 0;
341 }; 352 };
342 353
343 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ 354 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_message_filter.cc ('k') | content/browser/renderer_host/render_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698