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

Side by Side Diff: content/browser/renderer_host/media/midi_host.cc

Issue 142923005: Allow MessageFilters to restrict listening to specific message classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Working patch Created 6 years, 10 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 #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 17 matching lines...) Expand all
28 // The total number of bytes which we're allowed to send to the OS 28 // The total number of bytes which we're allowed to send to the OS
29 // before knowing that they have been successfully sent. 29 // before knowing that they have been successfully sent.
30 const size_t kMaxInFlightBytes = 10 * 1024 * 1024; // 10 MB. 30 const size_t kMaxInFlightBytes = 10 * 1024 * 1024; // 10 MB.
31 31
32 // We keep track of the number of bytes successfully sent to 32 // We keep track of the number of bytes successfully sent to
33 // the hardware. Every once in a while we report back to the renderer 33 // the hardware. Every once in a while we report back to the renderer
34 // the number of bytes sent since the last report. This threshold determines 34 // the number of bytes sent since the last report. This threshold determines
35 // how many bytes will be sent before reporting back to the renderer. 35 // how many bytes will be sent before reporting back to the renderer.
36 const size_t kAcknowledgementThresholdBytes = 1024 * 1024; // 1 MB. 36 const size_t kAcknowledgementThresholdBytes = 1024 * 1024; // 1 MB.
37 37
38 const uint32 kFilteredMessageClasses[] = {
39 MidiMsgStart,
40 };
41
38 bool IsDataByte(uint8 data) { 42 bool IsDataByte(uint8 data) {
39 return (data & 0x80) == 0; 43 return (data & 0x80) == 0;
40 } 44 }
41 45
42 bool IsSystemRealTimeMessage(uint8 data) { 46 bool IsSystemRealTimeMessage(uint8 data) {
43 return 0xf8 <= data && data <= 0xff; 47 return 0xf8 <= data && data <= 0xff;
44 } 48 }
45 49
46 } // namespace 50 } // namespace
47 51
48 using media::kSysExByte; 52 using media::kSysExByte;
49 using media::kEndOfSysExByte; 53 using media::kEndOfSysExByte;
50 54
51 MidiHost::MidiHost(int renderer_process_id, media::MidiManager* midi_manager) 55 MidiHost::MidiHost(int renderer_process_id, media::MidiManager* midi_manager)
52 : renderer_process_id_(renderer_process_id), 56 : BrowserMessageFilter(
57 kFilteredMessageClasses, arraysize(kFilteredMessageClasses)),
58 renderer_process_id_(renderer_process_id),
53 has_sys_ex_permission_(false), 59 has_sys_ex_permission_(false),
54 midi_manager_(midi_manager), 60 midi_manager_(midi_manager),
55 sent_bytes_in_flight_(0), 61 sent_bytes_in_flight_(0),
56 bytes_sent_since_last_acknowledgement_(0) { 62 bytes_sent_since_last_acknowledgement_(0) {
57 } 63 }
58 64
59 MidiHost::~MidiHost() { 65 MidiHost::~MidiHost() {
60 if (midi_manager_) 66 if (midi_manager_)
61 midi_manager_->EndSession(this); 67 midi_manager_->EndSession(this);
62 } 68 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 223 }
218 waiting_data_length = media::GetMidiMessageLength(current); 224 waiting_data_length = media::GetMidiMessageLength(current);
219 if (waiting_data_length == 0) 225 if (waiting_data_length == 0)
220 return false; // Error: |current| should have been a valid status byte. 226 return false; // Error: |current| should have been a valid status byte.
221 --waiting_data_length; // Found status byte 227 --waiting_data_length; // Found status byte
222 } 228 }
223 return waiting_data_length == 0 && !in_sysex; 229 return waiting_data_length == 0 && !in_sysex;
224 } 230 }
225 231
226 } // namespace content 232 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698