OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ |
6 #define CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ | 6 #define CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 class CONTENT_EXPORT MidiHost | 26 class CONTENT_EXPORT MidiHost |
27 : public BrowserMessageFilter, | 27 : public BrowserMessageFilter, |
28 public media::MidiManagerClient { | 28 public media::MidiManagerClient { |
29 public: | 29 public: |
30 // Called from UI thread from the owner of this object. | 30 // Called from UI thread from the owner of this object. |
31 MidiHost(int renderer_process_id, media::MidiManager* midi_manager); | 31 MidiHost(int renderer_process_id, media::MidiManager* midi_manager); |
32 | 32 |
33 // BrowserMessageFilter implementation. | 33 // BrowserMessageFilter implementation. |
34 virtual void OnDestruct() const override; | 34 void OnDestruct() const override; |
35 virtual bool OnMessageReceived(const IPC::Message& message) override; | 35 bool OnMessageReceived(const IPC::Message& message) override; |
36 | 36 |
37 // MidiManagerClient implementation. | 37 // MidiManagerClient implementation. |
38 virtual void CompleteStartSession(int client_id, | 38 void CompleteStartSession(int client_id, media::MidiResult result) override; |
39 media::MidiResult result) override; | 39 void ReceiveMidiData(uint32 port, |
40 virtual void ReceiveMidiData(uint32 port, | 40 const uint8* data, |
41 const uint8* data, | 41 size_t length, |
42 size_t length, | 42 double timestamp) override; |
43 double timestamp) override; | 43 void AccumulateMidiBytesSent(size_t n) override; |
44 virtual void AccumulateMidiBytesSent(size_t n) override; | |
45 | 44 |
46 // Start session to access MIDI hardware. | 45 // Start session to access MIDI hardware. |
47 void OnStartSession(int client_id); | 46 void OnStartSession(int client_id); |
48 | 47 |
49 // Data to be sent to a MIDI output port. | 48 // Data to be sent to a MIDI output port. |
50 void OnSendData(uint32 port, | 49 void OnSendData(uint32 port, |
51 const std::vector<uint8>& data, | 50 const std::vector<uint8>& data, |
52 double timestamp); | 51 double timestamp); |
53 | 52 |
54 private: | 53 private: |
55 FRIEND_TEST_ALL_PREFIXES(MidiHostTest, IsValidWebMIDIData); | 54 FRIEND_TEST_ALL_PREFIXES(MidiHostTest, IsValidWebMIDIData); |
56 friend class base::DeleteHelper<MidiHost>; | 55 friend class base::DeleteHelper<MidiHost>; |
57 friend class BrowserThread; | 56 friend class BrowserThread; |
58 | 57 |
59 virtual ~MidiHost(); | 58 ~MidiHost() override; |
60 | 59 |
61 // Returns true if |data| fulfills the requirements of MidiOutput.send API | 60 // Returns true if |data| fulfills the requirements of MidiOutput.send API |
62 // defined in the WebMIDI spec. | 61 // defined in the WebMIDI spec. |
63 // - |data| must be any number of complete MIDI messages (data abbreviation | 62 // - |data| must be any number of complete MIDI messages (data abbreviation |
64 // called "running status" is disallowed). | 63 // called "running status" is disallowed). |
65 // - 1-byte MIDI realtime messages can be placed at any position of |data|. | 64 // - 1-byte MIDI realtime messages can be placed at any position of |data|. |
66 static bool IsValidWebMIDIData(const std::vector<uint8>& data); | 65 static bool IsValidWebMIDIData(const std::vector<uint8>& data); |
67 | 66 |
68 int renderer_process_id_; | 67 int renderer_process_id_; |
69 | 68 |
(...skipping 21 matching lines...) Expand all Loading... |
91 | 90 |
92 // Protects access to |sent_bytes_in_flight_|. | 91 // Protects access to |sent_bytes_in_flight_|. |
93 base::Lock in_flight_lock_; | 92 base::Lock in_flight_lock_; |
94 | 93 |
95 DISALLOW_COPY_AND_ASSIGN(MidiHost); | 94 DISALLOW_COPY_AND_ASSIGN(MidiHost); |
96 }; | 95 }; |
97 | 96 |
98 } // namespace content | 97 } // namespace content |
99 | 98 |
100 #endif // CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ | 99 #endif // CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ |
OLD | NEW |