Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "ppapi/proxy/proxy_channel.h" | 10 #include "ppapi/proxy/proxy_channel.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 scoped_ptr<ppapi::proxy::BrokerDispatcher> dispatcher_; | 46 scoped_ptr<ppapi::proxy::BrokerDispatcher> dispatcher_; |
| 47 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; | 47 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class PepperBrokerImpl : public webkit::ppapi::PluginDelegate::Broker, | 50 class PepperBrokerImpl : public webkit::ppapi::PluginDelegate::Broker, |
| 51 public base::RefCountedThreadSafe<PepperBrokerImpl>{ | 51 public base::RefCountedThreadSafe<PepperBrokerImpl>{ |
| 52 public: | 52 public: |
| 53 PepperBrokerImpl(webkit::ppapi::PluginModule* plugin_module, | 53 PepperBrokerImpl(webkit::ppapi::PluginModule* plugin_module, |
| 54 PepperPluginDelegateImpl* delegate_); | 54 PepperPluginDelegateImpl* delegate_); |
| 55 | 55 |
| 56 // PepperBroker implementation. | 56 // webkit::ppapi::PluginDelegate::Broker implementation. |
| 57 virtual void Connect(webkit::ppapi::PPB_Broker_Impl* client) OVERRIDE; | |
| 58 virtual void Disconnect(webkit::ppapi::PPB_Broker_Impl* client) OVERRIDE; | 57 virtual void Disconnect(webkit::ppapi::PPB_Broker_Impl* client) OVERRIDE; |
| 59 | 58 |
| 59 // Called to balance out Disconnect() calls. | |
| 60 void Connect(webkit::ppapi::PPB_Broker_Impl* client); | |
| 61 | |
| 60 // Called when the channel to the broker has been established. | 62 // Called when the channel to the broker has been established. |
| 61 void OnBrokerChannelConnected(const IPC::ChannelHandle& channel_handle); | 63 void OnBrokerChannelConnected(const IPC::ChannelHandle& channel_handle); |
| 62 | 64 |
| 65 // Called when we know whether permission to access the PPAPI broker was | |
| 66 // granted. | |
| 67 void OnBrokerPermissionResult(webkit::ppapi::PPB_Broker_Impl* client, | |
| 68 bool result); | |
| 69 | |
| 70 private: | |
| 71 friend class base::RefCountedThreadSafe<PepperBrokerImpl>; | |
| 72 | |
| 73 struct PendingConnection { | |
| 74 PendingConnection(); | |
| 75 ~PendingConnection(); | |
| 76 | |
| 77 bool authorized; | |
|
ddorwin
2012/08/12 22:51:16
is_authorized
Bernhard Bauer
2012/08/13 09:02:12
Done.
| |
| 78 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> client; | |
| 79 }; | |
| 80 | |
| 81 virtual ~PepperBrokerImpl(); | |
| 82 | |
| 83 // Reports failure to all clients that had pending operations. | |
| 84 void ReportFailureToClients(); | |
| 85 | |
| 63 // Connects the plugin to the broker via a pipe. | 86 // Connects the plugin to the broker via a pipe. |
| 64 void ConnectPluginToBroker(webkit::ppapi::PPB_Broker_Impl* client); | 87 void ConnectPluginToBroker(webkit::ppapi::PPB_Broker_Impl* client); |
| 65 | 88 |
| 66 // Asynchronously sends a pipe to the broker. | |
| 67 int32_t SendHandleToBroker(PP_Instance instance, | |
| 68 base::SyncSocket::Handle handle); | |
| 69 | |
| 70 protected: | |
| 71 friend class base::RefCountedThreadSafe<PepperBrokerImpl>; | |
| 72 | |
| 73 virtual ~PepperBrokerImpl(); | |
| 74 | |
| 75 scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher_; | 89 scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher_; |
| 76 | 90 |
| 77 // A map of pointers to objects that have requested a connection to the weak | 91 // A map of pointers to objects that have requested a connection to the weak |
| 78 // pointer we can use to reference them. The mapping is needed so we can clean | 92 // pointer we can use to reference them. The mapping is needed so we can clean |
| 79 // up entries for objects that may have been deleted. | 93 // up entries for objects that may have been deleted. |
| 80 typedef std::map<webkit::ppapi::PPB_Broker_Impl*, | 94 typedef std::map<webkit::ppapi::PPB_Broker_Impl*, PendingConnection> |
| 81 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> > ClientMap; | 95 ClientMap; |
| 82 ClientMap pending_connects_; | 96 ClientMap pending_connects_; |
| 83 | 97 |
| 84 // Pointer to the associated plugin module. | 98 // Pointer to the associated plugin module. |
| 85 // Always set and cleared at the same time as the module's pointer to this. | 99 // Always set and cleared at the same time as the module's pointer to this. |
| 86 webkit::ppapi::PluginModule* plugin_module_; | 100 webkit::ppapi::PluginModule* plugin_module_; |
| 87 | 101 |
| 88 base::WeakPtr<PepperPluginDelegateImpl> delegate_; | 102 base::WeakPtr<PepperPluginDelegateImpl> delegate_; |
| 89 | 103 |
| 90 DISALLOW_COPY_AND_ASSIGN(PepperBrokerImpl); | 104 DISALLOW_COPY_AND_ASSIGN(PepperBrokerImpl); |
| 91 }; | 105 }; |
| 92 | 106 |
| 93 } // namespace content | 107 } // namespace content |
| 94 | 108 |
| 95 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_ | 109 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_ |
| OLD | NEW |