| 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/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/file_util_proxy.h" | 14 #include "base/file_util_proxy.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 18 #include "base/sync_socket.h" | 18 #include "base/sync_socket.h" |
| 19 #include "base/task.h" | 19 #include "base/task.h" |
| 20 #include "base/time.h" | 20 #include "base/time.h" |
| 21 #include "content/common/child_process_messages.h" | 21 #include "content/common/child_process_messages.h" |
| 22 #include "content/common/child_process.h" | 22 #include "content/common/child_process.h" |
| 23 #include "content/common/child_thread.h" | 23 #include "content/common/child_thread.h" |
| 24 #include "content/common/content_switches.h" | 24 #include "content/common/content_switches.h" |
| 25 #include "content/common/file_system/file_system_dispatcher.h" | 25 #include "content/common/file_system/file_system_dispatcher.h" |
| 26 #include "content/common/file_system_messages.h" |
| 26 #include "content/common/media/audio_messages.h" | 27 #include "content/common/media/audio_messages.h" |
| 27 #include "content/common/pepper_file_messages.h" | 28 #include "content/common/pepper_file_messages.h" |
| 28 #include "content/common/pepper_plugin_registry.h" | 29 #include "content/common/pepper_plugin_registry.h" |
| 29 #include "content/common/pepper_messages.h" | 30 #include "content/common/pepper_messages.h" |
| 31 #include "content/common/quota_dispatcher.h" |
| 30 #include "content/common/view_messages.h" | 32 #include "content/common/view_messages.h" |
| 31 #include "content/renderer/content_renderer_client.h" | 33 #include "content/renderer/content_renderer_client.h" |
| 32 #include "content/renderer/gpu/command_buffer_proxy.h" | 34 #include "content/renderer/gpu/command_buffer_proxy.h" |
| 33 #include "content/renderer/gpu/gpu_channel_host.h" | 35 #include "content/renderer/gpu/gpu_channel_host.h" |
| 34 #include "content/renderer/gpu/renderer_gl_context.h" | 36 #include "content/renderer/gpu/renderer_gl_context.h" |
| 35 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" | 37 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" |
| 36 #include "content/renderer/media/audio_message_filter.h" | 38 #include "content/renderer/media/audio_message_filter.h" |
| 37 #include "content/renderer/p2p/p2p_transport_impl.h" | 39 #include "content/renderer/p2p/p2p_transport_impl.h" |
| 38 #include "content/renderer/pepper_platform_context_3d_impl.h" | 40 #include "content/renderer/pepper_platform_context_3d_impl.h" |
| 39 #include "content/renderer/pepper_platform_video_decoder_impl.h" | 41 #include "content/renderer/pepper_platform_video_decoder_impl.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); | 352 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); |
| 351 } | 353 } |
| 352 virtual void RemoveInstance(PP_Instance instance) { | 354 virtual void RemoveInstance(PP_Instance instance) { |
| 353 pp::proxy::HostDispatcher::RemoveForInstance(instance); | 355 pp::proxy::HostDispatcher::RemoveForInstance(instance); |
| 354 } | 356 } |
| 355 | 357 |
| 356 private: | 358 private: |
| 357 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; | 359 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; |
| 358 }; | 360 }; |
| 359 | 361 |
| 362 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { |
| 363 public: |
| 364 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; |
| 365 explicit QuotaCallbackTranslator(PluginCallback* cb) : callback_(cb) {} |
| 366 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { |
| 367 callback_->Run(std::max(static_cast<int64>(0), quota - usage)); |
| 368 } |
| 369 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE { |
| 370 NOTREACHED(); |
| 371 } |
| 372 virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE { |
| 373 callback_->Run(0); |
| 374 } |
| 375 private: |
| 376 scoped_ptr<PluginCallback> callback_; |
| 377 }; |
| 378 |
| 360 } // namespace | 379 } // namespace |
| 361 | 380 |
| 362 bool DispatcherWrapper::Init( | 381 bool DispatcherWrapper::Init( |
| 363 RenderView* render_view, | 382 RenderView* render_view, |
| 364 base::ProcessHandle plugin_process_handle, | 383 base::ProcessHandle plugin_process_handle, |
| 365 const IPC::ChannelHandle& channel_handle, | 384 const IPC::ChannelHandle& channel_handle, |
| 366 PP_Module pp_module, | 385 PP_Module pp_module, |
| 367 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { | 386 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { |
| 368 dispatcher_.reset(new pp::proxy::HostDispatcher( | 387 dispatcher_.reset(new pp::proxy::HostDispatcher( |
| 369 plugin_process_handle, pp_module, local_get_interface)); | 388 plugin_process_handle, pp_module, local_get_interface)); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher); | 1021 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher); |
| 1003 } | 1022 } |
| 1004 | 1023 |
| 1005 void PepperPluginDelegateImpl::PublishPolicy(const std::string& policy_json) { | 1024 void PepperPluginDelegateImpl::PublishPolicy(const std::string& policy_json) { |
| 1006 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = | 1025 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = |
| 1007 subscribed_to_policy_updates_.begin(); | 1026 subscribed_to_policy_updates_.begin(); |
| 1008 i != subscribed_to_policy_updates_.end(); ++i) | 1027 i != subscribed_to_policy_updates_.end(); ++i) |
| 1009 (*i)->HandlePolicyUpdate(policy_json); | 1028 (*i)->HandlePolicyUpdate(policy_json); |
| 1010 } | 1029 } |
| 1011 | 1030 |
| 1031 void PepperPluginDelegateImpl::QueryAvailableSpace( |
| 1032 const GURL& origin, quota::StorageType type, |
| 1033 AvailableSpaceCallback* callback) { |
| 1034 ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota( |
| 1035 origin, type, new QuotaCallbackTranslator(callback)); |
| 1036 } |
| 1037 |
| 1038 void PepperPluginDelegateImpl::WillUpdateFile(const GURL& path) { |
| 1039 ChildThread::current()->Send(new FileSystemHostMsg_WillUpdate(path)); |
| 1040 } |
| 1041 |
| 1042 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) { |
| 1043 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta)); |
| 1044 } |
| 1045 |
| 1012 class AsyncOpenFileSystemURLCallbackTranslator | 1046 class AsyncOpenFileSystemURLCallbackTranslator |
| 1013 : public fileapi::FileSystemCallbackDispatcher { | 1047 : public fileapi::FileSystemCallbackDispatcher { |
| 1014 public: | 1048 public: |
| 1015 AsyncOpenFileSystemURLCallbackTranslator( | 1049 AsyncOpenFileSystemURLCallbackTranslator( |
| 1016 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback) | 1050 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback) |
| 1017 : callback_(callback) { | 1051 : callback_(callback) { |
| 1018 } | 1052 } |
| 1019 | 1053 |
| 1020 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} | 1054 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} |
| 1021 | 1055 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 | 1405 |
| 1372 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { | 1406 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { |
| 1373 return ppapi::Preferences(render_view_->webkit_preferences()); | 1407 return ppapi::Preferences(render_view_->webkit_preferences()); |
| 1374 } | 1408 } |
| 1375 | 1409 |
| 1376 void PepperPluginDelegateImpl::PublishInitialPolicy( | 1410 void PepperPluginDelegateImpl::PublishInitialPolicy( |
| 1377 scoped_refptr<webkit::ppapi::PluginInstance> instance, | 1411 scoped_refptr<webkit::ppapi::PluginInstance> instance, |
| 1378 const std::string& policy) { | 1412 const std::string& policy) { |
| 1379 instance->HandlePolicyUpdate(policy); | 1413 instance->HandlePolicyUpdate(policy); |
| 1380 } | 1414 } |
| OLD | NEW |