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 #ifndef PPAPI_PROXY_INTERFACE_PROXY_H_ | 5 #ifndef PPAPI_PROXY_INTERFACE_PROXY_H_ |
6 #define PPAPI_PROXY_INTERFACE_PROXY_H_ | 6 #define PPAPI_PROXY_INTERFACE_PROXY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "ipc/ipc_channel.h" | 9 #include "ipc/ipc_channel.h" |
10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
11 #include "ppapi/c/pp_completion_callback.h" | 11 #include "ppapi/c/pp_completion_callback.h" |
12 #include "ppapi/c/pp_resource.h" | 12 #include "ppapi/c/pp_resource.h" |
13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
14 #include "ppapi/proxy/interface_id.h" | 14 #include "ppapi/proxy/interface_id.h" |
| 15 #include "ppapi/shared_impl/function_group_base.h" |
15 | 16 |
16 namespace ppapi { | 17 namespace ppapi { |
17 namespace proxy { | 18 namespace proxy { |
18 | 19 |
19 class Dispatcher; | 20 class Dispatcher; |
20 | 21 |
21 class InterfaceProxy : public IPC::Channel::Listener, | 22 class InterfaceProxy : public IPC::Channel::Listener, |
22 public IPC::Message::Sender { | 23 public IPC::Message::Sender, |
| 24 public FunctionGroupBase { |
23 public: | 25 public: |
24 // Factory function type for interfaces. Ownership of the returned pointer | 26 // Factory function type for interfaces. Ownership of the returned pointer |
25 // is transferred to the caller. | 27 // is transferred to the caller. |
26 typedef InterfaceProxy* (*Factory)(Dispatcher* dispatcher, | 28 typedef InterfaceProxy* (*Factory)(Dispatcher* dispatcher); |
27 const void* target_interface); | |
28 | 29 |
| 30 // DEPRECATED: New classes should be registered directly in the interface |
| 31 // list. This is kept around until we convert all the existing code. |
| 32 // |
29 // Information about the interface. Each interface has a static function to | 33 // Information about the interface. Each interface has a static function to |
30 // return its info, which allows either construction on the target side, and | 34 // return its info, which allows either construction on the target side, and |
31 // getting the proxied interface on the source side (see dispatcher.h for | 35 // getting the proxied interface on the source side (see dispatcher.h for |
32 // terminology). | 36 // terminology). |
33 struct Info { | 37 struct Info { |
34 const void* interface_ptr; | 38 const void* interface_ptr; |
35 | 39 |
36 const char* name; | 40 const char* name; |
37 InterfaceID id; | 41 InterfaceID id; |
38 | 42 |
39 bool is_trusted; | 43 bool is_trusted; |
40 | 44 |
41 InterfaceProxy::Factory create_proxy; | 45 InterfaceProxy::Factory create_proxy; |
42 }; | 46 }; |
43 | 47 |
44 virtual ~InterfaceProxy(); | 48 virtual ~InterfaceProxy(); |
45 | 49 |
46 // The actual implementation of the given interface in the current process. | |
47 const void* target_interface() const { return target_interface_; } | |
48 | |
49 Dispatcher* dispatcher() const { return dispatcher_; } | 50 Dispatcher* dispatcher() const { return dispatcher_; } |
50 | 51 |
51 // IPC::Message::Sender implementation. | 52 // IPC::Message::Sender implementation. |
52 virtual bool Send(IPC::Message* msg); | 53 virtual bool Send(IPC::Message* msg); |
53 | 54 |
54 // Sub-classes must implement IPC::Channel::Listener which contains this: | 55 // Sub-classes must implement IPC::Channel::Listener which contains this: |
55 //virtual bool OnMessageReceived(const IPC::Message& msg); | 56 //virtual bool OnMessageReceived(const IPC::Message& msg); |
56 | 57 |
57 protected: | 58 protected: |
58 // Creates the given interface associated with the given dispatcher. The | 59 // Creates the given interface associated with the given dispatcher. The |
59 // dispatcher manages our lifetime. | 60 // dispatcher manages our lifetime. |
60 // | 61 InterfaceProxy(Dispatcher* dispatcher); |
61 // The target interface pointer, when non-NULL, indicates that this is a | |
62 // target proxy (see dispatcher.h for a definition). In this case, the proxy | |
63 // will interpret this pointer to the actual implementation of the interface | |
64 // in the local process. | |
65 InterfaceProxy(Dispatcher* dispatcher, const void* target_interface); | |
66 | 62 |
67 uint32 SendCallback(PP_CompletionCallback callback); | 63 uint32 SendCallback(PP_CompletionCallback callback); |
68 PP_CompletionCallback ReceiveCallback(uint32 serialized_callback); | 64 PP_CompletionCallback ReceiveCallback(uint32 serialized_callback); |
69 | 65 |
70 private: | 66 private: |
71 Dispatcher* dispatcher_; | 67 Dispatcher* dispatcher_; |
72 const void* target_interface_; | |
73 }; | 68 }; |
74 | 69 |
75 } // namespace proxy | 70 } // namespace proxy |
76 } // namespace ppapi | 71 } // namespace ppapi |
77 | 72 |
78 #endif // PPAPI_PROXY_INTERFACE_PROXY_H_ | 73 #endif // PPAPI_PROXY_INTERFACE_PROXY_H_ |
79 | 74 |
OLD | NEW |