| 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_listener.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_sender.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/shared_impl/api_id.h" | 14 #include "ppapi/shared_impl/api_id.h" |
| 15 | 15 |
| 16 namespace ppapi { | 16 namespace ppapi { |
| 17 namespace proxy { | 17 namespace proxy { |
| 18 | 18 |
| 19 class Dispatcher; | 19 class Dispatcher; |
| 20 | 20 |
| 21 class InterfaceProxy : public IPC::Channel::Listener, | 21 class InterfaceProxy : public IPC::Listener, public IPC::Sender { |
| 22 public IPC::Message::Sender { | |
| 23 public: | 22 public: |
| 24 // Factory function type for interfaces. Ownership of the returned pointer | 23 // Factory function type for interfaces. Ownership of the returned pointer |
| 25 // is transferred to the caller. | 24 // is transferred to the caller. |
| 26 typedef InterfaceProxy* (*Factory)(Dispatcher* dispatcher); | 25 typedef InterfaceProxy* (*Factory)(Dispatcher* dispatcher); |
| 27 | 26 |
| 28 // DEPRECATED: New classes should be registered directly in the interface | 27 // DEPRECATED: New classes should be registered directly in the interface |
| 29 // list. This is kept around until we convert all the existing code. | 28 // list. This is kept around until we convert all the existing code. |
| 30 // | 29 // |
| 31 // Information about the interface. Each interface has a static function to | 30 // Information about the interface. Each interface has a static function to |
| 32 // return its info, which allows either construction on the target side, and | 31 // return its info, which allows either construction on the target side, and |
| 33 // getting the proxied interface on the source side (see dispatcher.h for | 32 // getting the proxied interface on the source side (see dispatcher.h for |
| 34 // terminology). | 33 // terminology). |
| 35 struct Info { | 34 struct Info { |
| 36 const void* interface_ptr; | 35 const void* interface_ptr; |
| 37 | 36 |
| 38 const char* name; | 37 const char* name; |
| 39 ApiID id; | 38 ApiID id; |
| 40 | 39 |
| 41 bool is_trusted; | 40 bool is_trusted; |
| 42 | 41 |
| 43 InterfaceProxy::Factory create_proxy; | 42 InterfaceProxy::Factory create_proxy; |
| 44 }; | 43 }; |
| 45 | 44 |
| 46 virtual ~InterfaceProxy(); | 45 virtual ~InterfaceProxy(); |
| 47 | 46 |
| 48 Dispatcher* dispatcher() const { return dispatcher_; } | 47 Dispatcher* dispatcher() const { return dispatcher_; } |
| 49 | 48 |
| 50 // IPC::Message::Sender implementation. | 49 // IPC::Sender implementation. |
| 51 virtual bool Send(IPC::Message* msg); | 50 virtual bool Send(IPC::Message* msg); |
| 52 | 51 |
| 53 // Sub-classes must implement IPC::Channel::Listener which contains this: | 52 // Sub-classes must implement IPC::Listener which contains this: |
| 54 //virtual bool OnMessageReceived(const IPC::Message& msg); | 53 //virtual bool OnMessageReceived(const IPC::Message& msg); |
| 55 | 54 |
| 56 protected: | 55 protected: |
| 57 // Creates the given interface associated with the given dispatcher. The | 56 // Creates the given interface associated with the given dispatcher. The |
| 58 // dispatcher manages our lifetime. | 57 // dispatcher manages our lifetime. |
| 59 InterfaceProxy(Dispatcher* dispatcher); | 58 InterfaceProxy(Dispatcher* dispatcher); |
| 60 | 59 |
| 61 private: | 60 private: |
| 62 Dispatcher* dispatcher_; | 61 Dispatcher* dispatcher_; |
| 63 }; | 62 }; |
| 64 | 63 |
| 65 } // namespace proxy | 64 } // namespace proxy |
| 66 } // namespace ppapi | 65 } // namespace ppapi |
| 67 | 66 |
| 68 #endif // PPAPI_PROXY_INTERFACE_PROXY_H_ | 67 #endif // PPAPI_PROXY_INTERFACE_PROXY_H_ |
| 69 | 68 |
| OLD | NEW |