| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MEDIA_MIDI_MIDI_SCHEDULER_H_ | 5 #ifndef MEDIA_MIDI_MIDI_SCHEDULER_H_ | 
| 6 #define MEDIA_MIDI_MIDI_SCHEDULER_H_ | 6 #define MEDIA_MIDI_MIDI_SCHEDULER_H_ | 
| 7 | 7 | 
| 8 #include "base/callback.h" | 8 #include "base/callback.h" | 
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" | 
| 10 #include "media/base/media_export.h" |  | 
| 11 | 10 | 
| 12 namespace media { | 11 namespace media { | 
| 13 | 12 | 
| 14 class MidiManager; | 13 class MidiManager; | 
| 15 class MidiManagerClient; | 14 class MidiManagerClient; | 
| 16 | 15 | 
| 17 // TODO(crbug.com/467442): Make tasks cancelable per client. | 16 // TODO(crbug.com/467442): Make tasks cancelable per client. | 
| 18 class MEDIA_EXPORT MidiScheduler final { | 17 class MidiScheduler final { | 
| 19  public: | 18  public: | 
| 20   explicit MidiScheduler(MidiManager* manager); | 19   explicit MidiScheduler(MidiManager* manager); | 
| 21   ~MidiScheduler(); | 20   ~MidiScheduler(); | 
| 22 | 21 | 
| 23   // Post |closure| to the current message loop safely. The |closure| will not | 22   // Post |closure| to the current message loop safely. The |closure| will not | 
| 24   // be invoked after MidiScheduler is deleted. AccumulateMidiBytesSent() of | 23   // be invoked after MidiScheduler is deleted. AccumulateMidiBytesSent() of | 
| 25   // |client| is called internally. | 24   // |client| is called internally. | 
| 26   void PostSendDataTask(MidiManagerClient* client, | 25   void PostSendDataTask(MidiManagerClient* client, | 
| 27                         size_t length, | 26                         size_t length, | 
| 28                         double timestamp, | 27                         double timestamp, | 
| 29                         const base::Closure& closure); | 28                         const base::Closure& closure); | 
| 30 | 29 | 
| 31  private: | 30  private: | 
| 32   void InvokeClosure(MidiManagerClient* client, | 31   void InvokeClosure(MidiManagerClient* client, | 
| 33                      size_t length, | 32                      size_t length, | 
| 34                      const base::Closure& closure); | 33                      const base::Closure& closure); | 
| 35 | 34 | 
| 36   // MidiManager should own the MidiScheduler and be alive longer. | 35   // MidiManager should own the MidiScheduler and be alive longer. | 
| 37   MidiManager* manager_; | 36   MidiManager* manager_; | 
| 38   base::WeakPtrFactory<MidiScheduler> weak_factory_; | 37   base::WeakPtrFactory<MidiScheduler> weak_factory_; | 
| 39 | 38 | 
| 40   DISALLOW_COPY_AND_ASSIGN(MidiScheduler); | 39   DISALLOW_COPY_AND_ASSIGN(MidiScheduler); | 
| 41 }; | 40 }; | 
| 42 | 41 | 
| 43 }  // namespace media | 42 }  // namespace media | 
| 44 | 43 | 
| 45 #endif  // MEDIA_MIDI_MIDI_SCHEDULER_H_ | 44 #endif  // MEDIA_MIDI_MIDI_SCHEDULER_H_ | 
| OLD | NEW | 
|---|