| 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 #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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/public/browser/browser_message_filter.h" | 20 #include "content/public/browser/browser_message_filter.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "media/midi/midi_manager.h" | 22 #include "media/midi/midi_manager.h" |
| 23 #include "media/midi/midi_port_info.h" | 23 #include "media/midi/midi_port_info.h" |
| 24 #include "media/midi/midi_service.mojom.h" | 24 #include "media/midi/midi_service.mojom.h" |
| 25 | 25 |
| 26 namespace midi { | 26 namespace midi { |
| 27 class MidiManager; | 27 class MidiService; |
| 28 class MidiMessageQueue; | 28 class MidiMessageQueue; |
| 29 } // namespace midi | 29 } // namespace midi |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 class CONTENT_EXPORT MidiHost : public BrowserMessageFilter, | 33 class CONTENT_EXPORT MidiHost : public BrowserMessageFilter, |
| 34 public midi::MidiManagerClient { | 34 public midi::MidiManagerClient { |
| 35 public: | 35 public: |
| 36 // Called from UI thread from the owner of this object. | 36 // Called from UI thread from the owner of this object. |
| 37 MidiHost(int renderer_process_id, midi::MidiManager* midi_manager); | 37 MidiHost(int renderer_process_id, midi::MidiService* midi_service); |
| 38 | 38 |
| 39 // BrowserMessageFilter implementation. | 39 // BrowserMessageFilter implementation. |
| 40 void OnChannelClosing() override; | 40 void OnChannelClosing() override; |
| 41 void OnDestruct() const override; | 41 void OnDestruct() const override; |
| 42 bool OnMessageReceived(const IPC::Message& message) override; | 42 bool OnMessageReceived(const IPC::Message& message) override; |
| 43 | 43 |
| 44 // MidiManagerClient implementation. | 44 // MidiManagerClient implementation. |
| 45 void CompleteStartSession(midi::mojom::Result result) override; | 45 void CompleteStartSession(midi::mojom::Result result) override; |
| 46 void AddInputPort(const midi::MidiPortInfo& info) override; | 46 void AddInputPort(const midi::MidiPortInfo& info) override; |
| 47 void AddOutputPort(const midi::MidiPortInfo& info) override; | 47 void AddOutputPort(const midi::MidiPortInfo& info) override; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 73 | 73 |
| 74 int renderer_process_id_; | 74 int renderer_process_id_; |
| 75 | 75 |
| 76 // Represents if the renderer has a permission to send/receive MIDI SysEX | 76 // Represents if the renderer has a permission to send/receive MIDI SysEX |
| 77 // messages. | 77 // messages. |
| 78 bool has_sys_ex_permission_; | 78 bool has_sys_ex_permission_; |
| 79 | 79 |
| 80 // Represents if a session is requested to start. | 80 // Represents if a session is requested to start. |
| 81 bool is_session_requested_; | 81 bool is_session_requested_; |
| 82 | 82 |
| 83 // |midi_manager_| talks to the platform-specific MIDI APIs. | 83 // |midi_service_| manages a MidiManager instance that talks to |
| 84 // It can be NULL if the platform (or our current implementation) | 84 // platform-specific MIDI APIs. It can be nullptr after detached. |
| 85 // does not support MIDI. If not supported then a call to | 85 midi::MidiService* midi_service_; |
| 86 // OnRequestAccess() will always refuse access and a call to | |
| 87 // OnSendData() will do nothing. | |
| 88 midi::MidiManager* midi_manager_; | |
| 89 | 86 |
| 90 // Buffers where data sent from each MIDI input port is stored. | 87 // Buffers where data sent from each MIDI input port is stored. |
| 91 ScopedVector<midi::MidiMessageQueue> received_messages_queues_; | 88 ScopedVector<midi::MidiMessageQueue> received_messages_queues_; |
| 92 | 89 |
| 93 // Protects access to |received_messages_queues_|; | 90 // Protects access to |received_messages_queues_|; |
| 94 base::Lock messages_queues_lock_; | 91 base::Lock messages_queues_lock_; |
| 95 | 92 |
| 96 // The number of bytes sent to the platform-specific MIDI sending | 93 // The number of bytes sent to the platform-specific MIDI sending |
| 97 // system, but not yet completed. | 94 // system, but not yet completed. |
| 98 size_t sent_bytes_in_flight_; | 95 size_t sent_bytes_in_flight_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 109 | 106 |
| 110 // Protects access to |output_port_count_|. | 107 // Protects access to |output_port_count_|. |
| 111 base::Lock output_port_count_lock_; | 108 base::Lock output_port_count_lock_; |
| 112 | 109 |
| 113 DISALLOW_COPY_AND_ASSIGN(MidiHost); | 110 DISALLOW_COPY_AND_ASSIGN(MidiHost); |
| 114 }; | 111 }; |
| 115 | 112 |
| 116 } // namespace content | 113 } // namespace content |
| 117 | 114 |
| 118 #endif // CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ | 115 #endif // CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ |
| OLD | NEW |