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

Side by Side Diff: content/renderer/pepper_plugin_delegate_impl.cc

Issue 7157001: Implements AudioMessageFilter as member in RenderThread (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/renderer/pepper_plugin_delegate_impl.h" 5 #include "content/renderer/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl); 153 DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl);
154 }; 154 };
155 155
156 156
157 class PlatformAudioImpl 157 class PlatformAudioImpl
158 : public webkit::ppapi::PluginDelegate::PlatformAudio, 158 : public webkit::ppapi::PluginDelegate::PlatformAudio,
159 public AudioMessageFilter::Delegate, 159 public AudioMessageFilter::Delegate,
160 public base::RefCountedThreadSafe<PlatformAudioImpl> { 160 public base::RefCountedThreadSafe<PlatformAudioImpl> {
161 public: 161 public:
162 explicit PlatformAudioImpl(scoped_refptr<AudioMessageFilter> filter) 162 enum RoutingID {
163 DEFAULT_ROUTING_ID = 2,
164 };
165
166 explicit PlatformAudioImpl(AudioMessageFilter* filter)
163 : client_(NULL), filter_(filter), stream_id_(0), 167 : client_(NULL), filter_(filter), stream_id_(0),
164 main_message_loop_(MessageLoop::current()) { 168 main_message_loop_(MessageLoop::current()) {
165 DCHECK(filter_); 169 DCHECK(filter_);
170 if (!filter_->RoutingIDHasBeenSet()) {
171 // Ensure that first user sets a valid routing ID.
172 // This routing ID will remain during the lifetime of the audio message
173 // filter (which is a singleton).
174 filter_->SetRoutingID(DEFAULT_ROUTING_ID);
jam 2011/06/21 19:02:04 you can't just pick a routing a id in the renderer
175 }
166 } 176 }
167 177
168 virtual ~PlatformAudioImpl() { 178 virtual ~PlatformAudioImpl() {
169 // Make sure we have been shut down. Warning: this will usually happen on 179 // Make sure we have been shut down. Warning: this will usually happen on
170 // the I/O thread! 180 // the I/O thread!
171 DCHECK_EQ(0, stream_id_); 181 DCHECK_EQ(0, stream_id_);
172 DCHECK(!client_); 182 DCHECK(!client_);
173 } 183 }
174 184
175 // Initialize this audio context. StreamCreated() will be called when the 185 // Initialize this audio context. StreamCreated() will be called when the
(...skipping 28 matching lines...) Expand all
204 uint32 length); 214 uint32 length);
205 215
206 virtual void OnVolume(double volume) {} 216 virtual void OnVolume(double volume) {}
207 217
208 // The client to notify when the stream is created. THIS MUST ONLY BE 218 // The client to notify when the stream is created. THIS MUST ONLY BE
209 // ACCESSED ON THE MAIN THREAD. 219 // ACCESSED ON THE MAIN THREAD.
210 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client_; 220 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client_;
211 221
212 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE 222 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE
213 // I/O thread except to send messages and get the message loop. 223 // I/O thread except to send messages and get the message loop.
214 scoped_refptr<AudioMessageFilter> filter_; 224 // Cached result of Singleton<AudioMessageFilter>::get() to reduce overhead.
225 AudioMessageFilter* filter_;
215 226
216 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD 227 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD
217 // or else you could race with the initialize function which sets it. 228 // or else you could race with the initialize function which sets it.
218 int32 stream_id_; 229 int32 stream_id_;
219 230
220 MessageLoop* main_message_loop_; 231 MessageLoop* main_message_loop_;
221 232
222 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl); 233 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl);
223 }; 234 };
224 235
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 int index) { 854 int index) {
844 render_view_->reportFindInPageSelection( 855 render_view_->reportFindInPageSelection(
845 identifier, index + 1, WebKit::WebRect()); 856 identifier, index + 1, WebKit::WebRect());
846 } 857 }
847 858
848 webkit::ppapi::PluginDelegate::PlatformAudio* 859 webkit::ppapi::PluginDelegate::PlatformAudio*
849 PepperPluginDelegateImpl::CreateAudio( 860 PepperPluginDelegateImpl::CreateAudio(
850 uint32_t sample_rate, uint32_t sample_count, 861 uint32_t sample_rate, uint32_t sample_count,
851 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client) { 862 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client) {
852 scoped_refptr<PlatformAudioImpl> audio( 863 scoped_refptr<PlatformAudioImpl> audio(
853 new PlatformAudioImpl(render_view_->audio_message_filter())); 864 new PlatformAudioImpl(AudioMessageFilter::GetInstance()));
scherkus (not reviewing) 2011/06/21 17:24:00 since you have render_view object, why not use its
854 if (audio->Initialize(sample_rate, sample_count, client)) { 865 if (audio->Initialize(sample_rate, sample_count, client)) {
855 // Balanced by Release invoked in PlatformAudioImpl::ShutDownOnIOThread(). 866 // Balanced by Release invoked in PlatformAudioImpl::ShutDownOnIOThread().
856 return audio.release(); 867 return audio.release();
857 } else { 868 } else {
858 return NULL; 869 return NULL;
859 } 870 }
860 } 871 }
861 872
862 // If a broker has not already been created for this plugin, creates one. 873 // If a broker has not already been created for this plugin, creates one.
863 webkit::ppapi::PluginDelegate::PpapiBroker* 874 webkit::ppapi::PluginDelegate::PpapiBroker*
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 } 993 }
983 994
984 bool PepperPluginDelegateImpl::ReadDirectory( 995 bool PepperPluginDelegateImpl::ReadDirectory(
985 const GURL& directory_path, 996 const GURL& directory_path,
986 fileapi::FileSystemCallbackDispatcher* dispatcher) { 997 fileapi::FileSystemCallbackDispatcher* dispatcher) {
987 FileSystemDispatcher* file_system_dispatcher = 998 FileSystemDispatcher* file_system_dispatcher =
988 ChildThread::current()->file_system_dispatcher(); 999 ChildThread::current()->file_system_dispatcher();
989 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher); 1000 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher);
990 } 1001 }
991 1002
992 class AsyncOpenFileSystemURLCallbackTranslator : 1003 class AsyncOpenFileSystemURLCallbackTranslator
993 public fileapi::FileSystemCallbackDispatcher { 1004 : public fileapi::FileSystemCallbackDispatcher {
994 public: 1005 public:
995 AsyncOpenFileSystemURLCallbackTranslator( 1006 AsyncOpenFileSystemURLCallbackTranslator(
996 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback) 1007 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback)
997 : callback_(callback) { 1008 : callback_(callback) {
998 } 1009 }
999 1010
1000 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} 1011 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {}
1001 1012
1002 virtual void DidSucceed() { 1013 virtual void DidSucceed() {
1003 NOTREACHED(); 1014 NOTREACHED();
1004 } 1015 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 if (!base::SharedMemory::IsHandleValid(handle)) { 1339 if (!base::SharedMemory::IsHandleValid(handle)) {
1329 DLOG(WARNING) << "Browser failed to allocate shared memory"; 1340 DLOG(WARNING) << "Browser failed to allocate shared memory";
1330 return NULL; 1341 return NULL;
1331 } 1342 }
1332 return new base::SharedMemory(handle, false); 1343 return new base::SharedMemory(handle, false);
1333 } 1344 }
1334 1345
1335 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { 1346 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() {
1336 return ppapi::Preferences(render_view_->webkit_preferences()); 1347 return ppapi::Preferences(render_view_->webkit_preferences());
1337 } 1348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698