OLD | NEW |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2011 The Native Client 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 #include "native_client/src/shared/ppapi_proxy/browser_ppp_instance.h" | 5 #include "native_client/src/shared/ppapi_proxy/browser_ppp_instance.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
11 // Include file order cannot be observed because ppp_instance declares a | |
12 // structure return type that causes an error on Windows. | |
13 // TODO(sehr, brettw): fix the return types and include order in PPAPI. | |
14 #include "native_client/src/third_party/ppapi/c/pp_input_event.h" | |
15 #include "native_client/src/third_party/ppapi/c/pp_resource.h" | |
16 #include "native_client/src/third_party/ppapi/c/pp_var.h" | |
17 #include "native_client/src/third_party/ppapi/c/ppp_instance.h" | |
18 #include "srpcgen/ppp_rpc.h" | |
19 #include "native_client/src/include/checked_cast.h" | 11 #include "native_client/src/include/checked_cast.h" |
20 #include "native_client/src/include/nacl_scoped_ptr.h" | 12 #include "native_client/src/include/nacl_scoped_ptr.h" |
21 #include "native_client/src/include/portability.h" | 13 #include "native_client/src/include/portability.h" |
22 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 14 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
23 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" | 15 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" |
| 16 #include "native_client/src/shared/ppapi_proxy/browser_ppp_input_event.h" |
| 17 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h" |
24 #include "native_client/src/shared/ppapi_proxy/utility.h" | 18 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 19 #include "native_client/src/third_party/ppapi/c/pp_input_event.h" |
| 20 #include "native_client/src/third_party/ppapi/c/pp_resource.h" |
| 21 #include "native_client/src/third_party/ppapi/c/pp_var.h" |
| 22 #include "native_client/src/third_party/ppapi/c/ppp_instance.h" |
25 | 23 |
26 using nacl::scoped_array; | 24 using nacl::scoped_array; |
27 | 25 |
28 namespace ppapi_proxy { | 26 namespace ppapi_proxy { |
29 | 27 |
30 namespace { | 28 namespace { |
31 | 29 |
32 char* ArgArraySerialize(int argc, | 30 char* ArgArraySerialize(int argc, |
33 const char* array[], | 31 const char* array[], |
34 uint32_t* serial_size) { | 32 uint32_t* serial_size) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 DebugPrintf("PPP_Instance::DidCreate: %s\n", | 89 DebugPrintf("PPP_Instance::DidCreate: %s\n", |
92 NaClSrpcErrorString(srpc_result)); | 90 NaClSrpcErrorString(srpc_result)); |
93 if (srpc_result != NACL_SRPC_RESULT_OK) { | 91 if (srpc_result != NACL_SRPC_RESULT_OK) { |
94 return PP_FALSE; | 92 return PP_FALSE; |
95 } | 93 } |
96 return static_cast<PP_Bool>(success != 0); | 94 return static_cast<PP_Bool>(success != 0); |
97 } | 95 } |
98 | 96 |
99 void DidDestroy(PP_Instance instance) { | 97 void DidDestroy(PP_Instance instance) { |
100 DebugPrintf("PPP_Instance::DidDestroy: instance=%"NACL_PRIu32"\n", instance); | 98 DebugPrintf("PPP_Instance::DidDestroy: instance=%"NACL_PRIu32"\n", instance); |
| 99 // Inform BrowserInputEvent that the instance was destroyed. |
| 100 // TODO(NaCl team): It would probably make sense to use observer pattern for |
| 101 // instance creation/deletion events if we have much of this kind of stuff. |
| 102 BrowserInputEvent::InstanceDestroyed(instance); |
101 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidDestroy( | 103 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidDestroy( |
102 GetMainSrpcChannel(instance), instance); | 104 GetMainSrpcChannel(instance), instance); |
103 DebugPrintf("PPP_Instance::DidDestroy: %s\n", | 105 DebugPrintf("PPP_Instance::DidDestroy: %s\n", |
104 NaClSrpcErrorString(srpc_result)); | 106 NaClSrpcErrorString(srpc_result)); |
105 } | 107 } |
106 | 108 |
107 void DidChangeView(PP_Instance instance, | 109 void DidChangeView(PP_Instance instance, |
108 const PP_Rect* position, | 110 const PP_Rect* position, |
109 const PP_Rect* clip) { | 111 const PP_Rect* clip) { |
110 DebugPrintf("PPP_Instance::DidChangeView: instance=%"NACL_PRIu32"\n", | 112 DebugPrintf("PPP_Instance::DidChangeView: instance=%"NACL_PRIu32"\n", |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 DidDestroy, | 192 DidDestroy, |
191 DidChangeView, | 193 DidChangeView, |
192 DidChangeFocus, | 194 DidChangeFocus, |
193 HandleInputEvent, | 195 HandleInputEvent, |
194 HandleDocumentLoad | 196 HandleDocumentLoad |
195 }; | 197 }; |
196 return &instance_interface; | 198 return &instance_interface; |
197 } | 199 } |
198 | 200 |
199 } // namespace ppapi_proxy | 201 } // namespace ppapi_proxy |
OLD | NEW |