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 // Base class for child processes of the browser process (i.e. renderer and 20 // plugin host). This is a singleton object for each child process. 21 class ChildProcess { 22 public: 23 // Child processes should have an object that derives from this class. The 24 // constructor will return once ChildThread has started. 25 explicit ChildProcess(ChildThread* child_thread); 26 virtual ~ChildProcess(); 27 28 // Getter for this process' main thread. child_thread()29 ChildThread* child_thread() { return child_thread_.get(); } 30 31 // Getter for the one ChildProcess object for this process. current()32 static ChildProcess* current() { return child_process_; } 33 34 private: 35 // NOTE: make sure that child_thread_ is listed before shutdown_event_, since 36 // it depends on it (indirectly through IPC::SyncChannel). 37 mozilla::UniquePtr<ChildThread> child_thread_; 38 39 // The singleton instance for this process. 40 static ChildProcess* child_process_; 41 42 DISALLOW_EVIL_CONSTRUCTORS(ChildProcess); 43 }; 44 45 #endif // CHROME_COMMON_CHILD_PROCESS_H__ 46