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

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

Issue 10796099: Introducing remoting::Stoppable helper base class implementing asynchronous shutdown on a specific t (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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_thread.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/memory/scoped_ptr.h"
10 #include "base/message_loop.h"
11 #include "base/single_thread_task_runner.h"
12
13 class MessageLoop;
14
15 namespace remoting {
16
17 // This class along with |scoped_refptr| provides automatic life time management
18 // for a message loop. The message loop is stopped when the last |scoped_refptr|
19 // reference to |AutoMessageLoop| is deleted.
20 //
21 // Unlike |AutoThread| this class does not manage its own life time. It expects
22 // that |this| to be deleted sometime after Run() method is exited.
23 class AutoMessageLoop : public base::SingleThreadTaskRunner {
24 public:
25 explicit AutoMessageLoop(MessageLoop::Type type);
26 virtual ~AutoMessageLoop();
27
28 // A wapper around the corresponding method of |MessageLoop|.
29 void Run();
30
31 // SingleThreadTaskRunner implementation
32 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
33 const base::Closure& task,
34 base::TimeDelta delay) OVERRIDE;
35 virtual bool PostNonNestableDelayedTask(
36 const tracked_objects::Location& from_here,
37 const base::Closure& task,
38 base::TimeDelta delay) OVERRIDE;
39 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
40
41 protected:
42 // Quits the message loop by posting MessageLoop::QuitClosure.
43 virtual void OnDestruct() const OVERRIDE;
44
45 private:
46 scoped_ptr<MessageLoop> message_loop_;
47
48 DISALLOW_COPY_AND_ASSIGN(AutoMessageLoop);
49 };
50
51 } // namespace remoting
52
53 #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_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698