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 #include "chrome/common/child_process.h" 8 9 #include "base/basictypes.h" 10 #include "base/string_util.h" 11 #include "chrome/common/child_thread.h" 12 13 ChildProcess* ChildProcess::child_process_; 14 ChildProcess(ChildThread * child_thread)15ChildProcess::ChildProcess(ChildThread* child_thread) 16 : child_thread_(child_thread) { 17 DCHECK(!child_process_); 18 child_process_ = this; 19 if (child_thread_.get()) // null in unittests. 20 child_thread_->Run(); 21 } 22 ~ChildProcess()23ChildProcess::~ChildProcess() { 24 DCHECK(child_process_ == this); 25 26 if (child_thread_.get()) child_thread_->Stop(); 27 28 child_process_ = NULL; 29 } 30