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_PPP_INSTANCE_PROXY_H_ | 5 #ifndef PPAPI_PROXY_PPP_INSTANCE_PROXY_H_ |
6 #define PPAPI_PROXY_PPP_INSTANCE_PROXY_H_ | 6 #define PPAPI_PROXY_PPP_INSTANCE_PROXY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" |
11 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
12 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
13 #include "ppapi/c/pp_var.h" | 14 #include "ppapi/c/pp_var.h" |
14 #include "ppapi/proxy/host_resource.h" | 15 #include "ppapi/proxy/host_resource.h" |
15 #include "ppapi/proxy/interface_proxy.h" | 16 #include "ppapi/proxy/interface_proxy.h" |
| 17 #include "ppapi/shared_impl/ppp_instance_combined.h" |
16 | 18 |
17 struct PP_InputEvent; | 19 struct PP_InputEvent; |
18 struct PP_Rect; | 20 struct PP_Rect; |
19 struct PPP_Instance; | |
20 | 21 |
21 namespace pp { | 22 namespace pp { |
22 namespace proxy { | 23 namespace proxy { |
23 | 24 |
24 class SerializedVarReturnValue; | 25 class SerializedVarReturnValue; |
25 | 26 |
26 class PPP_Instance_Proxy : public InterfaceProxy { | 27 class PPP_Instance_Proxy : public InterfaceProxy { |
27 public: | 28 public: |
28 PPP_Instance_Proxy(Dispatcher* dispatcher, const void* target_interface); | 29 template <class PPP_Instance_Type> |
| 30 PPP_Instance_Proxy(Dispatcher* dispatcher, |
| 31 const PPP_Instance_Type* target_interface) |
| 32 : InterfaceProxy(dispatcher, static_cast<const void*>(target_interface)), |
| 33 combined_interface_( |
| 34 new ::ppapi::PPP_Instance_Combined(*target_interface)) { |
| 35 } |
29 virtual ~PPP_Instance_Proxy(); | 36 virtual ~PPP_Instance_Proxy(); |
30 | 37 |
31 static const Info* GetInfo(); | 38 // Return the info for the 0.4 version of the interface. |
| 39 static const Info* GetInfo0_4(); |
32 | 40 |
33 const PPP_Instance* ppp_instance_target() const { | 41 // Return the info for the 0.5 (latest, canonical) version of the interface. |
34 return reinterpret_cast<const PPP_Instance*>(target_interface()); | 42 static const Info* GetInfo0_5(); |
| 43 |
| 44 ::ppapi::PPP_Instance_Combined* ppp_instance_target() const { |
| 45 return combined_interface_.get(); |
35 } | 46 } |
36 | 47 |
37 // InterfaceProxy implementation. | 48 // InterfaceProxy implementation. |
38 virtual bool OnMessageReceived(const IPC::Message& msg); | 49 virtual bool OnMessageReceived(const IPC::Message& msg); |
39 | 50 |
40 private: | 51 private: |
41 // Message handlers. | 52 // Message handlers. |
42 void OnMsgDidCreate(PP_Instance instance, | 53 void OnMsgDidCreate(PP_Instance instance, |
43 const std::vector<std::string>& argn, | 54 const std::vector<std::string>& argn, |
44 const std::vector<std::string>& argv, | 55 const std::vector<std::string>& argv, |
45 PP_Bool* result); | 56 PP_Bool* result); |
46 void OnMsgDidDestroy(PP_Instance instance); | 57 void OnMsgDidDestroy(PP_Instance instance); |
47 void OnMsgDidChangeView(PP_Instance instance, | 58 void OnMsgDidChangeView(PP_Instance instance, |
48 const PP_Rect& position, | 59 const PP_Rect& position, |
49 const PP_Rect& clip, | 60 const PP_Rect& clip, |
50 PP_Bool fullscreen); | 61 PP_Bool fullscreen); |
51 void OnMsgDidChangeFocus(PP_Instance instance, PP_Bool has_focus); | 62 void OnMsgDidChangeFocus(PP_Instance instance, PP_Bool has_focus); |
52 void OnMsgHandleInputEvent(PP_Instance instance, | 63 void OnMsgHandleInputEvent(PP_Instance instance, |
53 const PP_InputEvent& event, | 64 const PP_InputEvent& event, |
54 PP_Bool* result); | 65 PP_Bool* result); |
55 void OnMsgHandleDocumentLoad(PP_Instance instance, | 66 void OnMsgHandleDocumentLoad(PP_Instance instance, |
56 const HostResource& url_loader, | 67 const HostResource& url_loader, |
57 PP_Bool* result); | 68 PP_Bool* result); |
58 void OnMsgGetInstanceObject(PP_Instance instance, | 69 void OnMsgGetInstanceObject(PP_Instance instance, |
59 SerializedVarReturnValue result); | 70 SerializedVarReturnValue result); |
| 71 scoped_ptr< ::ppapi::PPP_Instance_Combined> combined_interface_; |
60 }; | 72 }; |
61 | 73 |
62 } // namespace proxy | 74 } // namespace proxy |
63 } // namespace pp | 75 } // namespace pp |
64 | 76 |
65 #endif // PPAPI_PROXY_PPP_INSTANCE_PROXY_H_ | 77 #endif // PPAPI_PROXY_PPP_INSTANCE_PROXY_H_ |
OLD | NEW |