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

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: 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
« 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/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 provides automatic life time management for a message loop.
18 // The message loop is exited (i.e. Run() method exits) when the last reference
19 // to |AutoMessageLoop| is dropped. |AutoMessageLoop| does not control the life
20 // time of the message loop object.
21 class AutoMessageLoop : public base::SingleThreadTaskRunner {
22 public:
23 // |message_loop| must outlive |AutoMessageLoop|.
24 explicit AutoMessageLoop(MessageLoop* message_loop);
25
26 // SingleThreadTaskRunner implementation
27 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
28 const base::Closure& task,
29 base::TimeDelta delay) OVERRIDE;
30 virtual bool PostNonNestableDelayedTask(
31 const tracked_objects::Location& from_here,
32 const base::Closure& task,
33 base::TimeDelta delay) OVERRIDE;
34 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
35
36 protected:
37 // Quits the message loop by posting MessageLoop::QuitClosure.
38 virtual void OnDestruct() const OVERRIDE;
39
40 private:
41 virtual ~AutoMessageLoop();
42
43 friend class base::DeleteHelper<AutoMessageLoop>;
44
45 MessageLoop* message_loop_;
46
47 DISALLOW_COPY_AND_ASSIGN(AutoMessageLoop);
48 };
49
50 } // namespace remoting
51
52 #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