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" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
8 #include "base/time/time.h" | 11 #include "base/time/time.h" |
9 #include "content/child/child_process.h" | 12 #include "content/child/child_process.h" |
10 | 13 |
11 namespace content { | 14 namespace content { |
12 | 15 |
13 ScopedChildProcessReference::ScopedChildProcessReference() | 16 ScopedChildProcessReference::ScopedChildProcessReference() |
14 : has_reference_(true) { | 17 : has_reference_(true) { |
15 ChildProcess::current()->AddRefProcess(); | 18 ChildProcess::current()->AddRefProcess(); |
16 } | 19 } |
17 | 20 |
18 ScopedChildProcessReference::~ScopedChildProcessReference() { | 21 ScopedChildProcessReference::~ScopedChildProcessReference() { |
19 if (has_reference_) | 22 if (has_reference_) |
20 ChildProcess::current()->ReleaseProcess(); | 23 ChildProcess::current()->ReleaseProcess(); |
21 } | 24 } |
22 | 25 |
23 void ScopedChildProcessReference::ReleaseWithDelay( | 26 void ScopedChildProcessReference::ReleaseWithDelay( |
24 const base::TimeDelta& delay) { | 27 const base::TimeDelta& delay) { |
25 DCHECK(has_reference_); | 28 DCHECK(has_reference_); |
26 base::MessageLoop::current()->PostDelayedTask( | 29 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
27 FROM_HERE, | 30 FROM_HERE, base::Bind(&ChildProcess::ReleaseProcess, |
28 base::Bind(&ChildProcess::ReleaseProcess, | 31 base::Unretained(ChildProcess::current())), |
29 base::Unretained(ChildProcess::current())), | |
30 delay); | 32 delay); |
31 has_reference_ = false; | 33 has_reference_ = false; |
32 } | 34 } |
33 | 35 |
34 } // namespace content | 36 } // namespace content |
OLD | NEW |