LCOV - code coverage report
Current view: directory - ipc/chromium/src/chrome/common - child_process.cc (source / functions) Found Hit Coverage
Test: app.info Lines: 31 7 22.6 %
Date: 2012-06-02 Functions: 6 1 16.7 %

       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                 : #include "chrome/common/child_process.h"
       6                 : 
       7                 : #include "base/basictypes.h"
       8                 : #include "base/string_util.h"
       9                 : #include "chrome/common/child_thread.h"
      10                 : 
      11                 : ChildProcess* ChildProcess::child_process_;
      12                 : 
      13               1 : ChildProcess::ChildProcess(ChildThread* child_thread)
      14                 :     : child_thread_(child_thread),
      15                 :       ref_count_(0),
      16               1 :       shutdown_event_(true, false) {
      17               1 :   DCHECK(!child_process_);
      18               1 :   child_process_ = this;
      19               1 :   if (child_thread_.get())  // null in unittests.
      20               1 :     child_thread_->Run();
      21               1 : }
      22                 : 
      23               0 : ChildProcess::~ChildProcess() {
      24               0 :   DCHECK(child_process_ == this);
      25                 : 
      26                 :   // Signal this event before destroying the child process.  That way all
      27                 :   // background threads can cleanup.
      28                 :   // For example, in the renderer the RenderThread instances will be able to
      29                 :   // notice shutdown before the render process begins waiting for them to exit.
      30               0 :   shutdown_event_.Signal();
      31                 : 
      32               0 :   if (child_thread_.get())
      33               0 :     child_thread_->Stop();
      34                 : 
      35               0 :   child_process_ = NULL;
      36               0 : }
      37                 : 
      38               0 : void ChildProcess::AddRefProcess() {
      39               0 :   DCHECK(!child_thread_.get() ||  // null in unittests.
      40               0 :          MessageLoop::current() == child_thread_->message_loop());
      41               0 :   ref_count_++;
      42               0 : }
      43                 : 
      44               0 : void ChildProcess::ReleaseProcess() {
      45               0 :   DCHECK(!child_thread_.get() ||  // null in unittests.
      46               0 :          MessageLoop::current() == child_thread_->message_loop());
      47               0 :   DCHECK(ref_count_);
      48               0 :   DCHECK(child_process_);
      49               0 :   if (--ref_count_)
      50               0 :     return;
      51                 : 
      52               0 :   if (child_thread_.get())  // null in unittests.
      53               0 :     child_thread_->OnProcessFinalRelease();
      54                 : }
      55                 : 
      56               0 : base::WaitableEvent* ChildProcess::GetShutDownEvent() {
      57               0 :   DCHECK(child_process_);
      58               0 :   return &child_process_->shutdown_event_;
      59                 : }

Generated by: LCOV version 1.7