Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
4 : // Use of this source code is governed by a BSD-style license that can be
5 : // found in the LICENSE file.
6 :
7 : #ifndef CHROME_COMMON_CHILD_PROCESS_H__
8 : #define CHROME_COMMON_CHILD_PROCESS_H__
9 :
10 : #include <string>
11 : #include <vector>
12 : #include "base/basictypes.h"
13 : #include "base/message_loop.h"
14 : #include "base/waitable_event.h"
15 : #include "mozilla/UniquePtr.h"
16 :
17 : class ChildThread;
18 :
19 :
20 : // Base class for child processes of the browser process (i.e. renderer and
21 : // plugin host). This is a singleton object for each child process.
22 : class ChildProcess {
23 : public:
24 : // Child processes should have an object that derives from this class. The
25 : // constructor will return once ChildThread has started.
26 : explicit ChildProcess(ChildThread* child_thread);
27 : virtual ~ChildProcess();
28 :
29 : // Getter for this process' main thread.
30 21 : ChildThread* child_thread() { return child_thread_.get(); }
31 :
32 : // Getter for the one ChildProcess object for this process.
33 21 : static ChildProcess* current() { return child_process_; }
34 :
35 : private:
36 : // NOTE: make sure that child_thread_ is listed before shutdown_event_, since
37 : // it depends on it (indirectly through IPC::SyncChannel).
38 : mozilla::UniquePtr<ChildThread> child_thread_;
39 :
40 : // The singleton instance for this process.
41 : static ChildProcess* child_process_;
42 :
43 : DISALLOW_EVIL_CONSTRUCTORS(ChildProcess);
44 : };
45 :
46 : #endif // CHROME_COMMON_CHILD_PROCESS_H__
|