LCOV - code coverage report
Current view: directory - ipc/chromium/src/chrome/common - child_process.h (source / functions) Found Hit Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2012-06-02 Functions: 2 2 100.0 %

       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
       3                 : // found in the LICENSE file.
       4                 : 
       5                 : #ifndef CHROME_COMMON_CHILD_PROCESS_H__
       6                 : #define CHROME_COMMON_CHILD_PROCESS_H__
       7                 : 
       8                 : #include <string>
       9                 : #include <vector>
      10                 : #include "base/basictypes.h"
      11                 : #include "base/message_loop.h"
      12                 : #include "base/scoped_ptr.h"
      13                 : #include "base/waitable_event.h"
      14                 : 
      15                 : class ChildThread;
      16                 : 
      17                 : 
      18                 : // Base class for child processes of the browser process (i.e. renderer and
      19                 : // plugin host). This is a singleton object for each child process.
      20                 : class ChildProcess {
      21                 :  public:
      22                 :   // Child processes should have an object that derives from this class.  The
      23                 :   // constructor will return once ChildThread has started.
      24                 :   ChildProcess(ChildThread* child_thread);
      25                 :   virtual ~ChildProcess();
      26                 : 
      27                 :   // Getter for this process' main thread.
      28               2 :   ChildThread* child_thread() { return child_thread_.get(); }
      29                 : 
      30                 :   // A global event object that is signalled when the main thread's message
      31                 :   // loop exits.  This gives background threads a way to observe the main
      32                 :   // thread shutting down.  This can be useful when a background thread is
      33                 :   // waiting for some information from the browser process.  If the browser
      34                 :   // process goes away prematurely, the background thread can at least notice
      35                 :   // the child processes's main thread exiting to determine that it should give
      36                 :   // up waiting.
      37                 :   // For example, see the renderer code used to implement
      38                 :   // webkit_glue::GetCookies.
      39                 :   base::WaitableEvent* GetShutDownEvent();
      40                 : 
      41                 :   // These are used for ref-counting the child process.  The process shuts
      42                 :   // itself down when the ref count reaches 0.
      43                 :   // For example, in the renderer process, generally each tab managed by this
      44                 :   // process will hold a reference to the process, and release when closed.
      45                 :   void AddRefProcess();
      46                 :   void ReleaseProcess();
      47                 : 
      48                 :   // Getter for the one ChildProcess object for this process.
      49               2 :   static ChildProcess* current() { return child_process_; }
      50                 : 
      51                 :  private:
      52                 :   // NOTE: make sure that child_thread_ is listed before shutdown_event_, since
      53                 :   // it depends on it (indirectly through IPC::SyncChannel).
      54                 :   scoped_ptr<ChildThread> child_thread_;
      55                 : 
      56                 :   int ref_count_;
      57                 : 
      58                 :   // An event that will be signalled when we shutdown.
      59                 :   base::WaitableEvent shutdown_event_;
      60                 : 
      61                 :   // The singleton instance for this process.
      62                 :   static ChildProcess* child_process_;
      63                 : 
      64                 :   DISALLOW_EVIL_CONSTRUCTORS(ChildProcess);
      65                 : };
      66                 : 
      67                 : #endif  // CHROME_COMMON_CHILD_PROCESS_H__

Generated by: LCOV version 1.7