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

Side by Side Diff: content/browser/media/midi_host.h

Issue 1315793008: Web MIDI: introduce MidiManager::Shutdown to shutdown gracefully (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename to Detach Created 5 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/browser/browser_main_loop.cc ('k') | content/browser/media/midi_host.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_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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 void AddOutputPort(const media::midi::MidiPortInfo& info) override; 43 void AddOutputPort(const media::midi::MidiPortInfo& info) override;
44 void SetInputPortState(uint32 port, 44 void SetInputPortState(uint32 port,
45 media::midi::MidiPortState state) override; 45 media::midi::MidiPortState state) override;
46 void SetOutputPortState(uint32 port, 46 void SetOutputPortState(uint32 port,
47 media::midi::MidiPortState state) override; 47 media::midi::MidiPortState state) override;
48 void ReceiveMidiData(uint32 port, 48 void ReceiveMidiData(uint32 port,
49 const uint8* data, 49 const uint8* data,
50 size_t length, 50 size_t length,
51 double timestamp) override; 51 double timestamp) override;
52 void AccumulateMidiBytesSent(size_t n) override; 52 void AccumulateMidiBytesSent(size_t n) override;
53 void Detach() override;
53 54
54 // Start session to access MIDI hardware. 55 // Start session to access MIDI hardware.
55 void OnStartSession(); 56 void OnStartSession();
56 57
57 // Data to be sent to a MIDI output port. 58 // Data to be sent to a MIDI output port.
58 void OnSendData(uint32 port, 59 void OnSendData(uint32 port,
59 const std::vector<uint8>& data, 60 const std::vector<uint8>& data,
60 double timestamp); 61 double timestamp);
61 62
62 void OnEndSession(); 63 void OnEndSession();
63 64
64 protected: 65 protected:
65 ~MidiHost() override; 66 ~MidiHost() override;
66 67
67 private: 68 private:
68 FRIEND_TEST_ALL_PREFIXES(MidiHostTest, IsValidWebMIDIData); 69 FRIEND_TEST_ALL_PREFIXES(MidiHostTest, IsValidWebMIDIData);
69 friend class base::DeleteHelper<MidiHost>; 70 friend class base::DeleteHelper<MidiHost>;
70 friend class BrowserThread; 71 friend class BrowserThread;
71 72
72 // Returns true if |data| fulfills the requirements of MidiOutput.send API 73 // Returns true if |data| fulfills the requirements of MidiOutput.send API
73 // defined in the WebMIDI spec. 74 // defined in the Web MIDI spec.
74 // - |data| must be any number of complete MIDI messages (data abbreviation 75 // - |data| must be any number of complete MIDI messages (data abbreviation
75 // called "running status" is disallowed). 76 // called "running status" is disallowed).
76 // - 1-byte MIDI realtime messages can be placed at any position of |data|. 77 // - 1-byte MIDI realtime messages can be placed at any position of |data|.
77 static bool IsValidWebMIDIData(const std::vector<uint8>& data); 78 static bool IsValidWebMIDIData(const std::vector<uint8>& data);
78 79
79 int renderer_process_id_; 80 int renderer_process_id_;
80 81
81 // Represents if the renderer has a permission to send/receive MIDI SysEX 82 // Represents if the renderer has a permission to send/receive MIDI SysEX
82 // messages. 83 // messages.
83 bool has_sys_ex_permission_; 84 bool has_sys_ex_permission_;
84 85
85 // Represents if a session is requested to start. 86 // Represents if a session is requested to start.
86 bool is_session_requested_; 87 bool is_session_requested_;
87 88
88 // |midi_manager_| talks to the platform-specific MIDI APIs. 89 // |midi_manager_| talks to the platform-specific MIDI APIs.
89 // It can be NULL if the platform (or our current implementation) 90 // It can be NULL if the platform (or our current implementation)
90 // does not support MIDI. If not supported then a call to 91 // does not support MIDI. If not supported then a call to
91 // OnRequestAccess() will always refuse access and a call to 92 // OnRequestAccess() will always refuse access and a call to
92 // OnSendData() will do nothing. 93 // OnSendData() will do nothing.
93 media::midi::MidiManager* const midi_manager_; 94 media::midi::MidiManager* midi_manager_;
94 95
95 // Buffers where data sent from each MIDI input port is stored. 96 // Buffers where data sent from each MIDI input port is stored.
96 ScopedVector<media::midi::MidiMessageQueue> received_messages_queues_; 97 ScopedVector<media::midi::MidiMessageQueue> received_messages_queues_;
97 98
98 // Protects access to |received_messages_queues_|; 99 // Protects access to |received_messages_queues_|;
99 base::Lock messages_queues_lock_; 100 base::Lock messages_queues_lock_;
100 101
101 // The number of bytes sent to the platform-specific MIDI sending 102 // The number of bytes sent to the platform-specific MIDI sending
102 // system, but not yet completed. 103 // system, but not yet completed.
103 size_t sent_bytes_in_flight_; 104 size_t sent_bytes_in_flight_;
(...skipping 10 matching lines...) Expand all
114 115
115 // Protects access to |output_port_count_|. 116 // Protects access to |output_port_count_|.
116 base::Lock output_port_count_lock_; 117 base::Lock output_port_count_lock_;
117 118
118 DISALLOW_COPY_AND_ASSIGN(MidiHost); 119 DISALLOW_COPY_AND_ASSIGN(MidiHost);
119 }; 120 };
120 121
121 } // namespace content 122 } // namespace content
122 123
123 #endif // CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ 124 #endif // CONTENT_BROWSER_MEDIA_MIDI_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/media/midi_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698