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

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

Issue 7885009: Removed the dependency of PepperPluginRegistry on Pepper proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.h ('k') | ppapi/proxy/proxy_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bind.h" 10 #include "base/bind.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // occurred while the request was in-flight, so we need to NULL check. 326 // occurred while the request was in-flight, so we need to NULL check.
327 if (client_) 327 if (client_)
328 client_->StreamCreated(handle, length, socket_handle); 328 client_->StreamCreated(handle, length, socket_handle);
329 } else { 329 } else {
330 main_message_loop_->PostTask(FROM_HERE, 330 main_message_loop_->PostTask(FROM_HERE,
331 NewRunnableMethod(this, &PlatformAudioImpl::OnLowLatencyCreated, 331 NewRunnableMethod(this, &PlatformAudioImpl::OnLowLatencyCreated,
332 handle, socket_handle, length)); 332 handle, socket_handle, length));
333 } 333 }
334 } 334 }
335 335
336 class DispatcherWrapper 336 class DispatcherDelegate : public ppapi::proxy::ProxyChannel::Delegate {
337 public:
338 virtual ~DispatcherDelegate() {}
339
340 // ProxyChannel::Delegate implementation.
341 virtual base::MessageLoopProxy* GetIPCMessageLoop() {
342 // This is called only in the renderer so we know we have a child process.
343 DCHECK(ChildProcess::current()) << "Must be in the renderer.";
344 return ChildProcess::current()->io_message_loop_proxy();
345 }
346 virtual base::WaitableEvent* GetShutdownEvent() {
347 DCHECK(ChildProcess::current()) << "Must be in the renderer.";
348 return ChildProcess::current()->GetShutDownEvent();
349 }
350 };
351
352 class HostDispatcherWrapper
337 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { 353 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy {
338 public: 354 public:
339 DispatcherWrapper() {} 355 HostDispatcherWrapper() {}
340 virtual ~DispatcherWrapper() {} 356 virtual ~HostDispatcherWrapper() {}
341 357
342 bool Init(RenderView* render_view, 358 bool Init(base::ProcessHandle plugin_process_handle,
343 base::ProcessHandle plugin_process_handle,
344 const IPC::ChannelHandle& channel_handle, 359 const IPC::ChannelHandle& channel_handle,
345 PP_Module pp_module, 360 PP_Module pp_module,
346 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface); 361 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface,
362 const ppapi::Preferences& preferences) {
363 dispatcher_delegate_.reset(new DispatcherDelegate);
364 dispatcher_.reset(new ppapi::proxy::HostDispatcher(
365 plugin_process_handle, pp_module, local_get_interface));
366
367 if (!dispatcher_->InitHostWithChannel(
368 dispatcher_delegate_.get(),
369 channel_handle, true, preferences)) {
370 dispatcher_.reset();
371 dispatcher_delegate_.reset();
372 return false;
373 }
374 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true);
375 return true;
376 }
347 377
348 // OutOfProcessProxy implementation. 378 // OutOfProcessProxy implementation.
349 virtual const void* GetProxiedInterface(const char* name) { 379 virtual const void* GetProxiedInterface(const char* name) {
350 return dispatcher_->GetProxiedInterface(name); 380 return dispatcher_->GetProxiedInterface(name);
351 } 381 }
352 virtual void AddInstance(PP_Instance instance) { 382 virtual void AddInstance(PP_Instance instance) {
353 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); 383 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get());
354 } 384 }
355 virtual void RemoveInstance(PP_Instance instance) { 385 virtual void RemoveInstance(PP_Instance instance) {
356 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); 386 ppapi::proxy::HostDispatcher::RemoveForInstance(instance);
357 } 387 }
358 388
359 private: 389 private:
360 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; 390 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_;
391 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_;
361 }; 392 };
362 393
363 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { 394 class QuotaCallbackTranslator : public QuotaDispatcher::Callback {
364 public: 395 public:
365 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; 396 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback;
366 explicit QuotaCallbackTranslator(PluginCallback* cb) : callback_(cb) {} 397 explicit QuotaCallbackTranslator(PluginCallback* cb) : callback_(cb) {}
367 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { 398 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE {
368 callback_->Run(std::max(static_cast<int64>(0), quota - usage)); 399 callback_->Run(std::max(static_cast<int64>(0), quota - usage));
369 } 400 }
370 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE { 401 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 return handler_proxy_->state().frame_rate; 461 return handler_proxy_->state().frame_rate;
431 } 462 }
432 463
433 private: 464 private:
434 scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_; 465 scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_;
435 media::VideoCapture* video_capture_; 466 media::VideoCapture* video_capture_;
436 }; 467 };
437 468
438 } // namespace 469 } // namespace
439 470
440 bool DispatcherWrapper::Init(
441 RenderView* render_view,
442 base::ProcessHandle plugin_process_handle,
443 const IPC::ChannelHandle& channel_handle,
444 PP_Module pp_module,
445 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface) {
446 dispatcher_.reset(new ppapi::proxy::HostDispatcher(
447 plugin_process_handle, pp_module, local_get_interface));
448
449 if (!dispatcher_->InitHostWithChannel(
450 PepperPluginRegistry::GetInstance(),
451 channel_handle, true,
452 ppapi::Preferences(render_view->webkit_preferences()))) {
453 dispatcher_.reset();
454 return false;
455 }
456 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true);
457 return true;
458 }
459
460 BrokerDispatcherWrapper::BrokerDispatcherWrapper() { 471 BrokerDispatcherWrapper::BrokerDispatcherWrapper() {
461 } 472 }
462 473
463 BrokerDispatcherWrapper::~BrokerDispatcherWrapper() { 474 BrokerDispatcherWrapper::~BrokerDispatcherWrapper() {
464 } 475 }
465 476
466 bool BrokerDispatcherWrapper::Init( 477 bool BrokerDispatcherWrapper::Init(
467 base::ProcessHandle plugin_process_handle, 478 base::ProcessHandle plugin_process_handle,
468 const IPC::ChannelHandle& channel_handle) { 479 const IPC::ChannelHandle& channel_handle) {
480 dispatcher_delegate_.reset(new DispatcherDelegate);
469 dispatcher_.reset( 481 dispatcher_.reset(
470 new ppapi::proxy::BrokerHostDispatcher(plugin_process_handle)); 482 new ppapi::proxy::BrokerHostDispatcher(plugin_process_handle));
471 483
472 if (!dispatcher_->InitBrokerWithChannel(PepperPluginRegistry::GetInstance(), 484 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(),
473 channel_handle, 485 channel_handle,
474 true)) { 486 true)) {
475 dispatcher_.reset(); 487 dispatcher_.reset();
488 dispatcher_delegate_.reset();
476 return false; 489 return false;
477 } 490 }
478 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); 491 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true);
479 return true; 492 return true;
480 } 493 }
481 494
482 // Does not take ownership of the local pipe. 495 // Does not take ownership of the local pipe.
483 int32_t BrokerDispatcherWrapper::SendHandleToBroker( 496 int32_t BrokerDispatcherWrapper::SendHandleToBroker(
484 PP_Instance instance, 497 PP_Instance instance,
485 base::SyncSocket::Handle handle) { 498 base::SyncSocket::Handle handle) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 // Couldn't be initialized. 704 // Couldn't be initialized.
692 return scoped_refptr<webkit::ppapi::PluginModule>(); 705 return scoped_refptr<webkit::ppapi::PluginModule>();
693 } 706 }
694 707
695 // Create a new HostDispatcher for the proxying, and hook it to a new 708 // Create a new HostDispatcher for the proxying, and hook it to a new
696 // PluginModule. Note that AddLiveModule must be called before any early 709 // PluginModule. Note that AddLiveModule must be called before any early
697 // returns since the module's destructor will remove itself. 710 // returns since the module's destructor will remove itself.
698 module = new webkit::ppapi::PluginModule(info->name, path, 711 module = new webkit::ppapi::PluginModule(info->name, path,
699 PepperPluginRegistry::GetInstance()); 712 PepperPluginRegistry::GetInstance());
700 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); 713 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module);
701 scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); 714 scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper);
702 if (!dispatcher->Init( 715 if (!dispatcher->Init(
703 render_view_, 716 plugin_process_handle,
704 plugin_process_handle, channel_handle, 717 channel_handle,
705 module->pp_module(), 718 module->pp_module(),
706 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc())) 719 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(),
720 GetPreferences()))
707 return scoped_refptr<webkit::ppapi::PluginModule>(); 721 return scoped_refptr<webkit::ppapi::PluginModule>();
708 module->InitAsProxied(dispatcher.release()); 722 module->InitAsProxied(dispatcher.release());
709 return module; 723 return module;
710 } 724 }
711 725
712 scoped_refptr<PpapiBrokerImpl> PepperPluginDelegateImpl::CreatePpapiBroker( 726 scoped_refptr<PpapiBrokerImpl> PepperPluginDelegateImpl::CreatePpapiBroker(
713 webkit::ppapi::PluginModule* plugin_module) { 727 webkit::ppapi::PluginModule* plugin_module) {
714 DCHECK(plugin_module); 728 DCHECK(plugin_module);
715 DCHECK(!plugin_module->GetBroker()); 729 DCHECK(!plugin_module->GetBroker());
716 730
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 1492
1479 int PepperPluginDelegateImpl::GetRoutingId() const { 1493 int PepperPluginDelegateImpl::GetRoutingId() const {
1480 return render_view_->routing_id(); 1494 return render_view_->routing_id();
1481 } 1495 }
1482 1496
1483 void PepperPluginDelegateImpl::PublishInitialPolicy( 1497 void PepperPluginDelegateImpl::PublishInitialPolicy(
1484 scoped_refptr<webkit::ppapi::PluginInstance> instance, 1498 scoped_refptr<webkit::ppapi::PluginInstance> instance,
1485 const std::string& policy) { 1499 const std::string& policy) {
1486 instance->HandlePolicyUpdate(policy); 1500 instance->HandlePolicyUpdate(policy);
1487 } 1501 }
OLDNEW
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.h ('k') | ppapi/proxy/proxy_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698