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

Unified Diff: media/midi/midi_scheduler.cc

Issue 1060553003: Web MIDI: call AccumulateMidiBytesSent() after operation finished (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/midi/midi_scheduler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/midi_scheduler.cc
diff --git a/media/midi/midi_scheduler.cc b/media/midi/midi_scheduler.cc
index cc9373327fe23e41cea9e808e3c4234a180349e6..a65e703673b839c025e1d3384795000132cadb6d 100644
--- a/media/midi/midi_scheduler.cc
+++ b/media/midi/midi_scheduler.cc
@@ -11,7 +11,9 @@
namespace media {
-MidiScheduler::MidiScheduler() : weak_factory_(this) {
+MidiScheduler::MidiScheduler(MidiManager* manager)
+ : manager_(manager),
+ weak_factory_(this) {
}
MidiScheduler::~MidiScheduler() {
@@ -26,7 +28,11 @@ void MidiScheduler::PostSendDataTask(MidiManagerClient* client,
DCHECK(client);
const base::Closure& weak_closure = base::Bind(
- &MidiScheduler::InvokeClosure, weak_factory_.GetWeakPtr(), closure);
+ &MidiScheduler::InvokeClosure,
+ weak_factory_.GetWeakPtr(),
+ client,
+ length,
+ closure);
base::TimeDelta delay;
if (timestamp != 0.0) {
@@ -37,15 +43,13 @@ void MidiScheduler::PostSendDataTask(MidiManagerClient* client,
}
base::MessageLoop::current()->task_runner()->PostDelayedTask(
FROM_HERE, weak_closure, delay);
-
- // TODO(crbug.com/467442): AccumulateMidiBytesSent should be called in
- // InvokeClosure. But for now, we call it here since |client| may be deleted
- // at that time.
- client->AccumulateMidiBytesSent(length);
}
-void MidiScheduler::InvokeClosure(const base::Closure& closure) {
+void MidiScheduler::InvokeClosure(MidiManagerClient* client,
+ size_t length,
+ const base::Closure& closure) {
closure.Run();
+ manager_->AccumulateMidiBytesSent(client, length);
}
} // namespace media
« no previous file with comments | « media/midi/midi_scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698