Chromium Code Reviews| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { | 356 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { |
| 357 public: | 357 public: |
| 358 HostDispatcherWrapper() {} | 358 HostDispatcherWrapper() {} |
| 359 virtual ~HostDispatcherWrapper() {} | 359 virtual ~HostDispatcherWrapper() {} |
| 360 | 360 |
| 361 bool Init(base::ProcessHandle plugin_process_handle, | 361 bool Init(base::ProcessHandle plugin_process_handle, |
| 362 const IPC::ChannelHandle& channel_handle, | 362 const IPC::ChannelHandle& channel_handle, |
| 363 PP_Module pp_module, | 363 PP_Module pp_module, |
| 364 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface, | 364 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface, |
| 365 const ppapi::Preferences& preferences) { | 365 const ppapi::Preferences& preferences) { |
| 366 if (channel_handle.name.empty()) | |
| 367 return false; | |
| 368 | |
| 369 #if defined(OS_POSIX) | |
| 370 if (channel_handle.socket.fd == -1) | |
| 371 return false; | |
| 372 #endif | |
| 373 | |
| 366 dispatcher_delegate_.reset(new DispatcherDelegate); | 374 dispatcher_delegate_.reset(new DispatcherDelegate); |
| 367 dispatcher_.reset(new ppapi::proxy::HostDispatcher( | 375 dispatcher_.reset(new ppapi::proxy::HostDispatcher( |
| 368 plugin_process_handle, pp_module, local_get_interface)); | 376 plugin_process_handle, pp_module, local_get_interface)); |
| 369 | 377 |
| 370 if (!dispatcher_->InitHostWithChannel( | 378 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), |
| 371 dispatcher_delegate_.get(), | 379 channel_handle, |
| 372 channel_handle, true, preferences)) { | 380 true, // is client |
|
ddorwin
2011/11/07 23:54:07
Two spaces then "// Client."
xhwang
2011/11/08 00:45:39
Done.
| |
| 381 preferences)) { | |
| 373 dispatcher_.reset(); | 382 dispatcher_.reset(); |
| 374 dispatcher_delegate_.reset(); | 383 dispatcher_delegate_.reset(); |
| 375 return false; | 384 return false; |
| 376 } | 385 } |
| 377 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); | 386 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); |
| 378 return true; | 387 return true; |
| 379 } | 388 } |
| 380 | 389 |
| 381 // OutOfProcessProxy implementation. | 390 // OutOfProcessProxy implementation. |
| 382 virtual const void* GetProxiedInterface(const char* name) { | 391 virtual const void* GetProxiedInterface(const char* name) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 | 482 |
| 474 BrokerDispatcherWrapper::BrokerDispatcherWrapper() { | 483 BrokerDispatcherWrapper::BrokerDispatcherWrapper() { |
| 475 } | 484 } |
| 476 | 485 |
| 477 BrokerDispatcherWrapper::~BrokerDispatcherWrapper() { | 486 BrokerDispatcherWrapper::~BrokerDispatcherWrapper() { |
| 478 } | 487 } |
| 479 | 488 |
| 480 bool BrokerDispatcherWrapper::Init( | 489 bool BrokerDispatcherWrapper::Init( |
| 481 base::ProcessHandle broker_process_handle, | 490 base::ProcessHandle broker_process_handle, |
| 482 const IPC::ChannelHandle& channel_handle) { | 491 const IPC::ChannelHandle& channel_handle) { |
| 492 if (channel_handle.name.empty()) | |
| 493 return false; | |
| 494 | |
| 495 #if defined(OS_POSIX) | |
| 496 if (channel_handle.socket.fd == -1) | |
| 497 return false; | |
| 498 #endif | |
| 499 | |
| 483 dispatcher_delegate_.reset(new DispatcherDelegate); | 500 dispatcher_delegate_.reset(new DispatcherDelegate); |
| 484 dispatcher_.reset( | 501 dispatcher_.reset( |
| 485 new ppapi::proxy::BrokerHostDispatcher(broker_process_handle)); | 502 new ppapi::proxy::BrokerHostDispatcher(broker_process_handle)); |
| 486 | 503 |
| 487 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(), | 504 if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(), |
| 488 channel_handle, | 505 channel_handle, |
| 489 true)) { | 506 true)) { // is_client |
|
ddorwin
2011/11/07 23:54:07
same
xhwang
2011/11/08 00:45:39
Done.
| |
| 490 dispatcher_.reset(); | 507 dispatcher_.reset(); |
| 491 dispatcher_delegate_.reset(); | 508 dispatcher_delegate_.reset(); |
| 492 return false; | 509 return false; |
| 493 } | 510 } |
| 494 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); | 511 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); |
| 495 return true; | 512 return true; |
| 496 } | 513 } |
| 497 | 514 |
| 498 // Does not take ownership of the local pipe. | 515 // Does not take ownership of the local pipe. |
| 499 int32_t BrokerDispatcherWrapper::SendHandleToBroker( | 516 int32_t BrokerDispatcherWrapper::SendHandleToBroker( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 Release(); | 619 Release(); |
| 603 } | 620 } |
| 604 | 621 |
| 605 void PpapiBrokerImpl::OnBrokerChannelConnected( | 622 void PpapiBrokerImpl::OnBrokerChannelConnected( |
| 606 base::ProcessHandle broker_process_handle, | 623 base::ProcessHandle broker_process_handle, |
| 607 const IPC::ChannelHandle& channel_handle) { | 624 const IPC::ChannelHandle& channel_handle) { |
| 608 scoped_ptr<BrokerDispatcherWrapper> dispatcher(new BrokerDispatcherWrapper); | 625 scoped_ptr<BrokerDispatcherWrapper> dispatcher(new BrokerDispatcherWrapper); |
| 609 if (dispatcher->Init(broker_process_handle, channel_handle)) { | 626 if (dispatcher->Init(broker_process_handle, channel_handle)) { |
| 610 dispatcher_.reset(dispatcher.release()); | 627 dispatcher_.reset(dispatcher.release()); |
| 611 | 628 |
| 612 // Process all pending channel requests from the renderers. | 629 // Process all pending channel requests from the plugins. |
| 613 for (ClientMap::iterator i = pending_connects_.begin(); | 630 for (ClientMap::iterator i = pending_connects_.begin(); |
| 614 i != pending_connects_.end(); ++i) { | 631 i != pending_connects_.end(); ++i) { |
| 615 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second; | 632 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second; |
| 616 if (weak_ptr) | 633 if (weak_ptr) |
| 617 ConnectPluginToBroker(weak_ptr); | 634 ConnectPluginToBroker(weak_ptr); |
| 618 } | 635 } |
| 619 } else { | 636 } else { |
| 620 // Report failure to all clients. | 637 // Report failure to all clients. |
| 621 for (ClientMap::iterator i = pending_connects_.begin(); | 638 for (ClientMap::iterator i = pending_connects_.begin(); |
| 622 i != pending_connects_.end(); ++i) { | 639 i != pending_connects_.end(); ++i) { |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1737 if (!context) | 1754 if (!context) |
| 1738 return NULL; | 1755 return NULL; |
| 1739 if (!context->makeContextCurrent() || context->isContextLost()) | 1756 if (!context->makeContextCurrent() || context->isContextLost()) |
| 1740 return NULL; | 1757 return NULL; |
| 1741 | 1758 |
| 1742 RendererGLContext* parent_context = context->context(); | 1759 RendererGLContext* parent_context = context->context(); |
| 1743 if (!parent_context) | 1760 if (!parent_context) |
| 1744 return NULL; | 1761 return NULL; |
| 1745 return parent_context; | 1762 return parent_context; |
| 1746 } | 1763 } |
| OLD | NEW |