Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / child / scoped_child_process_reference.cc
blob757195708ff8f28c0e503ac10402f1c5d00234ed
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"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "base/time/time.h"
12 #include "content/child/child_process.h"
14 namespace content {
16 ScopedChildProcessReference::ScopedChildProcessReference()
17 : has_reference_(true) {
18 ChildProcess::current()->AddRefProcess();
21 ScopedChildProcessReference::~ScopedChildProcessReference() {
22 if (has_reference_)
23 ChildProcess::current()->ReleaseProcess();
26 void ScopedChildProcessReference::ReleaseWithDelay(
27 const base::TimeDelta& delay) {
28 DCHECK(has_reference_);
29 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
30 FROM_HERE, base::Bind(&ChildProcess::ReleaseProcess,
31 base::Unretained(ChildProcess::current())),
32 delay);
33 has_reference_ = false;
36 } // namespace content