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

Unified Diff: media/midi/midi_scheduler.h

Issue 1052983002: Web MIDI: add MidiScheduler for send() with timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
Index: media/midi/midi_scheduler.h
diff --git a/media/midi/midi_scheduler.h b/media/midi/midi_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..200709e12ecfb7befc182981e675347545494032
--- /dev/null
+++ b/media/midi/midi_scheduler.h
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MIDI_MIDI_SCHEDULER_H_
+#define MEDIA_MIDI_MIDI_SCHEDULER_H_
+
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+
+namespace media {
+
+class MidiManagerClient;
+
+// TODO(crbug.com/467442): Make tasks cancelable per client.
+class MidiScheduler {
yhirano 2015/04/03 01:32:16 [optional] +final?
Takashi Toyoshima 2015/04/03 02:35:11 Done.
+ public:
+ MidiScheduler();
+ ~MidiScheduler();
yhirano 2015/04/03 01:32:16 You don't need an empty destructor.
Takashi Toyoshima 2015/04/03 02:35:11 Without this, compiler reports an error like, ../
yhirano 2015/04/03 03:26:38 Oh, sorry, you're right.
+
+ // Post |closure| to the current message loop safely. The |closure| will not
+ // be invoked after MidiScheduler is deleted. AccumulateMidiBytesSent() of
+ // |client| is called internally.
+ void PostSendDataTask(MidiManagerClient* client,
+ size_t length,
+ double timestamp,
+ const base::Closure& closure);
+
+ private:
+ void InvokeClosure(const base::Closure& closure);
+
+ base::WeakPtrFactory<MidiScheduler> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MidiScheduler);
+};
+
+} // namespace media
+
+#endif // MEDIA_MIDI_MIDI_SCHEDULER_H_

Powered by Google App Engine
This is Rietveld 408576698