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

Side by Side Diff: media/base/serial_runner.cc

Issue 275673002: Remove completion callbacks from AudioRenderer::Play/Pause(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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/base/serial_runner.h ('k') | media/base/serial_runner_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "media/base/serial_runner.h" 5 #include "media/base/serial_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 // Converts a Closure into a bound function accepting a PipelineStatusCB.
16 static void RunClosure(
17 const base::Closure& closure,
18 const PipelineStatusCB& status_cb) {
19 closure.Run();
20 status_cb.Run(PIPELINE_OK);
21 }
22
15 // Converts a bound function accepting a Closure into a bound function 23 // Converts a bound function accepting a Closure into a bound function
16 // accepting a PipelineStatusCB. Since closures have no way of reporting a 24 // accepting a PipelineStatusCB. Since closures have no way of reporting a
17 // status |status_cb| is executed with PIPELINE_OK. 25 // status |status_cb| is executed with PIPELINE_OK.
18 static void RunBoundClosure( 26 static void RunBoundClosure(
19 const SerialRunner::BoundClosure& bound_closure, 27 const SerialRunner::BoundClosure& bound_closure,
20 const PipelineStatusCB& status_cb) { 28 const PipelineStatusCB& status_cb) {
21 bound_closure.Run(base::Bind(status_cb, PIPELINE_OK)); 29 bound_closure.Run(base::Bind(status_cb, PIPELINE_OK));
22 } 30 }
23 31
24 // Runs |status_cb| with |last_status| on |task_runner|. 32 // Runs |status_cb| with |last_status| on |task_runner|.
25 static void RunOnTaskRunner( 33 static void RunOnTaskRunner(
26 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 34 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
27 const PipelineStatusCB& status_cb, 35 const PipelineStatusCB& status_cb,
28 PipelineStatus last_status) { 36 PipelineStatus last_status) {
29 // Force post to permit cancellation of a series in the scenario where all 37 // Force post to permit cancellation of a series in the scenario where all
30 // bound functions run on the same thread. 38 // bound functions run on the same thread.
31 task_runner->PostTask(FROM_HERE, base::Bind(status_cb, last_status)); 39 task_runner->PostTask(FROM_HERE, base::Bind(status_cb, last_status));
32 } 40 }
33 41
34 SerialRunner::Queue::Queue() {} 42 SerialRunner::Queue::Queue() {}
35 SerialRunner::Queue::~Queue() {} 43 SerialRunner::Queue::~Queue() {}
36 44
45 void SerialRunner::Queue::Push(const base::Closure& closure) {
46 bound_fns_.push(base::Bind(&RunClosure, closure));
47 }
48
37 void SerialRunner::Queue::Push( 49 void SerialRunner::Queue::Push(
38 const BoundClosure& bound_closure) { 50 const BoundClosure& bound_closure) {
39 bound_fns_.push(base::Bind(&RunBoundClosure, bound_closure)); 51 bound_fns_.push(base::Bind(&RunBoundClosure, bound_closure));
40 } 52 }
41 53
42 void SerialRunner::Queue::Push( 54 void SerialRunner::Queue::Push(
43 const BoundPipelineStatusCB& bound_status_cb) { 55 const BoundPipelineStatusCB& bound_status_cb) {
44 bound_fns_.push(bound_status_cb); 56 bound_fns_.push(bound_status_cb);
45 } 57 }
46 58
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 104 }
93 105
94 BoundPipelineStatusCB bound_fn = bound_fns_.Pop(); 106 BoundPipelineStatusCB bound_fn = bound_fns_.Pop();
95 bound_fn.Run(base::Bind( 107 bound_fn.Run(base::Bind(
96 &RunOnTaskRunner, 108 &RunOnTaskRunner,
97 task_runner_, 109 task_runner_,
98 base::Bind(&SerialRunner::RunNextInSeries, weak_factory_.GetWeakPtr()))); 110 base::Bind(&SerialRunner::RunNextInSeries, weak_factory_.GetWeakPtr())));
99 } 111 }
100 112
101 } // namespace media 113 } // namespace media
OLDNEW
« no previous file with comments | « media/base/serial_runner.h ('k') | media/base/serial_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698