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

Side by Side Diff: chrome/common/child_process.h

Issue 155876: Revert r21117 as it caused reliability failures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 CHROME_COMMON_CHILD_PROCESS_H__ 5 #ifndef CHROME_COMMON_CHILD_PROCESS_H__
6 #define CHROME_COMMON_CHILD_PROCESS_H__ 6 #define CHROME_COMMON_CHILD_PROCESS_H__
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/thread.h"
11 #include "base/waitable_event.h" 10 #include "base/waitable_event.h"
12 #include "chrome/common/child_thread.h" 11
12 class ChildThread;
13 13
14 // Base class for child processes of the browser process (i.e. renderer and 14 // Base class for child processes of the browser process (i.e. renderer and
15 // plugin host). This is a singleton object for each child process. 15 // plugin host). This is a singleton object for each child process.
16 class ChildProcess { 16 class ChildProcess {
17 public: 17 public:
18 // Child processes should have an object that derives from this class. 18 // Child processes should have an object that derives from this class. The
19 ChildProcess(); 19 // constructor will return once ChildThread has started.
20 ChildProcess(ChildThread* child_thread);
20 virtual ~ChildProcess(); 21 virtual ~ChildProcess();
21 22
22 // Getter for the child process' main thread. 23 // Getter for this process' main thread.
23 ChildThread* main_thread() { return main_thread_.get(); } 24 ChildThread* child_thread() { return child_thread_.get(); }
24 void set_main_thread(ChildThread* thread) { main_thread_.reset(thread); }
25
26 MessageLoop* io_message_loop() { return io_thread_.message_loop(); }
27 25
28 // A global event object that is signalled when the main thread's message 26 // A global event object that is signalled when the main thread's message
29 // loop exits. This gives background threads a way to observe the main 27 // loop exits. This gives background threads a way to observe the main
30 // thread shutting down. This can be useful when a background thread is 28 // thread shutting down. This can be useful when a background thread is
31 // waiting for some information from the browser process. If the browser 29 // waiting for some information from the browser process. If the browser
32 // process goes away prematurely, the background thread can at least notice 30 // process goes away prematurely, the background thread can at least notice
33 // the child processes's main thread exiting to determine that it should give 31 // the child processes's main thread exiting to determine that it should give
34 // up waiting. 32 // up waiting.
35 // For example, see the renderer code used to implement 33 // For example, see the renderer code used to implement
36 // webkit_glue::GetCookies. 34 // webkit_glue::GetCookies.
37 base::WaitableEvent* GetShutDownEvent(); 35 base::WaitableEvent* GetShutDownEvent();
38 36
39 // These are used for ref-counting the child process. The process shuts 37 // These are used for ref-counting the child process. The process shuts
40 // itself down when the ref count reaches 0. 38 // itself down when the ref count reaches 0.
41 // For example, in the renderer process, generally each tab managed by this 39 // For example, in the renderer process, generally each tab managed by this
42 // process will hold a reference to the process, and release when closed. 40 // process will hold a reference to the process, and release when closed.
43 void AddRefProcess(); 41 void AddRefProcess();
44 void ReleaseProcess(); 42 void ReleaseProcess();
45 43
46 // Getter for the one ChildProcess object for this process. 44 // Getter for the one ChildProcess object for this process.
47 static ChildProcess* current() { return child_process_; } 45 static ChildProcess* current() { return child_process_; }
48 46
49 private: 47 private:
48 // NOTE: make sure that child_thread_ is listed before shutdown_event_, since
49 // it depends on it (indirectly through IPC::SyncChannel).
50 scoped_ptr<ChildThread> child_thread_;
51
50 int ref_count_; 52 int ref_count_;
51 53
52 // An event that will be signalled when we shutdown. 54 // An event that will be signalled when we shutdown.
53 base::WaitableEvent shutdown_event_; 55 base::WaitableEvent shutdown_event_;
54 56
55 // The thread that handles IO events.
56 base::Thread io_thread_;
57
58 // NOTE: make sure that main_thread_ is listed after shutdown_event_, since
59 // it depends on it (indirectly through IPC::SyncChannel). Same for
60 // io_thread_.
61 scoped_ptr<ChildThread> main_thread_;
62
63 // The singleton instance for this process. 57 // The singleton instance for this process.
64 static ChildProcess* child_process_; 58 static ChildProcess* child_process_;
65 59
66 DISALLOW_EVIL_CONSTRUCTORS(ChildProcess); 60 DISALLOW_EVIL_CONSTRUCTORS(ChildProcess);
67 }; 61 };
68 62
69 #endif // CHROME_COMMON_CHILD_PROCESS_H__ 63 #endif // CHROME_COMMON_CHILD_PROCESS_H__
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/browser_render_process_host.cc ('k') | chrome/common/child_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698