OLD | NEW |
---|---|
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 Loading... | |
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 explicit PlatformAudioImpl(AudioMessageFilter* filter) |
163 : client_(NULL), filter_(filter), stream_id_(0), | 163 : client_(NULL), filter_(filter), stream_id_(0), |
164 main_message_loop_(MessageLoop::current()) { | 164 main_message_loop_(MessageLoop::current()) { |
165 DCHECK(filter_); | 165 DCHECK(filter_); |
166 } | 166 } |
167 | 167 |
168 virtual ~PlatformAudioImpl() { | 168 virtual ~PlatformAudioImpl() { |
169 // Make sure we have been shut down. Warning: this will usually happen on | 169 // Make sure we have been shut down. Warning: this will usually happen on |
170 // the I/O thread! | 170 // the I/O thread! |
171 DCHECK_EQ(0, stream_id_); | 171 DCHECK_EQ(0, stream_id_); |
172 DCHECK(!client_); | 172 DCHECK(!client_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 uint32 length); | 204 uint32 length); |
205 | 205 |
206 virtual void OnVolume(double volume) {} | 206 virtual void OnVolume(double volume) {} |
207 | 207 |
208 // The client to notify when the stream is created. THIS MUST ONLY BE | 208 // The client to notify when the stream is created. THIS MUST ONLY BE |
209 // ACCESSED ON THE MAIN THREAD. | 209 // ACCESSED ON THE MAIN THREAD. |
210 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client_; | 210 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client_; |
211 | 211 |
212 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE | 212 // 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. | 213 // I/O thread except to send messages and get the message loop. |
214 scoped_refptr<AudioMessageFilter> filter_; | 214 // Cached result of Singleton<AudioMessageFilter>::get() to reduce overhead. |
215 AudioMessageFilter* filter_; | |
215 | 216 |
216 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 217 // 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. | 218 // or else you could race with the initialize function which sets it. |
218 int32 stream_id_; | 219 int32 stream_id_; |
219 | 220 |
220 MessageLoop* main_message_loop_; | 221 MessageLoop* main_message_loop_; |
221 | 222 |
222 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl); | 223 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl); |
223 }; | 224 }; |
224 | 225 |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
843 int index) { | 844 int index) { |
844 render_view_->reportFindInPageSelection( | 845 render_view_->reportFindInPageSelection( |
845 identifier, index + 1, WebKit::WebRect()); | 846 identifier, index + 1, WebKit::WebRect()); |
846 } | 847 } |
847 | 848 |
848 webkit::ppapi::PluginDelegate::PlatformAudio* | 849 webkit::ppapi::PluginDelegate::PlatformAudio* |
849 PepperPluginDelegateImpl::CreateAudio( | 850 PepperPluginDelegateImpl::CreateAudio( |
850 uint32_t sample_rate, uint32_t sample_count, | 851 uint32_t sample_rate, uint32_t sample_count, |
851 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client) { | 852 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client) { |
852 scoped_refptr<PlatformAudioImpl> audio( | 853 scoped_refptr<PlatformAudioImpl> audio( |
853 new PlatformAudioImpl(render_view_->audio_message_filter())); | 854 new PlatformAudioImpl(AudioMessageFilter::GetInstance())); |
854 if (audio->Initialize(sample_rate, sample_count, client)) { | 855 if (audio->Initialize(sample_rate, sample_count, client)) { |
855 // Balanced by Release invoked in PlatformAudioImpl::ShutDownOnIOThread(). | 856 // Balanced by Release invoked in PlatformAudioImpl::ShutDownOnIOThread(). |
856 return audio.release(); | 857 return audio.release(); |
857 } else { | 858 } else { |
858 return NULL; | 859 return NULL; |
859 } | 860 } |
860 } | 861 } |
861 | 862 |
862 // If a broker has not already been created for this plugin, creates one. | 863 // If a broker has not already been created for this plugin, creates one. |
863 webkit::ppapi::PluginDelegate::PpapiBroker* | 864 webkit::ppapi::PluginDelegate::PpapiBroker* |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
982 } | 983 } |
983 | 984 |
984 bool PepperPluginDelegateImpl::ReadDirectory( | 985 bool PepperPluginDelegateImpl::ReadDirectory( |
985 const GURL& directory_path, | 986 const GURL& directory_path, |
986 fileapi::FileSystemCallbackDispatcher* dispatcher) { | 987 fileapi::FileSystemCallbackDispatcher* dispatcher) { |
987 FileSystemDispatcher* file_system_dispatcher = | 988 FileSystemDispatcher* file_system_dispatcher = |
988 ChildThread::current()->file_system_dispatcher(); | 989 ChildThread::current()->file_system_dispatcher(); |
989 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher); | 990 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher); |
990 } | 991 } |
991 | 992 |
992 class AsyncOpenFileSystemURLCallbackTranslator : | 993 class AsyncOpenFileSystemURLCallbackTranslator |
993 public fileapi::FileSystemCallbackDispatcher { | 994 : public fileapi::FileSystemCallbackDispatcher { |
scherkus (not reviewing)
2011/06/17 17:50:10
indentation
henrika_dont_use
2011/06/21 16:43:38
Done.
| |
994 public: | 995 public: |
995 AsyncOpenFileSystemURLCallbackTranslator( | 996 AsyncOpenFileSystemURLCallbackTranslator( |
996 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback) | 997 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback) |
997 : callback_(callback) { | 998 : callback_(callback) { |
998 } | 999 } |
999 | 1000 |
1000 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} | 1001 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} |
1001 | 1002 |
1002 virtual void DidSucceed() { | 1003 virtual void DidSucceed() { |
1003 NOTREACHED(); | 1004 NOTREACHED(); |
1004 } | 1005 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1328 if (!base::SharedMemory::IsHandleValid(handle)) { | 1329 if (!base::SharedMemory::IsHandleValid(handle)) { |
1329 DLOG(WARNING) << "Browser failed to allocate shared memory"; | 1330 DLOG(WARNING) << "Browser failed to allocate shared memory"; |
1330 return NULL; | 1331 return NULL; |
1331 } | 1332 } |
1332 return new base::SharedMemory(handle, false); | 1333 return new base::SharedMemory(handle, false); |
1333 } | 1334 } |
1334 | 1335 |
1335 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { | 1336 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { |
1336 return ppapi::Preferences(render_view_->webkit_preferences()); | 1337 return ppapi::Preferences(render_view_->webkit_preferences()); |
1337 } | 1338 } |
OLD | NEW |