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

Side by Side Diff: media/base/audio_output_device_callback_util.h

Issue 1184473002: Add support for the audio-output-device switching IPC mechanism to the renderer lower layers (media… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/audio_output_device_callback_util.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) 2015 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 // Provides an utility class to support invocation of callbacks in the correct
DaleCurtis 2015/06/11 17:58:47 Why not use media::BindToCurrentLoop?
Guido Urdaneta 2015/06/11 20:10:09 Done.
6 // thread for the SwitchOutputDevice operation provided by
7 // media::AudioRendererSink and other related classes.
8 // The rationale for this class is that SwitchOutputDevice operations go
9 // through many layers (i.e., from blink to the browser and back), and
10 // the request can move throughout multiple threads. It is impossible for
11 // the lower layers to know the right thread where the callback should be run.
12 // This class provides a convenient way for users to create callbacks that
13 // can assume they will be run on the correct thread, and for implementors of
14 // SwitchOutputDevice, which can easily invoke the callback without having
15 // to worry about threads.
16 // Note that the methods of this class can be called on any thread, but they
17 // cannot be called concurrently by multiple threads.
18
19 #ifndef MEDIA_BASE_AUDIO_OUTPUT_DEVICE_CALLBACK_UTIL_H_
20 #define MEDIA_BASE_AUDIO_OUTPUT_DEVICE_CALLBACK_UTIL_H_
21
22 #include "base/callback.h"
23 #include "base/single_thread_task_runner.h"
24 #include "media/audio/audio_output_ipc.h"
25
26 namespace media {
27
28 typedef base::Callback<void(SwitchOutputDeviceResult)>
29 SwitchOutputDeviceCallback;
30
31 class MEDIA_EXPORT SwitchOutputDeviceCallbackRunner {
32 public:
33 SwitchOutputDeviceCallbackRunner(
34 scoped_ptr<SwitchOutputDeviceCallback> callback,
35 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner);
36
37 ~SwitchOutputDeviceCallbackRunner();
38
39 // Posts the execution of |callback_| to |callback task runner_|, and
40 // relinquishes ownership of both afterwards. |result| is passed as the
41 // argument for |callback_|.
42 // Calling this method a second time has no effect.
43 void Run(SwitchOutputDeviceResult result);
44
45 private:
46 scoped_ptr<SwitchOutputDeviceCallback> callback_;
47 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_;
48 };
49
50 } // namespace media
51
52 #endif // MEDIA_BASE_AUDIO_OUTPUT_DEVICE_CALLBACK_UTIL_H_
OLDNEW
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/audio_output_device_callback_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698