OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/child/scoped_child_process_reference.h" | 5 #include "content/child/scoped_child_process_reference.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "content/child/child_process.h" | 12 #include "content/child/child_process.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 ScopedChildProcessReference::ScopedChildProcessReference() | 16 ScopedChildProcessReference::ScopedChildProcessReference() |
17 : has_reference_(true) { | 17 : has_reference_(true) { |
18 ChildProcess::current()->AddRefProcess(); | 18 ChildProcess::current()->AddRefProcess(); |
19 } | 19 } |
20 | 20 |
21 ScopedChildProcessReference::~ScopedChildProcessReference() { | 21 ScopedChildProcessReference::~ScopedChildProcessReference() { |
22 if (has_reference_) | 22 if (has_reference_) |
23 ChildProcess::current()->ReleaseProcess(); | 23 ChildProcess::current()->ReleaseProcess(); |
24 } | 24 } |
25 | 25 |
26 void ScopedChildProcessReference::ReleaseWithDelay( | 26 void ScopedChildProcessReference::ReleaseWithDelay( |
27 const base::TimeDelta& delay) { | 27 const base::TimeDelta& delay) { |
28 DCHECK(has_reference_); | 28 DCHECK(has_reference_); |
29 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 29 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
30 FROM_HERE, base::Bind(&ChildProcess::ReleaseProcess, | 30 FROM_HERE, base::Bind(&ChildProcess::ReleaseProcess, |
31 base::Unretained(ChildProcess::current())), | 31 base::Unretained(ChildProcess::current())), |
32 delay); | 32 delay); |
33 has_reference_ = false; | 33 has_reference_ = false; |
34 } | 34 } |
35 | 35 |
36 } // namespace content | 36 } // namespace content |
OLD | NEW |