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

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

Issue 2404443002: Web MIDI: use midi_service.mojom for media::midi::Result (Closed)
Patch Set: yhirano@ review 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
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
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "ipc/message_filter.h" 17 #include "ipc/message_filter.h"
18 #include "media/midi/midi_port_info.h" 18 #include "media/midi/midi_port_info.h"
19 #include "media/midi/result.h" 19 #include "media/midi/midi_service.mojom.h"
20 #include "third_party/WebKit/public/platform/modules/webmidi/WebMIDIAccessorClie nt.h" 20 #include "third_party/WebKit/public/platform/modules/webmidi/WebMIDIAccessorClie nt.h"
21 21
22 namespace base { 22 namespace base {
23 class SingleThreadTaskRunner; 23 class SingleThreadTaskRunner;
24 } 24 }
25 25
26 namespace content { 26 namespace content {
27 27
28 // MessageFilter that handles MIDI messages. Created on render thread, and 28 // MessageFilter that handles MIDI messages. Created on render thread, and
29 // host multiple clients running on multiple frames on IO thread. 29 // host multiple clients running on multiple frames on IO thread.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void Send(IPC::Message* message); 78 void Send(IPC::Message* message);
79 79
80 // IPC::MessageFilter override. Called on |io_task_runner|. 80 // IPC::MessageFilter override. Called on |io_task_runner|.
81 bool OnMessageReceived(const IPC::Message& message) override; 81 bool OnMessageReceived(const IPC::Message& message) override;
82 void OnFilterAdded(IPC::Channel* channel) override; 82 void OnFilterAdded(IPC::Channel* channel) override;
83 void OnFilterRemoved() override; 83 void OnFilterRemoved() override;
84 void OnChannelClosing() override; 84 void OnChannelClosing() override;
85 85
86 // Called when the browser process has approved (or denied) access to 86 // Called when the browser process has approved (or denied) access to
87 // MIDI hardware. 87 // MIDI hardware.
88 void OnSessionStarted(midi::Result result); 88 void OnSessionStarted(midi::mojom::Result result);
89 89
90 // These functions are called in 2 cases: 90 // These functions are called in 2 cases:
91 // (1) Just before calling |OnSessionStarted|, to notify the recipient about 91 // (1) Just before calling |OnSessionStarted|, to notify the recipient about
92 // existing ports. 92 // existing ports.
93 // (2) To notify the recipient that a new device was connected and that new 93 // (2) To notify the recipient that a new device was connected and that new
94 // ports have been created. 94 // ports have been created.
95 void OnAddInputPort(midi::MidiPortInfo info); 95 void OnAddInputPort(midi::MidiPortInfo info);
96 void OnAddOutputPort(midi::MidiPortInfo info); 96 void OnAddOutputPort(midi::MidiPortInfo info);
97 97
98 // These functions are called to notify the recipient that a device that is 98 // These functions are called to notify the recipient that a device that is
99 // notified via OnAddInputPort() or OnAddOutputPort() gets disconnected, or 99 // notified via OnAddInputPort() or OnAddOutputPort() gets disconnected, or
100 // connected again. 100 // connected again.
101 void OnSetInputPortState(uint32_t port, midi::MidiPortState state); 101 void OnSetInputPortState(uint32_t port, midi::MidiPortState state);
102 void OnSetOutputPortState(uint32_t port, midi::MidiPortState state); 102 void OnSetOutputPortState(uint32_t port, midi::MidiPortState state);
103 103
104 // Called when the browser process has sent MIDI data containing one or 104 // Called when the browser process has sent MIDI data containing one or
105 // more messages. 105 // more messages.
106 void OnDataReceived(uint32_t port, 106 void OnDataReceived(uint32_t port,
107 const std::vector<uint8_t>& data, 107 const std::vector<uint8_t>& data,
108 double timestamp); 108 double timestamp);
109 109
110 // From time-to-time, the browser incrementally informs us of how many bytes 110 // 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 111 // 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. 112 // sending too much data before knowing how much has already been sent.
113 void OnAcknowledgeSentData(size_t bytes_sent); 113 void OnAcknowledgeSentData(size_t bytes_sent);
114 114
115 // Following methods, Handle*, run on |main_task_runner_|. 115 // Following methods, Handle*, run on |main_task_runner_|.
116 void HandleClientAdded(midi::Result result); 116 void HandleClientAdded(midi::mojom::Result result);
117 117
118 void HandleAddInputPort(midi::MidiPortInfo info); 118 void HandleAddInputPort(midi::MidiPortInfo info);
119 void HandleAddOutputPort(midi::MidiPortInfo info); 119 void HandleAddOutputPort(midi::MidiPortInfo info);
120 void HandleSetInputPortState(uint32_t port, midi::MidiPortState state); 120 void HandleSetInputPortState(uint32_t port, midi::MidiPortState state);
121 void HandleSetOutputPortState(uint32_t port, 121 void HandleSetOutputPortState(uint32_t port,
122 midi::MidiPortState 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);
(...skipping 19 matching lines...) Expand all
146 typedef std::set<blink::WebMIDIAccessorClient*> ClientsSet; 146 typedef std::set<blink::WebMIDIAccessorClient*> ClientsSet;
147 ClientsSet clients_; 147 ClientsSet clients_;
148 148
149 // Represents clients that are waiting for a session being open. 149 // Represents clients that are waiting for a session being open.
150 // Note: std::vector is not safe to invoke callbacks inside iterator based 150 // Note: std::vector is not safe to invoke callbacks inside iterator based
151 // for-loops. 151 // for-loops.
152 typedef std::vector<blink::WebMIDIAccessorClient*> ClientsQueue; 152 typedef std::vector<blink::WebMIDIAccessorClient*> ClientsQueue;
153 ClientsQueue clients_waiting_session_queue_; 153 ClientsQueue clients_waiting_session_queue_;
154 154
155 // Represents a result on starting a session. Can be accessed only on 155 // Represents a result on starting a session. Can be accessed only on
156 midi::Result session_result_; 156 midi::mojom::Result session_result_;
157 157
158 // Holds MidiPortInfoList for input ports and output ports. 158 // Holds MidiPortInfoList for input ports and output ports.
159 midi::MidiPortInfoList inputs_; 159 midi::MidiPortInfoList inputs_;
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

Powered by Google App Engine
This is Rietveld 408576698