| 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" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 class DispatcherWrapper | 335 class DispatcherWrapper |
| 336 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { | 336 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { |
| 337 public: | 337 public: |
| 338 DispatcherWrapper() {} | 338 DispatcherWrapper() {} |
| 339 virtual ~DispatcherWrapper() {} | 339 virtual ~DispatcherWrapper() {} |
| 340 | 340 |
| 341 bool Init(RenderView* render_view, | 341 bool Init(RenderView* render_view, |
| 342 base::ProcessHandle plugin_process_handle, | 342 base::ProcessHandle plugin_process_handle, |
| 343 const IPC::ChannelHandle& channel_handle, | 343 const IPC::ChannelHandle& channel_handle, |
| 344 PP_Module pp_module, | 344 PP_Module pp_module, |
| 345 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface); | 345 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface); |
| 346 | 346 |
| 347 // OutOfProcessProxy implementation. | 347 // OutOfProcessProxy implementation. |
| 348 virtual const void* GetProxiedInterface(const char* name) { | 348 virtual const void* GetProxiedInterface(const char* name) { |
| 349 return dispatcher_->GetProxiedInterface(name); | 349 return dispatcher_->GetProxiedInterface(name); |
| 350 } | 350 } |
| 351 virtual void AddInstance(PP_Instance instance) { | 351 virtual void AddInstance(PP_Instance instance) { |
| 352 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); | 352 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); |
| 353 } | 353 } |
| 354 virtual void RemoveInstance(PP_Instance instance) { | 354 virtual void RemoveInstance(PP_Instance instance) { |
| 355 pp::proxy::HostDispatcher::RemoveForInstance(instance); | 355 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); |
| 356 } | 356 } |
| 357 | 357 |
| 358 private: | 358 private: |
| 359 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; | 359 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; |
| 360 }; | 360 }; |
| 361 | 361 |
| 362 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { | 362 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { |
| 363 public: | 363 public: |
| 364 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; | 364 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; |
| 365 explicit QuotaCallbackTranslator(PluginCallback* cb) : callback_(cb) {} | 365 explicit QuotaCallbackTranslator(PluginCallback* cb) : callback_(cb) {} |
| 366 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { | 366 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { |
| 367 callback_->Run(std::max(static_cast<int64>(0), quota - usage)); | 367 callback_->Run(std::max(static_cast<int64>(0), quota - usage)); |
| 368 } | 368 } |
| 369 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE { | 369 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 media::VideoCapture* video_capture_; | 434 media::VideoCapture* video_capture_; |
| 435 }; | 435 }; |
| 436 | 436 |
| 437 } // namespace | 437 } // namespace |
| 438 | 438 |
| 439 bool DispatcherWrapper::Init( | 439 bool DispatcherWrapper::Init( |
| 440 RenderView* render_view, | 440 RenderView* render_view, |
| 441 base::ProcessHandle plugin_process_handle, | 441 base::ProcessHandle plugin_process_handle, |
| 442 const IPC::ChannelHandle& channel_handle, | 442 const IPC::ChannelHandle& channel_handle, |
| 443 PP_Module pp_module, | 443 PP_Module pp_module, |
| 444 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { | 444 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { |
| 445 dispatcher_.reset(new pp::proxy::HostDispatcher( | 445 dispatcher_.reset(new ppapi::proxy::HostDispatcher( |
| 446 plugin_process_handle, pp_module, local_get_interface)); | 446 plugin_process_handle, pp_module, local_get_interface)); |
| 447 | 447 |
| 448 if (!dispatcher_->InitHostWithChannel( | 448 if (!dispatcher_->InitHostWithChannel( |
| 449 PepperPluginRegistry::GetInstance(), | 449 PepperPluginRegistry::GetInstance(), |
| 450 channel_handle, true, | 450 channel_handle, true, |
| 451 ppapi::Preferences(render_view->webkit_preferences()))) { | 451 ppapi::Preferences(render_view->webkit_preferences()))) { |
| 452 dispatcher_.reset(); | 452 dispatcher_.reset(); |
| 453 return false; | 453 return false; |
| 454 } | 454 } |
| 455 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); | 455 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); |
| 456 return true; | 456 return true; |
| 457 } | 457 } |
| 458 | 458 |
| 459 BrokerDispatcherWrapper::BrokerDispatcherWrapper() { | 459 BrokerDispatcherWrapper::BrokerDispatcherWrapper() { |
| 460 } | 460 } |
| 461 | 461 |
| 462 BrokerDispatcherWrapper::~BrokerDispatcherWrapper() { | 462 BrokerDispatcherWrapper::~BrokerDispatcherWrapper() { |
| 463 } | 463 } |
| 464 | 464 |
| 465 bool BrokerDispatcherWrapper::Init( | 465 bool BrokerDispatcherWrapper::Init( |
| 466 base::ProcessHandle plugin_process_handle, | 466 base::ProcessHandle plugin_process_handle, |
| 467 const IPC::ChannelHandle& channel_handle) { | 467 const IPC::ChannelHandle& channel_handle) { |
| 468 dispatcher_.reset( | 468 dispatcher_.reset( |
| 469 new pp::proxy::BrokerHostDispatcher(plugin_process_handle)); | 469 new ppapi::proxy::BrokerHostDispatcher(plugin_process_handle)); |
| 470 | 470 |
| 471 if (!dispatcher_->InitBrokerWithChannel(PepperPluginRegistry::GetInstance(), | 471 if (!dispatcher_->InitBrokerWithChannel(PepperPluginRegistry::GetInstance(), |
| 472 channel_handle, | 472 channel_handle, |
| 473 true)) { | 473 true)) { |
| 474 dispatcher_.reset(); | 474 dispatcher_.reset(); |
| 475 return false; | 475 return false; |
| 476 } | 476 } |
| 477 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); | 477 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); |
| 478 return true; | 478 return true; |
| 479 } | 479 } |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 | 1467 |
| 1468 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { | 1468 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { |
| 1469 return ppapi::Preferences(render_view_->webkit_preferences()); | 1469 return ppapi::Preferences(render_view_->webkit_preferences()); |
| 1470 } | 1470 } |
| 1471 | 1471 |
| 1472 void PepperPluginDelegateImpl::PublishInitialPolicy( | 1472 void PepperPluginDelegateImpl::PublishInitialPolicy( |
| 1473 scoped_refptr<webkit::ppapi::PluginInstance> instance, | 1473 scoped_refptr<webkit::ppapi::PluginInstance> instance, |
| 1474 const std::string& policy) { | 1474 const std::string& policy) { |
| 1475 instance->HandlePolicyUpdate(policy); | 1475 instance->HandlePolicyUpdate(policy); |
| 1476 } | 1476 } |
| OLD | NEW |