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

Side by Side Diff: media/midi/midi_manager_winrt.h

Issue 2243183002: Web MIDI backend for Windows 10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, fixup Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef MEDIA_MIDI_MIDI_MANAGER_WINRT_H_
6 #define MEDIA_MIDI_MIDI_MANAGER_WINRT_H_
7
8 #include <memory>
9
10 #include "base/threading/thread.h"
11 #include "base/threading/thread_checker.h"
12 #include "media/midi/midi_manager.h"
13 #include "media/midi/midi_scheduler.h"
Takashi Toyoshima 2016/08/23 08:09:38 Now we do not need to include midi_scheduler.h, bu
Shao-Chuan Lee 2016/08/24 09:40:30 Done.
14
15 namespace media {
16 namespace midi {
17
18 class MIDI_EXPORT MidiManagerWinrt final : public MidiManager {
19 public:
20 MidiManagerWinrt();
21 ~MidiManagerWinrt() override;
22
23 // MidiManager overrides:
24 void StartInitialization() final;
25 void Finalize() final;
26 void DispatchSendMidiData(MidiManagerClient* client,
27 uint32_t port_index,
28 const std::vector<uint8_t>& data,
29 double timestamp) final;
30
31 // Callback from MidiPortManager::OnEnumerationComplete on the COM thread.
32 // Calls CompleteInitialization() when both MidiPortManagers are ready.
Takashi Toyoshima 2016/08/23 08:09:38 If we do not have any negative impact, can we make
Shao-Chuan Lee 2016/08/24 08:50:32 Done.
33 void OnPortManagerReady();
34
35 private:
36 // Callbacks on the COM thread.
37 void InitializeOnComThread();
38 void FinalizeOnComThread();
39 void SendOnComThread(uint32_t port_index, const std::vector<uint8_t>& data);
40
41 // Subclasses that access protected members of MidiManager.
Takashi Toyoshima 2016/08/23 08:09:38 note: private?
Shao-Chuan Lee 2016/08/24 08:50:32 Done.
42 class MidiInPortManager;
43 class MidiOutPortManager;
44
45 // COM-initialized thread for calling WinRT methods.
46 base::Thread com_thread_;
Takashi Toyoshima 2016/08/23 08:09:38 It would be better to make this unique_ptr and con
Shao-Chuan Lee 2016/08/24 08:50:32 Now I'm using a lock to synchronize between Finali
Takashi Toyoshima 2016/08/25 06:09:44 Agreed. I read thread.cc again. So, it seems to re
47
48 // Should be instantiated on COM thread.
49 std::unique_ptr<base::ThreadChecker> com_thread_checker_;
50
51 // All operations to MidiPortManager should be done on COM thread.
52 std::unique_ptr<MidiInPortManager> port_manager_in_;
53 std::unique_ptr<MidiOutPortManager> port_manager_out_;
54
55 // |scheduler_| is constructed/destructed on COM thread and used by
56 // DispatchSendMidiData on Chrome_IOThread, a lock is required.
57 base::Lock scheduler_lock_;
58 std::unique_ptr<MidiScheduler> scheduler_; // GUARDED_BY(scheduler_lock_)
59
60 // Incremented when a MidiPortManager is ready.
61 uint8_t port_manager_ready_count_ = 0;
62
63 DISALLOW_COPY_AND_ASSIGN(MidiManagerWinrt);
64 };
65
66 } // namespace midi
67 } // namespace media
68
69 #endif // MEDIA_MIDI_MIDI_MANAGER_WINRT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698