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

Side by Side Diff: remoting/base/auto_message_loop.h

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: CR feedback Created 8 years, 3 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
« no previous file with comments | « no previous file | remoting/base/auto_message_loop.cc » ('j') | remoting/base/auto_message_loop.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef REMOTING_BASE_AUTO_MESSAGE_LOOP_H_
6 #define REMOTING_BASE_AUTO_MESSAGE_LOOP_H_
7
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h"
12 #include "base/single_thread_task_runner.h"
13
14 class MessageLoop;
15
16 namespace remoting {
17
18 // This class provides automatic life time management for a single thread task
19 // runner. The task runner is stopped when the last reference to
20 // |AutoMessageLoop| is dropped.
Wez 2012/08/28 17:34:53 nit: It doesn't actually do that any more, though;
alexeypa (please no reviews) 2012/08/28 19:18:51 It is technically true. It is hard to figure out t
21 class AutoMessageLoop : public base::SingleThreadTaskRunner {
Wez 2012/08/28 17:34:53 nit: AutoMessageLoop doesn't seem the right name f
alexeypa (please no reviews) 2012/08/28 19:18:51 Sounds like a good name. AutoMessageLoop is shorte
22 public:
23 // |parent| is optional and may be NULL. |stop_callback| can be called on any
24 // thread.
Wez 2012/08/28 17:34:53 nit: Clarify what |stop_callback| is for / when it
alexeypa (please no reviews) 2012/08/28 19:18:51 Done.
25 AutoMessageLoop(base::SingleThreadTaskRunner* parent,
Wez 2012/08/28 17:34:53 nit: scoped_refptr<base::SingleThreadTaskRunner>,
Wez 2012/08/28 17:34:53 Why do you need the |parent| reference? The purpos
alexeypa (please no reviews) 2012/08/28 19:18:51 Done.
alexeypa (please no reviews) 2012/08/28 19:18:51 This is a way to express parent-child relations be
26 base::SingleThreadTaskRunner* task_runner,
27 const base::Closure& stop_callback);
28
29 // SingleThreadTaskRunner implementation
30 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
31 const base::Closure& task,
32 base::TimeDelta delay) OVERRIDE;
33 virtual bool PostNonNestableDelayedTask(
34 const tracked_objects::Location& from_here,
35 const base::Closure& task,
36 base::TimeDelta delay) OVERRIDE;
37 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
38
39 protected:
40 // Quits the message loop by invoking |stop_callback_|.
41 virtual void OnDestruct() const OVERRIDE;
42
43 private:
44 friend class base::DeleteHelper<AutoMessageLoop>;
45
46 virtual ~AutoMessageLoop();
47
48 // An optional reference to the parent message loop to keep it alive.
49 scoped_refptr<base::SingleThreadTaskRunner> parent_;
50
51 // This callback quits |task_runner_|. It can be run on any thread.
52 base::Closure stop_callback_;
53
54 // The wrapped task runner.
55 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
56
57 DISALLOW_COPY_AND_ASSIGN(AutoMessageLoop);
58 };
59
60 } // namespace remoting
61
62 #endif // REMOTING_BASE_AUTO_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/base/auto_message_loop.cc » ('j') | remoting/base/auto_message_loop.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698