[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef PPAPI_PPB_BROKER_PROXY_H_ | ||||
6 | #define PPAPI_PPB_BROKER_PROXY_H_ | ||||
7 | |||||
8 | #include "base/sync_socket.h" | ||||
9 | #include "ipc/ipc_platform_file.h" | ||||
10 | #include "ppapi/c/pp_instance.h" | ||||
11 | #include "ppapi/cpp/completion_callback.h" | ||||
12 | #include "ppapi/proxy/interface_proxy.h" | ||||
13 | #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" | ||||
14 | |||||
[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 15 | struct PPB_BrokerTrusted; |
16 | |||||
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 17 | namespace ppapi { |
18 | class HostResource; | ||||
19 | } | ||||
20 | |||||
[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 21 | namespace pp { |
22 | namespace proxy { | ||||
23 | |||||
[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 24 | class PPB_Broker_Proxy : public InterfaceProxy { |
25 | public: | ||||
26 | PPB_Broker_Proxy(Dispatcher* dispatcher, const void* target_interface); | ||||
27 | virtual ~PPB_Broker_Proxy(); | ||||
28 | |||||
29 | static const Info* GetInfo(); | ||||
30 | |||||
[email protected] | 9815108e | 2011-05-27 21:50:28 | [diff] [blame] | 31 | static PP_Resource CreateProxyResource(PP_Instance instance); |
32 | |||||
[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 33 | const PPB_BrokerTrusted* ppb_broker_target() const { |
34 | return static_cast<const PPB_BrokerTrusted*>(target_interface()); | ||||
35 | } | ||||
36 | |||||
37 | // InterfaceProxy implementation. | ||||
38 | virtual bool OnMessageReceived(const IPC::Message& msg); | ||||
39 | |||||
40 | private: | ||||
41 | // Message handlers. | ||||
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 42 | void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource); |
43 | void OnMsgConnect(const ppapi::HostResource& broker); | ||||
44 | void OnMsgConnectComplete(const ppapi::HostResource& broker, | ||||
[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 45 | IPC::PlatformFileForTransit foreign_socket_handle, |
46 | int32_t result); | ||||
47 | |||||
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 48 | void ConnectCompleteInHost(int32_t result, |
49 | const ppapi::HostResource& host_resource); | ||||
[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 50 | |
51 | CompletionCallbackFactory<PPB_Broker_Proxy, | ||||
52 | ProxyNonThreadSafeRefCount> callback_factory_; | ||||
53 | }; | ||||
54 | |||||
55 | } // namespace proxy | ||||
56 | } // namespace pp | ||||
57 | |||||
58 | #endif // PPAPI_PPB_BROKER_PROXY_H_ |