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

Side by Side Diff: base/mp/mp_child_process.h

Issue 1625015: Refactor ChildProcess and related classes to create a framework outside of br... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years, 8 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
« no previous file with comments | « base/mp/message_router.cc ('k') | base/mp/mp_child_process.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_MP_CHILD_PROCESS_H__
6 #define BASE_MP_CHILD_PROCESS_H__
7
8 #include "base/basictypes.h"
9 #include "base/scoped_ptr.h"
10 #include "base/thread.h"
11 #include "base/waitable_event.h"
12 #include "base/mp/mp_child_thread.h"
13
14 namespace base {
15
16 // Base class for child processes of the browser process (i.e. renderer and
17 // plugin host). This is a singleton object for each child process.
18 class MpChildProcess {
19 public:
20 // Child processes should have an object that derives from this class.
21 MpChildProcess();
22 virtual ~MpChildProcess();
23
24 // Derived classes should override this method to return a pointer to the
25 // application IO thread.
26 virtual base::Thread* GetIOThread() = 0;
27
28 // Getter for the child process' main thread.
29 MpChildThread* main_thread() { return main_thread_.get(); }
30 void set_main_thread(MpChildThread* thread) { main_thread_.reset(thread); }
31
32 MessageLoop* io_message_loop() { return GetIOThread()->message_loop(); }
33
34 // A global event object that is signalled when the main thread's message
35 // loop exits. This gives background threads a way to observe the main
36 // thread shutting down. This can be useful when a background thread is
37 // waiting for some information from the browser process. If the browser
38 // process goes away prematurely, the background thread can at least notice
39 // the child processes's main thread exiting to determine that it should give
40 // up waiting.
41 // For example, see the renderer code used to implement
42 // webkit_glue::GetCookies.
43 base::WaitableEvent* GetShutDownEvent();
44
45 // These are used for ref-counting the child process. The process shuts
46 // itself down when the ref count reaches 0.
47 // For example, in the renderer process, generally each tab managed by this
48 // process will hold a reference to the process, and release when closed.
49 void AddRefProcess();
50 void ReleaseProcess();
51
52 // Getter for the one MpChildProcess object for this process.
53 static MpChildProcess* current() { return child_process_; }
54 private:
55 int ref_count_;
56
57 // An event that will be signalled when we shutdown.
58 base::WaitableEvent shutdown_event_;
59
60 // NOTE: make sure that main_thread_ is listed after shutdown_event_, since
61 // it depends on it (indirectly through IPC::SyncChannel). Same for
62 // io_thread_.
63 scoped_ptr<MpChildThread> main_thread_;
64
65 // The singleton instance for this process.
66 static MpChildProcess* child_process_;
67
68 DISALLOW_COPY_AND_ASSIGN(MpChildProcess);
69 };
70
71 } // namespace base
72
73 #endif // BASE_MP_CHILD_PROCESS_H__
OLDNEW
« no previous file with comments | « base/mp/message_router.cc ('k') | base/mp/mp_child_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698