Disable ContentSettingBubbleModelTest.RPHAllow which is flaky.
[chromium-blink-merge.git] / content / renderer / pepper / pepper_broker_impl.h
blobd3653bb372b1650122ed3cf3a381f5cbaa6e7e9b
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/process.h"
10 #include "content/common/content_export.h"
11 #include "ppapi/proxy/proxy_channel.h"
12 #include "webkit/plugins/ppapi/plugin_delegate.h"
13 #include "webkit/plugins/ppapi/ppb_broker_impl.h"
15 namespace IPC {
16 struct ChannelHandle;
19 namespace ppapi {
20 namespace proxy {
21 class BrokerDispatcher;
25 namespace webkit {
26 namespace ppapi {
27 class PluginModule;
31 namespace content {
33 class PepperPluginDelegateImpl;
35 // This object is NOT thread-safe.
36 class CONTENT_EXPORT PepperBrokerDispatcherWrapper {
37 public:
38 PepperBrokerDispatcherWrapper();
39 ~PepperBrokerDispatcherWrapper();
41 bool Init(base::ProcessId broker_pid,
42 const IPC::ChannelHandle& channel_handle);
44 int32_t SendHandleToBroker(PP_Instance instance,
45 base::SyncSocket::Handle handle);
47 private:
48 scoped_ptr<ppapi::proxy::BrokerDispatcher> dispatcher_;
49 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_;
52 class PepperBrokerImpl : public webkit::ppapi::PluginDelegate::Broker,
53 public base::RefCountedThreadSafe<PepperBrokerImpl>{
54 public:
55 PepperBrokerImpl(webkit::ppapi::PluginModule* plugin_module,
56 PepperPluginDelegateImpl* delegate_);
58 // webkit::ppapi::PluginDelegate::Broker implementation.
59 virtual void Disconnect(webkit::ppapi::PPB_Broker_Impl* client) OVERRIDE;
61 // Adds a pending connection to the broker. Balances out Disconnect() calls.
62 void AddPendingConnect(webkit::ppapi::PPB_Broker_Impl* client);
64 // Called when the channel to the broker has been established.
65 void OnBrokerChannelConnected(base::ProcessId broker_pid,
66 const IPC::ChannelHandle& channel_handle);
68 // Called when we know whether permission to access the PPAPI broker was
69 // granted.
70 void OnBrokerPermissionResult(webkit::ppapi::PPB_Broker_Impl* client,
71 bool result);
73 private:
74 friend class base::RefCountedThreadSafe<PepperBrokerImpl>;
76 struct PendingConnection {
77 PendingConnection();
78 ~PendingConnection();
80 bool is_authorized;
81 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> client;
84 virtual ~PepperBrokerImpl();
86 // Reports failure to all clients that had pending operations.
87 void ReportFailureToClients(int error_code);
89 // Connects the plugin to the broker via a pipe.
90 void ConnectPluginToBroker(webkit::ppapi::PPB_Broker_Impl* client);
92 scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher_;
94 // A map of pointers to objects that have requested a connection to the weak
95 // pointer we can use to reference them. The mapping is needed so we can clean
96 // up entries for objects that may have been deleted.
97 typedef std::map<webkit::ppapi::PPB_Broker_Impl*, PendingConnection>
98 ClientMap;
99 ClientMap pending_connects_;
101 // Pointer to the associated plugin module.
102 // Always set and cleared at the same time as the module's pointer to this.
103 webkit::ppapi::PluginModule* plugin_module_;
105 base::WeakPtr<PepperPluginDelegateImpl> delegate_;
107 DISALLOW_COPY_AND_ASSIGN(PepperBrokerImpl);
110 } // namespace content
112 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROKER_IMPL_H_