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

Side by Side Diff: media/audio/scoped_task_runner_observer.h

Issue 66183002: Replace MessageLoopProxy with SingleThreadTaskRunner for the rest of media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win and audio tests Created 6 years, 11 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 | « media/audio/scoped_loop_observer.cc ('k') | media/audio/scoped_task_runner_observer.cc » ('j') | no next file with comments »
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 MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_
6 #define MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop/message_loop.h"
10
11 namespace base {
12 class SingleThreadTaskRunner;
13 class WaitableEvent;
14 }
15
16 namespace media {
17
18 // A common base class for AudioOutputDevice and AudioInputDevice that manages
19 // a task runner and monitors it for destruction. If the object goes out of
20 // scope before the task runner, the object will automatically remove itself
21 // from the task runner's list of destruction observers.
22 // NOTE: The class that inherits from this class must implement the
23 // WillDestroyCurrentMessageLoop virtual method from DestructionObserver.
24 class ScopedTaskRunnerObserver
25 : public base::MessageLoop::DestructionObserver {
26 public:
27 explicit ScopedTaskRunnerObserver(
28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
29
30 protected:
31 virtual ~ScopedTaskRunnerObserver();
32
33 // Accessor to the loop that's used by the derived class.
34 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner() {
35 return task_runner_;
36 }
37
38 private:
39 // Call to add or remove ourselves from the list of destruction observers for
40 // the message loop.
41 void ObserveLoopDestruction(bool enable, base::WaitableEvent* done);
42
43 // A pointer to the task runner. In case it gets destroyed before this object
44 // goes out of scope, PostTask() etc will fail but not crash.
45 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
46
47 DISALLOW_COPY_AND_ASSIGN(ScopedTaskRunnerObserver);
48 };
49
50 } // namespace media.
51
52 #endif // MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_
OLDNEW
« no previous file with comments | « media/audio/scoped_loop_observer.cc ('k') | media/audio/scoped_task_runner_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698