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 #include "content/browser/renderer_host/media/midi_host.h" | 5 #include "content/browser/renderer_host/media/midi_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 Send(new MIDIMsg_SessionStarted( | 84 Send(new MIDIMsg_SessionStarted( |
85 client_id, | 85 client_id, |
86 success, | 86 success, |
87 input_ports, | 87 input_ports, |
88 output_ports)); | 88 output_ports)); |
89 } | 89 } |
90 | 90 |
91 void MIDIHost::OnSendData(int port, | 91 void MIDIHost::OnSendData(uint32 port, |
92 const std::vector<uint8>& data, | 92 const std::vector<uint8>& data, |
93 double timestamp) { | 93 double timestamp) { |
94 if (!midi_manager_) | 94 if (!midi_manager_) |
95 return; | 95 return; |
96 | 96 |
97 if (data.empty()) | 97 if (data.empty()) |
98 return; | 98 return; |
99 | 99 |
100 base::AutoLock auto_lock(in_flight_lock_); | 100 base::AutoLock auto_lock(in_flight_lock_); |
101 | 101 |
102 // Sanity check that we won't send too much. | 102 // Sanity check that we won't send too much. |
103 if (sent_bytes_in_flight_ > kMaxInFlightBytes || | 103 if (sent_bytes_in_flight_ > kMaxInFlightBytes || |
104 data.size() > kMaxInFlightBytes || | 104 data.size() > kMaxInFlightBytes || |
105 data.size() + sent_bytes_in_flight_ > kMaxInFlightBytes) | 105 data.size() + sent_bytes_in_flight_ > kMaxInFlightBytes) |
106 return; | 106 return; |
107 | 107 |
108 // For now disallow all System Exclusive messages even if we | 108 // For now disallow all System Exclusive messages even if we |
109 // have permission. | 109 // have permission. |
110 // TODO(toyoshim): allow System Exclusive if browser has granted | 110 // TODO(toyoshim): allow System Exclusive if browser has granted |
111 // this client access. We'll likely need to pass a GURL | 111 // this client access. We'll likely need to pass a GURL |
112 // here to compare against our permissions. | 112 // here to compare against our permissions. |
113 if (data[0] >= kSysExMessage) | 113 if (data[0] >= kSysExMessage) |
114 return; | 114 return; |
115 | 115 |
116 midi_manager_->DispatchSendMIDIData( | 116 midi_manager_->DispatchSendMIDIData( |
117 this, | 117 this, |
118 port, | 118 static_cast<size_t>(port), |
119 &data[0], | 119 data, |
120 data.size(), | |
121 timestamp); | 120 timestamp); |
122 | 121 |
123 sent_bytes_in_flight_ += data.size(); | 122 sent_bytes_in_flight_ += data.size(); |
124 } | 123 } |
125 | 124 |
126 void MIDIHost::ReceiveMIDIData( | 125 void MIDIHost::ReceiveMIDIData( |
127 int port_index, | 126 int port_index, |
128 const uint8* data, | 127 const uint8* data, |
129 size_t length, | 128 size_t length, |
130 double timestamp) { | 129 double timestamp) { |
(...skipping 25 matching lines...) Expand all Loading... |
156 | 155 |
157 if (bytes_sent_since_last_acknowledgement_ >= | 156 if (bytes_sent_since_last_acknowledgement_ >= |
158 kAcknowledgementThresholdBytes) { | 157 kAcknowledgementThresholdBytes) { |
159 Send(new MIDIMsg_AcknowledgeSentData( | 158 Send(new MIDIMsg_AcknowledgeSentData( |
160 bytes_sent_since_last_acknowledgement_)); | 159 bytes_sent_since_last_acknowledgement_)); |
161 bytes_sent_since_last_acknowledgement_ = 0; | 160 bytes_sent_since_last_acknowledgement_ = 0; |
162 } | 161 } |
163 } | 162 } |
164 | 163 |
165 } // namespace content | 164 } // namespace content |
OLD | NEW |