| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_ | 5 #ifndef MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_ |
| 6 #define MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_ | 6 #define MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // from the task runner's list of destruction observers. | 21 // from the task runner's list of destruction observers. |
| 22 // NOTE: The class that inherits from this class must implement the | 22 // NOTE: The class that inherits from this class must implement the |
| 23 // WillDestroyCurrentMessageLoop virtual method from DestructionObserver. | 23 // WillDestroyCurrentMessageLoop virtual method from DestructionObserver. |
| 24 class ScopedTaskRunnerObserver | 24 class ScopedTaskRunnerObserver |
| 25 : public base::MessageLoop::DestructionObserver { | 25 : public base::MessageLoop::DestructionObserver { |
| 26 public: | 26 public: |
| 27 explicit ScopedTaskRunnerObserver( | 27 explicit ScopedTaskRunnerObserver( |
| 28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 virtual ~ScopedTaskRunnerObserver(); | 31 ~ScopedTaskRunnerObserver() override; |
| 32 | 32 |
| 33 // Accessor to the loop that's used by the derived class. | 33 // Accessor to the loop that's used by the derived class. |
| 34 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner() { | 34 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner() { |
| 35 return task_runner_; | 35 return task_runner_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 // Call to add or remove ourselves from the list of destruction observers for | 39 // Call to add or remove ourselves from the list of destruction observers for |
| 40 // the message loop. | 40 // the message loop. |
| 41 void ObserveLoopDestruction(bool enable, base::WaitableEvent* done); | 41 void ObserveLoopDestruction(bool enable, base::WaitableEvent* done); |
| 42 | 42 |
| 43 // A pointer to the task runner. In case it gets destroyed before this object | 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. | 44 // goes out of scope, PostTask() etc will fail but not crash. |
| 45 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 45 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 46 | 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(ScopedTaskRunnerObserver); | 47 DISALLOW_COPY_AND_ASSIGN(ScopedTaskRunnerObserver); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace media. | 50 } // namespace media. |
| 51 | 51 |
| 52 #endif // MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_ | 52 #endif // MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_ |
| OLD | NEW |