Roll libvpx 861f35:1fff3e
[chromium-blink-merge.git] / media / midi / midi_scheduler.h
blob06f6b5746d01373321a0fd833d45abb21cc374d9
1 // Copyright 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.
5 #ifndef MEDIA_MIDI_MIDI_SCHEDULER_H_
6 #define MEDIA_MIDI_MIDI_SCHEDULER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
11 namespace media {
13 class MidiManager;
14 class MidiManagerClient;
16 // TODO(crbug.com/467442): Make tasks cancelable per client.
17 class MidiScheduler final {
18 public:
19 MidiScheduler(MidiManager* manager);
20 ~MidiScheduler();
22 // Post |closure| to the current message loop safely. The |closure| will not
23 // be invoked after MidiScheduler is deleted. AccumulateMidiBytesSent() of
24 // |client| is called internally.
25 void PostSendDataTask(MidiManagerClient* client,
26 size_t length,
27 double timestamp,
28 const base::Closure& closure);
30 private:
31 void InvokeClosure(MidiManagerClient* client,
32 size_t length,
33 const base::Closure& closure);
35 // MidiManager should own the MidiScheduler and be alive longer.
36 MidiManager* manager_;
37 base::WeakPtrFactory<MidiScheduler> weak_factory_;
39 DISALLOW_COPY_AND_ASSIGN(MidiScheduler);
42 } // namespace media
44 #endif // MEDIA_MIDI_MIDI_SCHEDULER_H_