OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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. | |
4 | |
5 #include "remoting/base/auto_thread.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/message_loop.h" | |
9 | |
10 namespace remoting { | |
11 | |
12 AutoThread::AutoThread(const char* name, | |
13 scoped_refptr<base::SingleThreadTaskRunner> parent) | |
14 : parent_(parent), | |
15 thread_(name) { | |
16 } | |
17 | |
18 AutoThread::~AutoThread() { | |
19 thread_.Stop(); | |
Sergey Ulanov
2012/07/23 22:44:37
Ref-count may go to zero on any thread, but you ca
alexeypa (please no reviews)
2012/07/23 23:44:53
It is partially addressed. AutoThread is destroyed
| |
20 } | |
21 | |
22 bool AutoThread::Start() { | |
23 return thread_.Start(); | |
24 } | |
25 | |
26 bool AutoThread::StartWithOptions(const base::Thread::Options& options) { | |
27 return thread_.StartWithOptions(options); | |
28 } | |
29 | |
30 bool AutoThread::PostDelayedTask( | |
31 const tracked_objects::Location& from_here, | |
32 const base::Closure& task, | |
33 base::TimeDelta delay) { | |
34 thread_.message_loop()->PostDelayedTask(from_here, task, delay); | |
35 return true; | |
36 } | |
37 | |
38 bool AutoThread::PostNonNestableDelayedTask( | |
39 const tracked_objects::Location& from_here, | |
40 const base::Closure& task, | |
41 base::TimeDelta delay) { | |
42 thread_.message_loop()->PostNonNestableDelayedTask(from_here, task, delay); | |
43 return true; | |
44 } | |
45 | |
46 bool AutoThread::RunsTasksOnCurrentThread() const { | |
47 return MessageLoop::current() == thread_.message_loop(); | |
48 } | |
49 | |
50 void AutoThread::OnDestruct() const { | |
51 // Deletes |this| on the parent's message loop. | |
52 parent_->DeleteSoon(FROM_HERE, this); | |
53 } | |
54 | |
55 } // namespace remoting | |
OLD | NEW |