diff options
author | crogers@google.com <crogers@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-22 01:49:39 +0000 |
---|---|---|
committer | crogers@google.com <crogers@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-22 01:49:39 +0000 |
commit | e1848157f1024d4c01f1dcbb009dcbc3913f230d (patch) | |
tree | 678f49e10d7bf6c1442b6729a052d20b384c8c1c /content/renderer | |
parent | a80773bb263a9706cc8ee4e3f336d2d3d28fadd8 (diff) | |
download | chromium_src-e1848157f1024d4c01f1dcbb009dcbc3913f230d.zip chromium_src-e1848157f1024d4c01f1dcbb009dcbc3913f230d.tar.gz chromium_src-e1848157f1024d4c01f1dcbb009dcbc3913f230d.tar.bz2 |
Revert 207983 "Implement Web MIDI API back-end"
> Implement Web MIDI API back-end
>
> This involves browser-side support and IPC for sending and receiving
> MIDI messages. Initially support for OSX is included.
>
> BUG=163795
> R=palmer@chromium.org, piman@chromium.org, scherkus@chromium.org
>
> Review URL: https://codereview.chromium.org/16025005
TBR=crogers@google.com
Review URL: https://codereview.chromium.org/17334006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207989 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/media/midi_message_filter.cc | 199 | ||||
-rw-r--r-- | content/renderer/media/midi_message_filter.h | 116 | ||||
-rw-r--r-- | content/renderer/media/renderer_webmidiaccessor_impl.cc | 43 | ||||
-rw-r--r-- | content/renderer/media/renderer_webmidiaccessor_impl.h | 41 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.cc | 4 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.h | 5 | ||||
-rw-r--r-- | content/renderer/renderer_webkitplatformsupport_impl.cc | 10 | ||||
-rw-r--r-- | content/renderer/renderer_webkitplatformsupport_impl.h | 2 |
8 files changed, 0 insertions, 420 deletions
diff --git a/content/renderer/media/midi_message_filter.cc b/content/renderer/media/midi_message_filter.cc deleted file mode 100644 index 1abb537..0000000 --- a/content/renderer/media/midi_message_filter.cc +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/renderer/media/midi_message_filter.h" - -#include "base/bind.h" -#include "base/debug/trace_event.h" -#include "base/message_loop/message_loop_proxy.h" -#include "base/strings/utf_string_conversions.h" -#include "content/common/media/midi_messages.h" -#include "content/renderer/render_thread_impl.h" -#include "ipc/ipc_logging.h" - -using media::MIDIPortInfoList; -using base::AutoLock; - -namespace content { - -MIDIMessageFilter::MIDIMessageFilter( - const scoped_refptr<base::MessageLoopProxy>& io_message_loop) - : channel_(NULL), - io_message_loop_(io_message_loop), - next_available_id_(0) { -} - -MIDIMessageFilter::~MIDIMessageFilter() {} - -void MIDIMessageFilter::Send(IPC::Message* message) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); - if (!channel_) { - delete message; - } else { - channel_->Send(message); - } -} - -bool MIDIMessageFilter::OnMessageReceived(const IPC::Message& message) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(MIDIMessageFilter, message) - IPC_MESSAGE_HANDLER(MIDIMsg_AccessApproved, OnAccessApproved) - IPC_MESSAGE_HANDLER(MIDIMsg_DataReceived, OnDataReceived) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void MIDIMessageFilter::OnFilterAdded(IPC::Channel* channel) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); - channel_ = channel; -} - -void MIDIMessageFilter::OnFilterRemoved() { - DCHECK(io_message_loop_->BelongsToCurrentThread()); - - // Once removed, a filter will not be used again. At this time all - // delegates must be notified so they release their reference. - OnChannelClosing(); -} - -void MIDIMessageFilter::OnChannelClosing() { - DCHECK(io_message_loop_->BelongsToCurrentThread()); - channel_ = NULL; -} - -void MIDIMessageFilter::RequestAccess( - WebKit::WebMIDIAccessorClient* client, int access) { - // Generate and keep track of a "client id" which is sent to the browser - // to ask permission to talk to MIDI hardware. - // This id is handed back when we receive the answer in OnAccessApproved(). - if (clients_.find(client) == clients_.end()) { - int client_id = next_available_id_++; - clients_[client] = client_id; - - io_message_loop_->PostTask(FROM_HERE, - base::Bind(&MIDIMessageFilter::RequestAccessOnIOThread, this, - client_id, access)); - } -} - -void MIDIMessageFilter::RequestAccessOnIOThread(int client_id, int access) { - Send(new MIDIHostMsg_RequestAccess(client_id, access)); -} - -void MIDIMessageFilter::RemoveClient(WebKit::WebMIDIAccessorClient* client) { - ClientsMap::iterator i = clients_.find(client); - if (i != clients_.end()) - clients_.erase(i); -} - -// Received from browser. - -void MIDIMessageFilter::OnAccessApproved( - int client_id, - int access, - bool success, - MIDIPortInfoList inputs, - MIDIPortInfoList outputs) { - // Handle on the main JS thread. - ChildThread::current()->message_loop()->PostTask(FROM_HERE, - base::Bind(&MIDIMessageFilter::HandleAccessApproved, this, - client_id, access, success, inputs, outputs)); -} - -void MIDIMessageFilter::HandleAccessApproved( - int client_id, - int access, - bool success, - MIDIPortInfoList inputs, - MIDIPortInfoList outputs) { - WebKit::WebMIDIAccessorClient* client = GetClientFromId(client_id); - if (!client) - return; - - if (success) { - // Add the client's input and output ports. - for (size_t i = 0; i < inputs.size(); ++i) { - client->didAddInputPort( - UTF8ToUTF16(inputs[i].id), - UTF8ToUTF16(inputs[i].manufacturer), - UTF8ToUTF16(inputs[i].name), - UTF8ToUTF16(inputs[i].version)); - } - - for (size_t i = 0; i < outputs.size(); ++i) { - client->didAddOutputPort( - UTF8ToUTF16(outputs[i].id), - UTF8ToUTF16(outputs[i].manufacturer), - UTF8ToUTF16(outputs[i].name), - UTF8ToUTF16(outputs[i].version)); - } - } - - if (success) - client->didAllowAccess(); - else - client->didBlockAccess(); -} - -WebKit::WebMIDIAccessorClient* -MIDIMessageFilter::GetClientFromId(int client_id) { - // Iterating like this seems inefficient, but in practice there generally - // will be very few clients (usually one). Additionally, this lookup - // usually happens one time during page load. So the performance hit is - // negligible. - for (ClientsMap::iterator i = clients_.begin(); i != clients_.end(); ++i) { - if ((*i).second == client_id) - return (*i).first; - } - return NULL; -} - -void MIDIMessageFilter::OnDataReceived(int port, - const std::vector<uint8>& data, - double timestamp) { - TRACE_EVENT0("midi", "MIDIMessageFilter::OnDataReceived"); - - ChildThread::current()->message_loop()->PostTask(FROM_HERE, - base::Bind(&MIDIMessageFilter::HandleDataReceived, this, - port, data, timestamp)); -} - -void MIDIMessageFilter::HandleDataReceived(int port, - const std::vector<uint8>& data, - double timestamp) { - TRACE_EVENT0("midi", "MIDIMessageFilter::HandleDataReceived"); - -#if defined(OS_ANDROID) - // TODO(crogers): figure out why data() method does not compile on Android. - NOTIMPLEMENTED(); -#else - for (ClientsMap::iterator i = clients_.begin(); i != clients_.end(); ++i) - (*i).first->didReceiveMIDIData(port, data.data(), data.size(), timestamp); -#endif -} - -void MIDIMessageFilter::SendMIDIData(int port, - const uint8* data, - size_t length, - double timestamp) { - // TODO(crogers): we need more work to check the amount of data sent, - // throttle if necessary, and filter out the SYSEX messages if not - // approved. For now, we will not implement the sending of MIDI data. - NOTIMPLEMENTED(); - // std::vector<uint8> v(data, data + length); - // io_message_loop_->PostTask(FROM_HERE, - // base::Bind(&MIDIMessageFilter::SendMIDIDataOnIOThread, this, - // port, v, timestamp)); -} - -void MIDIMessageFilter::SendMIDIDataOnIOThread(int port, - const std::vector<uint8>& data, - double timestamp) { - // Send to the browser. - Send(new MIDIHostMsg_SendData(port, data, timestamp)); -} - -} // namespace content diff --git a/content/renderer/media/midi_message_filter.h b/content/renderer/media/midi_message_filter.h deleted file mode 100644 index 236ae47..0000000 --- a/content/renderer/media/midi_message_filter.h +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ -#define CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ - -#include <map> -#include <vector> - -#include "base/memory/scoped_ptr.h" -#include "content/common/content_export.h" -#include "ipc/ipc_channel_proxy.h" -#include "media/midi/midi_port_info.h" -#include "third_party/WebKit/public/platform/WebMIDIAccessor.h" -#include "third_party/WebKit/public/platform/WebMIDIAccessorClient.h" - -namespace base { -class MessageLoopProxy; -} - -namespace content { - -// MessageFilter that handles MIDI messages. -class CONTENT_EXPORT MIDIMessageFilter - : public IPC::ChannelProxy::MessageFilter { - public: - explicit MIDIMessageFilter( - const scoped_refptr<base::MessageLoopProxy>& io_message_loop); - - // Each client registers for MIDI access here. - // If permission is granted, then the client's - // addInputPort() and addOutputPort() methods will be called, - // giving the client access to receive and send data. - void RequestAccess(WebKit::WebMIDIAccessorClient* client, int access); - void RemoveClient(WebKit::WebMIDIAccessorClient* client); - - // A client will only be able to call this method if it has a suitable - // output port (from addOutputPort()). - void SendMIDIData(int port, - const uint8* data, - size_t length, - double timestamp); - - // IO message loop associated with this message filter. - scoped_refptr<base::MessageLoopProxy> io_message_loop() const { - return io_message_loop_; - } - - protected: - virtual ~MIDIMessageFilter(); - - private: - // Sends an IPC message using |channel_|. - void Send(IPC::Message* message); - - // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|. - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; - virtual void OnFilterRemoved() OVERRIDE; - virtual void OnChannelClosing() OVERRIDE; - - // Called when the browser process has approved (or denied) access to - // MIDI hardware. - void OnAccessApproved(int client_id, - int access, - bool success, - media::MIDIPortInfoList inputs, - media::MIDIPortInfoList outputs); - - // Called when the browser process has sent MIDI data containing one or - // more messages. - void OnDataReceived(int port, - const std::vector<uint8>& data, - double timestamp); - - void HandleAccessApproved(int client_id, - int access, - bool success, - media::MIDIPortInfoList inputs, - media::MIDIPortInfoList outputs); - - void HandleDataReceived(int port, - const std::vector<uint8>& data, - double timestamp); - - void RequestAccessOnIOThread(int client_id, int access); - - void SendMIDIDataOnIOThread(int port, - const std::vector<uint8>& data, - double timestamp); - - WebKit::WebMIDIAccessorClient* GetClientFromId(int client_id); - - // IPC channel for Send(); must only be accessed on |io_message_loop_|. - IPC::Channel* channel_; - - // Message loop on which IPC calls are driven. - const scoped_refptr<base::MessageLoopProxy> io_message_loop_; - - // Keeps track of all MIDI clients. - // We map client to "client id" used to track permission. - // When access has been approved, we add the input and output ports to - // the client, allowing it to actually receive and send MIDI data. - typedef std::map<WebKit::WebMIDIAccessorClient*, int> ClientsMap; - ClientsMap clients_; - - // Dishes out client ids. - int next_available_id_; - - DISALLOW_COPY_AND_ASSIGN(MIDIMessageFilter); -}; - -} // namespace content - -#endif // CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ diff --git a/content/renderer/media/renderer_webmidiaccessor_impl.cc b/content/renderer/media/renderer_webmidiaccessor_impl.cc deleted file mode 100644 index 0a8b68f..0000000 --- a/content/renderer/media/renderer_webmidiaccessor_impl.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/renderer/media/renderer_webmidiaccessor_impl.h" - -#include "base/logging.h" -#include "content/renderer/media/midi_message_filter.h" -#include "content/renderer/render_thread_impl.h" - -namespace content { - -RendererWebMIDIAccessorImpl::RendererWebMIDIAccessorImpl( - WebKit::WebMIDIAccessorClient* client) - : client_(client) { - DCHECK(client_); -} - -RendererWebMIDIAccessorImpl::~RendererWebMIDIAccessorImpl() { - midi_message_filter()->RemoveClient(client_); -} - -void RendererWebMIDIAccessorImpl::requestAccess(bool access) { - midi_message_filter()->RequestAccess(client_, access ? 1 : 0); -} - -void RendererWebMIDIAccessorImpl::sendMIDIData( - unsigned port_index, - const unsigned char* data, - size_t length, - double timestamp) { - midi_message_filter()->SendMIDIData( - port_index, - data, - length, - timestamp); -} - -MIDIMessageFilter* RendererWebMIDIAccessorImpl::midi_message_filter() { - return RenderThreadImpl::current()->midi_message_filter(); -} - -} // namespace content diff --git a/content/renderer/media/renderer_webmidiaccessor_impl.h b/content/renderer/media/renderer_webmidiaccessor_impl.h deleted file mode 100644 index a6a07c9..0000000 --- a/content/renderer/media/renderer_webmidiaccessor_impl.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_RENDERER_MEDIA_RENDERER_WEBMIDIACCESSOR_IMPL_H_ -#define CONTENT_RENDERER_MEDIA_RENDERER_WEBMIDIACCESSOR_IMPL_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "third_party/WebKit/public/platform/WebMIDIAccessor.h" -#include "third_party/WebKit/public/platform/WebMIDIAccessorClient.h" - -namespace content { - -class MIDIMessageFilter; - -class RendererWebMIDIAccessorImpl - : public WebKit::WebMIDIAccessor { - public: - explicit RendererWebMIDIAccessorImpl( - WebKit::WebMIDIAccessorClient* client); - virtual ~RendererWebMIDIAccessorImpl(); - - // WebKit::WebMIDIAccessor implementation. - virtual void requestAccess(bool access) OVERRIDE; - virtual void sendMIDIData(unsigned port_index, - const unsigned char* data, - size_t length, - double timestamp) OVERRIDE; - - private: - WebKit::WebMIDIAccessorClient* client_; - - MIDIMessageFilter* midi_message_filter(); - - DISALLOW_COPY_AND_ASSIGN(RendererWebMIDIAccessorImpl); -}; - -} // namespace content - -#endif // CONTENT_RENDERER_MEDIA_RENDERER_WEBMIDIACCESSOR_IMPL_H_ diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 72e7fb5..795a92a 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -65,7 +65,6 @@ #include "content/renderer/media/audio_renderer_mixer_manager.h" #include "content/renderer/media/media_stream_center.h" #include "content/renderer/media/media_stream_dependency_factory.h" -#include "content/renderer/media/midi_message_filter.h" #include "content/renderer/media/peer_connection_tracker.h" #include "content/renderer/media/video_capture_impl_manager.h" #include "content/renderer/media/video_capture_message_filter.h" @@ -369,9 +368,6 @@ void RenderThreadImpl::Init() { audio_message_filter_ = new AudioMessageFilter(GetIOMessageLoopProxy()); AddFilter(audio_message_filter_.get()); - midi_message_filter_ = new MIDIMessageFilter(GetIOMessageLoopProxy()); - AddFilter(midi_message_filter_.get()); - AddFilter(new IndexedDBMessageFilter); GetContentClient()->renderer()->RenderThreadStarted(); diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index 9ef7002..63cc80c 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -81,7 +81,6 @@ class InputEventFilter; class InputHandlerManager; class MediaStreamCenter; class MediaStreamDependencyFactory; -class MIDIMessageFilter; class P2PSocketDispatcher; class PeerConnectionTracker; class RendererWebKitPlatformSupportImpl; @@ -228,9 +227,6 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread, return audio_message_filter_.get(); } - MIDIMessageFilter* midi_message_filter() { - return midi_message_filter_.get(); - } // Creates the embedder implementation of WebMediaStreamCenter. // The resulting object is owned by WebKit and deleted by WebKit at tear-down. @@ -383,7 +379,6 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread, scoped_refptr<DBMessageFilter> db_message_filter_; scoped_refptr<AudioInputMessageFilter> audio_input_message_filter_; scoped_refptr<AudioMessageFilter> audio_message_filter_; - scoped_refptr<MIDIMessageFilter> midi_message_filter_; scoped_refptr<DevToolsAgentFilter> devtools_agent_message_filter_; scoped_ptr<MediaStreamDependencyFactory> media_stream_factory_; diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index 0ec76a1..5e74dc4 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -31,7 +31,6 @@ #include "content/renderer/hyphenator/hyphenator.h" #include "content/renderer/media/media_stream_dependency_factory.h" #include "content/renderer/media/renderer_webaudiodevice_impl.h" -#include "content/renderer/media/renderer_webmidiaccessor_impl.h" #include "content/renderer/media/webcontentdecryptionmodule_impl.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/renderer_clipboard_client.h" @@ -92,7 +91,6 @@ using WebKit::WebFileSystem; using WebKit::WebFrame; using WebKit::WebGamepads; using WebKit::WebIDBFactory; -using WebKit::WebMIDIAccessor; using WebKit::Platform; using WebKit::WebMediaStreamCenter; using WebKit::WebMediaStreamCenterClient; @@ -773,14 +771,6 @@ RendererWebKitPlatformSupportImpl::createContentDecryptionModule( //------------------------------------------------------------------------------ -WebKit::WebMIDIAccessor* -RendererWebKitPlatformSupportImpl::createMIDIAccessor( - WebKit::WebMIDIAccessorClient* client) { - return new RendererWebMIDIAccessorImpl(client); -} - -//------------------------------------------------------------------------------ - WebKit::WebString RendererWebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( unsigned key_size_index, diff --git a/content/renderer/renderer_webkitplatformsupport_impl.h b/content/renderer/renderer_webkitplatformsupport_impl.h index 83990c4..104cd24 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.h +++ b/content/renderer/renderer_webkitplatformsupport_impl.h @@ -107,8 +107,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl virtual WebKit::WebContentDecryptionModule* createContentDecryptionModule( const WebKit::WebString& key_system); - virtual WebKit::WebMIDIAccessor* - createMIDIAccessor(WebKit::WebMIDIAccessorClient* client); virtual WebKit::WebBlobRegistry* blobRegistry(); virtual void sampleGamepads(WebKit::WebGamepads&); |