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

Side by Side Diff: content/renderer/media/midi_message_filter.h

Issue 2422163002: Web MIDI: use midi_service.mojom for media::midi::PortState (Closed)
Patch Set: gn --check fix Created 4 years, 2 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
« no previous file with comments | « content/common/media/midi_messages.h ('k') | content/renderer/media/midi_message_filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_
6 #define CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ 6 #define CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 void SendMidiData(uint32_t port, 47 void SendMidiData(uint32_t port,
48 const uint8_t* data, 48 const uint8_t* data,
49 size_t length, 49 size_t length,
50 double timestamp); 50 double timestamp);
51 51
52 // IO task runner associated with this message filter. 52 // IO task runner associated with this message filter.
53 base::SingleThreadTaskRunner* io_task_runner() const { 53 base::SingleThreadTaskRunner* io_task_runner() const {
54 return io_task_runner_.get(); 54 return io_task_runner_.get();
55 } 55 }
56 56
57 static blink::WebMIDIAccessorClient::MIDIPortState ToBlinkState( 57 static midi::mojom::PortState ToBlinkState(midi::mojom::PortState state) {
58 midi::MidiPortState state) {
59 // "open" status is separately managed by blink per MIDIAccess instance. 58 // "open" status is separately managed by blink per MIDIAccess instance.
60 if (state == midi::MIDI_PORT_OPENED) 59 // TODO(toyoshim): Pass through the state as is, and have a logic to convert
61 state = midi::MIDI_PORT_CONNECTED; 60 // this state to JavaScript exposing state in Blink side.
62 return static_cast<blink::WebMIDIAccessorClient::MIDIPortState>(state); 61 if (state == midi::mojom::PortState::OPENED)
62 return midi::mojom::PortState::CONNECTED;
63 return state;
63 } 64 }
64 65
65 protected: 66 protected:
66 ~MidiMessageFilter() override; 67 ~MidiMessageFilter() override;
67 68
68 private: 69 private:
69 void StartSessionOnIOThread(); 70 void StartSessionOnIOThread();
70 71
71 void SendMidiDataOnIOThread(uint32_t port, 72 void SendMidiDataOnIOThread(uint32_t port,
72 const std::vector<uint8_t>& data, 73 const std::vector<uint8_t>& data,
(...skipping 18 matching lines...) Expand all
91 // (1) Just before calling |OnSessionStarted|, to notify the recipient about 92 // (1) Just before calling |OnSessionStarted|, to notify the recipient about
92 // existing ports. 93 // existing ports.
93 // (2) To notify the recipient that a new device was connected and that new 94 // (2) To notify the recipient that a new device was connected and that new
94 // ports have been created. 95 // ports have been created.
95 void OnAddInputPort(midi::MidiPortInfo info); 96 void OnAddInputPort(midi::MidiPortInfo info);
96 void OnAddOutputPort(midi::MidiPortInfo info); 97 void OnAddOutputPort(midi::MidiPortInfo info);
97 98
98 // These functions are called to notify the recipient that a device that is 99 // These functions are called to notify the recipient that a device that is
99 // notified via OnAddInputPort() or OnAddOutputPort() gets disconnected, or 100 // notified via OnAddInputPort() or OnAddOutputPort() gets disconnected, or
100 // connected again. 101 // connected again.
101 void OnSetInputPortState(uint32_t port, midi::MidiPortState state); 102 void OnSetInputPortState(uint32_t port, midi::mojom::PortState state);
102 void OnSetOutputPortState(uint32_t port, midi::MidiPortState state); 103 void OnSetOutputPortState(uint32_t port, midi::mojom::PortState state);
103 104
104 // Called when the browser process has sent MIDI data containing one or 105 // Called when the browser process has sent MIDI data containing one or
105 // more messages. 106 // more messages.
106 void OnDataReceived(uint32_t port, 107 void OnDataReceived(uint32_t port,
107 const std::vector<uint8_t>& data, 108 const std::vector<uint8_t>& data,
108 double timestamp); 109 double timestamp);
109 110
110 // From time-to-time, the browser incrementally informs us of how many bytes 111 // From time-to-time, the browser incrementally informs us of how many bytes
111 // it has successfully sent. This is part of our throttling process to avoid 112 // it has successfully sent. This is part of our throttling process to avoid
112 // sending too much data before knowing how much has already been sent. 113 // sending too much data before knowing how much has already been sent.
113 void OnAcknowledgeSentData(size_t bytes_sent); 114 void OnAcknowledgeSentData(size_t bytes_sent);
114 115
115 // Following methods, Handle*, run on |main_task_runner_|. 116 // Following methods, Handle*, run on |main_task_runner_|.
116 void HandleClientAdded(midi::mojom::Result result); 117 void HandleClientAdded(midi::mojom::Result result);
117 118
118 void HandleAddInputPort(midi::MidiPortInfo info); 119 void HandleAddInputPort(midi::MidiPortInfo info);
119 void HandleAddOutputPort(midi::MidiPortInfo info); 120 void HandleAddOutputPort(midi::MidiPortInfo info);
120 void HandleSetInputPortState(uint32_t port, midi::MidiPortState state); 121 void HandleSetInputPortState(uint32_t port, midi::mojom::PortState state);
121 void HandleSetOutputPortState(uint32_t port, 122 void HandleSetOutputPortState(uint32_t port, midi::mojom::PortState state);
122 midi::MidiPortState state);
123 123
124 void HandleDataReceived(uint32_t port, 124 void HandleDataReceived(uint32_t port,
125 const std::vector<uint8_t>& data, 125 const std::vector<uint8_t>& data,
126 double timestamp); 126 double timestamp);
127 127
128 void HandleAckknowledgeSentData(size_t bytes_sent); 128 void HandleAckknowledgeSentData(size_t bytes_sent);
129 129
130 // IPC sender for Send(); must only be accessed on |io_task_runner_|. 130 // IPC sender for Send(); must only be accessed on |io_task_runner_|.
131 IPC::Sender* sender_; 131 IPC::Sender* sender_;
132 132
(...skipping 27 matching lines...) Expand all
160 midi::MidiPortInfoList outputs_; 160 midi::MidiPortInfoList outputs_;
161 161
162 size_t unacknowledged_bytes_sent_; 162 size_t unacknowledged_bytes_sent_;
163 163
164 DISALLOW_COPY_AND_ASSIGN(MidiMessageFilter); 164 DISALLOW_COPY_AND_ASSIGN(MidiMessageFilter);
165 }; 165 };
166 166
167 } // namespace content 167 } // namespace content
168 168
169 #endif // CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ 169 #endif // CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_
OLDNEW
« no previous file with comments | « content/common/media/midi_messages.h ('k') | content/renderer/media/midi_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698