[email protected] | 84396dbc | 2011-04-14 06:33:42 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 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" | ||||
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 9 | #include "ipc/ipc_listener.h" |
10 | #include "ipc/ipc_sender.h" | ||||
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 11 | #include "ppapi/c/pp_completion_callback.h" |
12 | #include "ppapi/c/pp_resource.h" | ||||
13 | #include "ppapi/c/pp_var.h" | ||||
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 14 | #include "ppapi/shared_impl/api_id.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 15 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 16 | namespace ppapi { |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 17 | namespace proxy { |
18 | |||||
19 | class Dispatcher; | ||||
20 | |||||
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 21 | class InterfaceProxy : public IPC::Listener, public IPC::Sender { |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 22 | public: |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 23 | // Factory function type for interfaces. Ownership of the returned pointer |
24 | // is transferred to the caller. | ||||
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 25 | typedef InterfaceProxy* (*Factory)(Dispatcher* dispatcher); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 26 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 27 | virtual ~InterfaceProxy(); |
28 | |||||
[email protected] | f56279c | 2011-02-02 18:12:31 | [diff] [blame] | 29 | Dispatcher* dispatcher() const { return dispatcher_; } |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 30 | |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 31 | // IPC::Sender implementation. |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 32 | virtual bool Send(IPC::Message* msg); |
33 | |||||
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 34 | // Sub-classes must implement IPC::Listener which contains this: |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 35 | //virtual bool OnMessageReceived(const IPC::Message& msg); |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 36 | |
37 | protected: | ||||
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 38 | // Creates the given interface associated with the given dispatcher. The |
39 | // dispatcher manages our lifetime. | ||||
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 40 | InterfaceProxy(Dispatcher* dispatcher); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 41 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 42 | private: |
43 | Dispatcher* dispatcher_; | ||||
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 44 | }; |
45 | |||||
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 46 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 47 | } // namespace ppapi |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 48 | |
49 | #endif // PPAPI_PROXY_INTERFACE_PROXY_H_ | ||||
50 |