| 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_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROKER_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_BROKER_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_BROKER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/process/process.h" | 9 #include "base/process/process.h" |
| 10 #include "base/sync_socket.h" | 10 #include "base/sync_socket.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/renderer/pepper/ppb_broker_impl.h" | 12 #include "content/renderer/pepper/ppb_broker_impl.h" |
| 13 #include "ppapi/proxy/proxy_channel.h" | 13 #include "ppapi/proxy/proxy_channel.h" |
| 14 | 14 |
| 15 namespace IPC { | 15 namespace IPC { |
| 16 struct ChannelHandle; | 16 struct ChannelHandle; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace ppapi { | 19 namespace ppapi { |
| 20 namespace proxy { | 20 namespace proxy { |
| 21 class BrokerDispatcher; | 21 class BrokerDispatcher; |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 | 26 |
| 27 class PepperPluginDelegateImpl; | 27 class PepperHelperImpl; |
| 28 class PluginModule; | 28 class PluginModule; |
| 29 | 29 |
| 30 // This object is NOT thread-safe. | 30 // This object is NOT thread-safe. |
| 31 class CONTENT_EXPORT PepperBrokerDispatcherWrapper { | 31 class CONTENT_EXPORT PepperBrokerDispatcherWrapper { |
| 32 public: | 32 public: |
| 33 PepperBrokerDispatcherWrapper(); | 33 PepperBrokerDispatcherWrapper(); |
| 34 ~PepperBrokerDispatcherWrapper(); | 34 ~PepperBrokerDispatcherWrapper(); |
| 35 | 35 |
| 36 bool Init(base::ProcessId broker_pid, | 36 bool Init(base::ProcessId broker_pid, |
| 37 const IPC::ChannelHandle& channel_handle); | 37 const IPC::ChannelHandle& channel_handle); |
| 38 | 38 |
| 39 int32_t SendHandleToBroker(PP_Instance instance, | 39 int32_t SendHandleToBroker(PP_Instance instance, |
| 40 base::SyncSocket::Handle handle); | 40 base::SyncSocket::Handle handle); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 scoped_ptr<ppapi::proxy::BrokerDispatcher> dispatcher_; | 43 scoped_ptr<ppapi::proxy::BrokerDispatcher> dispatcher_; |
| 44 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; | 44 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class PepperBroker : public base::RefCountedThreadSafe<PepperBroker>{ | 47 class PepperBroker : public base::RefCountedThreadSafe<PepperBroker>{ |
| 48 public: | 48 public: |
| 49 PepperBroker(PluginModule* plugin_module, | 49 PepperBroker(PluginModule* plugin_module, PepperHelperImpl* helper); |
| 50 PepperPluginDelegateImpl* delegate_); | |
| 51 | 50 |
| 52 // Decrements the references to the broker. | 51 // Decrements the references to the broker. |
| 53 // When there are no more references, this renderer's dispatcher is | 52 // When there are no more references, this renderer's dispatcher is |
| 54 // destroyed, allowing the broker to shutdown if appropriate. | 53 // destroyed, allowing the broker to shutdown if appropriate. |
| 55 // Callers should not reference this object after calling Disconnect(). | 54 // Callers should not reference this object after calling Disconnect(). |
| 56 void Disconnect(PPB_Broker_Impl* client); | 55 void Disconnect(PPB_Broker_Impl* client); |
| 57 | 56 |
| 58 // Adds a pending connection to the broker. Balances out Disconnect() calls. | 57 // Adds a pending connection to the broker. Balances out Disconnect() calls. |
| 59 void AddPendingConnect(PPB_Broker_Impl* client); | 58 void AddPendingConnect(PPB_Broker_Impl* client); |
| 60 | 59 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 91 // A map of pointers to objects that have requested a connection to the weak | 90 // A map of pointers to objects that have requested a connection to the weak |
| 92 // pointer we can use to reference them. The mapping is needed so we can clean | 91 // pointer we can use to reference them. The mapping is needed so we can clean |
| 93 // up entries for objects that may have been deleted. | 92 // up entries for objects that may have been deleted. |
| 94 typedef std::map<PPB_Broker_Impl*, PendingConnection> ClientMap; | 93 typedef std::map<PPB_Broker_Impl*, PendingConnection> ClientMap; |
| 95 ClientMap pending_connects_; | 94 ClientMap pending_connects_; |
| 96 | 95 |
| 97 // Pointer to the associated plugin module. | 96 // Pointer to the associated plugin module. |
| 98 // Always set and cleared at the same time as the module's pointer to this. | 97 // Always set and cleared at the same time as the module's pointer to this. |
| 99 PluginModule* plugin_module_; | 98 PluginModule* plugin_module_; |
| 100 | 99 |
| 101 base::WeakPtr<PepperPluginDelegateImpl> delegate_; | 100 base::WeakPtr<PepperHelperImpl> helper_; |
| 102 | 101 |
| 103 DISALLOW_COPY_AND_ASSIGN(PepperBroker); | 102 DISALLOW_COPY_AND_ASSIGN(PepperBroker); |
| 104 }; | 103 }; |
| 105 | 104 |
| 106 } // namespace content | 105 } // namespace content |
| 107 | 106 |
| 108 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROKER_H_ | 107 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROKER_H_ |
| OLD | NEW |