Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: remoting/base/auto_thread.cc

Issue 10829467: [Chromoting] Introducing refcount-based life time management of the message loops in the service (d… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Destructors of ref-counted objects should not be public. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 bool AutoThread::Start() {
19 return thread_.Start();
20 }
21
22 bool AutoThread::StartWithOptions(const base::Thread::Options& options) {
23 return thread_.StartWithOptions(options);
24 }
25
26 bool AutoThread::PostDelayedTask(
27 const tracked_objects::Location& from_here,
28 const base::Closure& task,
29 base::TimeDelta delay) {
30 thread_.message_loop()->PostDelayedTask(from_here, task, delay);
31 return true;
32 }
33
34 bool AutoThread::PostNonNestableDelayedTask(
35 const tracked_objects::Location& from_here,
36 const base::Closure& task,
37 base::TimeDelta delay) {
38 thread_.message_loop()->PostNonNestableDelayedTask(from_here, task, delay);
39 return true;
40 }
41
42 bool AutoThread::RunsTasksOnCurrentThread() const {
43 return MessageLoop::current() == thread_.message_loop();
44 }
45
46 void AutoThread::OnDestruct() const {
47 // Deletes |this| on the parent message loop.
48 parent_->DeleteSoon(FROM_HERE, this);
49 }
50
51 AutoThread::~AutoThread() {
52 thread_.Stop();
Wez 2012/08/24 21:30:49 This arrangement means that once no-one needs the
alexeypa (please no reviews) 2012/08/27 21:19:40 Yeah, it is not good. Taking |thread_| owneship fr
53 }
54
55 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698