OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_PROXY_INTERFACE_PROXY_H_ |
| 6 #define PPAPI_PROXY_INTERFACE_PROXY_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "ipc/ipc_channel.h" |
| 10 #include "ipc/ipc_message.h" |
| 11 #include "ppapi/c/pp_completion_callback.h" |
| 12 #include "ppapi/c/pp_resource.h" |
| 13 #include "ppapi/c/pp_var.h" |
| 14 #include "ppapi/proxy/interface_id.h" |
| 15 |
| 16 namespace pp { |
| 17 namespace proxy { |
| 18 |
| 19 class Dispatcher; |
| 20 |
| 21 class InterfaceProxy : public IPC::Channel::Listener, |
| 22 public IPC::Message::Sender { |
| 23 public: |
| 24 // Creates the given interface associated with the given dispatcher. The |
| 25 // dispatcher manages our lifetime. |
| 26 // |
| 27 // The target interface pointer, when non-NULL, indicates that this is a |
| 28 // target proxy (see dispatcher.h for a definition). In this case, the proxy |
| 29 // will interpret this pointer to the actual implementation of the interface |
| 30 // in the local process. |
| 31 // |
| 32 // If the target interface is NULL, this proxy will be a "source" interface. |
| 33 InterfaceProxy(Dispatcher* dispatcher, const void* target_interface); |
| 34 virtual ~InterfaceProxy(); |
| 35 |
| 36 // See dispatcher.h for definitions of source and target. |
| 37 bool is_source_proxy() const { return !target_interface_; } |
| 38 bool is_target_proxy() const { return !!target_interface_; } |
| 39 |
| 40 // When this proxy is the "target" of the IPC communication (see |
| 41 // dispatcher.h), this target_interface pointer will indicate the local |
| 42 // side's interface pointer. This contains the functions that actually |
| 43 // implement the proxied interface. |
| 44 // |
| 45 // This will be NULL when this proxy is a source proxy. |
| 46 const void* target_interface() const { return target_interface_; } |
| 47 |
| 48 Dispatcher* dispatcher() { return dispatcher_; } |
| 49 |
| 50 // IPC::Message::Sender implementation. |
| 51 virtual bool Send(IPC::Message* msg); |
| 52 |
| 53 // Returns the local implementation of the interface that will proxy it to |
| 54 // the remote side. This is used on the source side only (see dispatcher.h). |
| 55 virtual const void* GetSourceInterface() const = 0; |
| 56 |
| 57 // Returns the interface ID associated with this proxy. Implemented by each |
| 58 // derived class to identify itself. |
| 59 virtual InterfaceID GetInterfaceId() const = 0; |
| 60 |
| 61 // Sub-classes must implement IPC::Channel::Listener: |
| 62 //virtual void OnMessageReceived(const IPC::Message& msg); |
| 63 |
| 64 protected: |
| 65 uint32 SendCallback(PP_CompletionCallback callback); |
| 66 PP_CompletionCallback ReceiveCallback(uint32 serialized_callback); |
| 67 |
| 68 private: |
| 69 Dispatcher* dispatcher_; |
| 70 const void* target_interface_; |
| 71 }; |
| 72 |
| 73 } // namespace proxy |
| 74 } // namespace pp |
| 75 |
| 76 #endif // PPAPI_PROXY_INTERFACE_PROXY_H_ |
| 77 |
OLD | NEW |