1 // Copyright 2013 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.
5 #include "content/child/scoped_child_process_reference.h"
8 #include "base/time/time.h"
9 #include "content/child/child_process.h"
13 ScopedChildProcessReference::ScopedChildProcessReference()
14 : has_reference_(true) {
15 ChildProcess::current()->AddRefProcess();
18 ScopedChildProcessReference::~ScopedChildProcessReference() {
20 ChildProcess::current()->ReleaseProcess();
23 void ScopedChildProcessReference::ReleaseWithDelay(
24 const base::TimeDelta
& delay
) {
25 DCHECK(has_reference_
);
26 base::MessageLoop::current()->PostDelayedTask(
28 base::Bind(&ChildProcess::ReleaseProcess
,
29 base::Unretained(ChildProcess::current())),
31 has_reference_
= false;
34 } // namespace content