ipc/chromium/src/chrome/common/child_process.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/chrome/common/child_process.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef CHROME_COMMON_CHILD_PROCESS_H__
     1.9 +#define CHROME_COMMON_CHILD_PROCESS_H__
    1.10 +
    1.11 +#include <string>
    1.12 +#include <vector>
    1.13 +#include "base/basictypes.h"
    1.14 +#include "base/message_loop.h"
    1.15 +#include "base/scoped_ptr.h"
    1.16 +#include "base/waitable_event.h"
    1.17 +
    1.18 +class ChildThread;
    1.19 +
    1.20 +
    1.21 +// Base class for child processes of the browser process (i.e. renderer and
    1.22 +// plugin host). This is a singleton object for each child process.
    1.23 +class ChildProcess {
    1.24 + public:
    1.25 +  // Child processes should have an object that derives from this class.  The
    1.26 +  // constructor will return once ChildThread has started.
    1.27 +  ChildProcess(ChildThread* child_thread);
    1.28 +  virtual ~ChildProcess();
    1.29 +
    1.30 +  // Getter for this process' main thread.
    1.31 +  ChildThread* child_thread() { return child_thread_.get(); }
    1.32 +
    1.33 +  // A global event object that is signalled when the main thread's message
    1.34 +  // loop exits.  This gives background threads a way to observe the main
    1.35 +  // thread shutting down.  This can be useful when a background thread is
    1.36 +  // waiting for some information from the browser process.  If the browser
    1.37 +  // process goes away prematurely, the background thread can at least notice
    1.38 +  // the child processes's main thread exiting to determine that it should give
    1.39 +  // up waiting.
    1.40 +  // For example, see the renderer code used to implement
    1.41 +  // webkit_glue::GetCookies.
    1.42 +  base::WaitableEvent* GetShutDownEvent();
    1.43 +
    1.44 +  // These are used for ref-counting the child process.  The process shuts
    1.45 +  // itself down when the ref count reaches 0.
    1.46 +  // For example, in the renderer process, generally each tab managed by this
    1.47 +  // process will hold a reference to the process, and release when closed.
    1.48 +  void AddRefProcess();
    1.49 +  void ReleaseProcess();
    1.50 +
    1.51 +  // Getter for the one ChildProcess object for this process.
    1.52 +  static ChildProcess* current() { return child_process_; }
    1.53 +
    1.54 + private:
    1.55 +  // NOTE: make sure that child_thread_ is listed before shutdown_event_, since
    1.56 +  // it depends on it (indirectly through IPC::SyncChannel).
    1.57 +  scoped_ptr<ChildThread> child_thread_;
    1.58 +
    1.59 +  int ref_count_;
    1.60 +
    1.61 +  // An event that will be signalled when we shutdown.
    1.62 +  base::WaitableEvent shutdown_event_;
    1.63 +
    1.64 +  // The singleton instance for this process.
    1.65 +  static ChildProcess* child_process_;
    1.66 +
    1.67 +  DISALLOW_EVIL_CONSTRUCTORS(ChildProcess);
    1.68 +};
    1.69 +
    1.70 +#endif  // CHROME_COMMON_CHILD_PROCESS_H__

mercurial