OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_testing.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_testing.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <new> | 8 #include <new> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 namespace { | 27 namespace { |
28 | 28 |
29 const nacl_abi_size_t kPPPointBytes = | 29 const nacl_abi_size_t kPPPointBytes = |
30 static_cast<nacl_abi_size_t>(sizeof(struct PP_Point)); | 30 static_cast<nacl_abi_size_t>(sizeof(struct PP_Point)); |
31 const nacl_abi_size_t kPPURLComponentsDevBytes = | 31 const nacl_abi_size_t kPPURLComponentsDevBytes = |
32 static_cast<nacl_abi_size_t>(sizeof(struct PP_URLComponents_Dev)); | 32 static_cast<nacl_abi_size_t>(sizeof(struct PP_URLComponents_Dev)); |
33 | 33 |
34 PP_Bool ReadImageData(PP_Resource device_context_2d, | 34 PP_Bool ReadImageData(PP_Resource device_context_2d, |
35 PP_Resource image, | 35 PP_Resource image, |
36 const struct PP_Point* top_left) { | 36 const struct PP_Point* top_left) { |
37 DebugPrintf("PPB_Testing::ReadImageData: device_context_2d=%"NACL_PRIu32"\n", | 37 DebugPrintf("PPB_Testing::ReadImageData: device_context_2d=%"NACL_PRId32"\n", |
38 device_context_2d); | 38 device_context_2d); |
39 | 39 |
40 int32_t success = 0; | 40 int32_t success = 0; |
41 NaClSrpcError srpc_result = | 41 NaClSrpcError srpc_result = |
42 PpbTestingRpcClient::PPB_Testing_ReadImageData( | 42 PpbTestingRpcClient::PPB_Testing_ReadImageData( |
43 GetMainSrpcChannel(), | 43 GetMainSrpcChannel(), |
44 device_context_2d, | 44 device_context_2d, |
45 image, | 45 image, |
46 kPPPointBytes, | 46 kPPPointBytes, |
47 reinterpret_cast<char*>(const_cast<PP_Point*>(top_left)), | 47 reinterpret_cast<char*>(const_cast<PP_Point*>(top_left)), |
48 &success); | 48 &success); |
49 | 49 |
50 DebugPrintf("PPB_Testing::ReadImageData: %s\n", | 50 DebugPrintf("PPB_Testing::ReadImageData: %s\n", |
51 NaClSrpcErrorString(srpc_result)); | 51 NaClSrpcErrorString(srpc_result)); |
52 if (srpc_result == NACL_SRPC_RESULT_OK && success) | 52 if (srpc_result == NACL_SRPC_RESULT_OK && success) |
53 return PP_TRUE; | 53 return PP_TRUE; |
54 return PP_FALSE; | 54 return PP_FALSE; |
55 } | 55 } |
56 | 56 |
57 void RunMessageLoop(PP_Instance instance) { | 57 void RunMessageLoop(PP_Instance instance) { |
58 DebugPrintf("PPB_Testing::RunMessageLoop: instance=%"NACL_PRIu32"\n", | 58 DebugPrintf("PPB_Testing::RunMessageLoop: instance=%"NACL_PRId32"\n", |
59 instance); | 59 instance); |
60 | 60 |
61 NaClSrpcError srpc_result = | 61 NaClSrpcError srpc_result = |
62 PpbTestingRpcClient::PPB_Testing_RunMessageLoop( | 62 PpbTestingRpcClient::PPB_Testing_RunMessageLoop( |
63 GetMainSrpcChannel(), | 63 GetMainSrpcChannel(), |
64 instance); | 64 instance); |
65 | 65 |
66 DebugPrintf("PPB_Testing::RunMessageLoop: %s\n", | 66 DebugPrintf("PPB_Testing::RunMessageLoop: %s\n", |
67 NaClSrpcErrorString(srpc_result)); | 67 NaClSrpcErrorString(srpc_result)); |
68 } | 68 } |
69 | 69 |
70 void QuitMessageLoop(PP_Instance instance) { | 70 void QuitMessageLoop(PP_Instance instance) { |
71 DebugPrintf("PPB_Testing::QuitMessageLoop: instance=%"NACL_PRIu32"\n", | 71 DebugPrintf("PPB_Testing::QuitMessageLoop: instance=%"NACL_PRId32"\n", |
72 instance); | 72 instance); |
73 | 73 |
74 NaClSrpcError srpc_result = | 74 NaClSrpcError srpc_result = |
75 PpbTestingRpcClient::PPB_Testing_QuitMessageLoop( | 75 PpbTestingRpcClient::PPB_Testing_QuitMessageLoop( |
76 GetMainSrpcChannel(), | 76 GetMainSrpcChannel(), |
77 instance); | 77 instance); |
78 | 78 |
79 DebugPrintf("PPB_Testing::QuitMessageLoop: %s\n", | 79 DebugPrintf("PPB_Testing::QuitMessageLoop: %s\n", |
80 NaClSrpcErrorString(srpc_result)); | 80 NaClSrpcErrorString(srpc_result)); |
81 } | 81 } |
82 | 82 |
83 uint32_t GetLiveObjectsForInstance(PP_Instance instance) { | 83 uint32_t GetLiveObjectsForInstance(PP_Instance instance) { |
84 DebugPrintf("PPB_Testing::GetLiveObjectsForInstance: " | 84 DebugPrintf("PPB_Testing::GetLiveObjectsForInstance: " |
85 "instance=%"NACL_PRIu32"\n", instance); | 85 "instance=%"NACL_PRId32"\n", instance); |
86 | 86 |
87 int32_t live_object_count = 0; | 87 int32_t live_object_count = 0; |
88 NaClSrpcError srpc_result = | 88 NaClSrpcError srpc_result = |
89 PpbTestingRpcClient::PPB_Testing_GetLiveObjectsForInstance( | 89 PpbTestingRpcClient::PPB_Testing_GetLiveObjectsForInstance( |
90 GetMainSrpcChannel(), | 90 GetMainSrpcChannel(), |
91 instance, | 91 instance, |
92 &live_object_count); | 92 &live_object_count); |
93 | 93 |
94 DebugPrintf("PPB_Testing::GetLiveObjectsForInstance: %s\n", | 94 DebugPrintf("PPB_Testing::GetLiveObjectsForInstance: %s\n", |
95 NaClSrpcErrorString(srpc_result)); | 95 NaClSrpcErrorString(srpc_result)); |
(...skipping 17 matching lines...) Expand all Loading... |
113 PpbTestingRpcClient::PPB_Testing_SimulateInputEvent(GetMainSrpcChannel(), | 113 PpbTestingRpcClient::PPB_Testing_SimulateInputEvent(GetMainSrpcChannel(), |
114 instance, | 114 instance, |
115 input_event); | 115 input_event); |
116 DebugPrintf("PPB_Testing::SimulateInputEvent: %s\n", | 116 DebugPrintf("PPB_Testing::SimulateInputEvent: %s\n", |
117 NaClSrpcErrorString(srpc_result)); | 117 NaClSrpcErrorString(srpc_result)); |
118 } | 118 } |
119 | 119 |
120 struct PP_Var GetDocumentURL(PP_Instance instance, | 120 struct PP_Var GetDocumentURL(PP_Instance instance, |
121 struct PP_URLComponents_Dev* components) { | 121 struct PP_URLComponents_Dev* components) { |
122 DebugPrintf("PPB_Testing::GetDocumentURL: " | 122 DebugPrintf("PPB_Testing::GetDocumentURL: " |
123 "instance=%"NACL_PRIu32"\n", instance); | 123 "instance=%"NACL_PRId32"\n", instance); |
124 | 124 |
125 NaClSrpcChannel* channel = GetMainSrpcChannel(); | 125 NaClSrpcChannel* channel = GetMainSrpcChannel(); |
126 nacl_abi_size_t components_size = | 126 nacl_abi_size_t components_size = |
127 (components != NULL) ? kPPURLComponentsDevBytes : 0; | 127 (components != NULL) ? kPPURLComponentsDevBytes : 0; |
128 nacl_abi_size_t url_size = kMaxReturnVarSize; | 128 nacl_abi_size_t url_size = kMaxReturnVarSize; |
129 nacl::scoped_array<char> url_bytes(new char[url_size]); | 129 nacl::scoped_array<char> url_bytes(new char[url_size]); |
130 if (url_bytes.get() == NULL) | 130 if (url_bytes.get() == NULL) |
131 return PP_MakeUndefined(); | 131 return PP_MakeUndefined(); |
132 | 132 |
133 NaClSrpcError srpc_result = | 133 NaClSrpcError srpc_result = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 GetLiveObjectsForInstance, | 169 GetLiveObjectsForInstance, |
170 IsOutOfProcess, | 170 IsOutOfProcess, |
171 SimulateInputEvent, | 171 SimulateInputEvent, |
172 GetDocumentURL, | 172 GetDocumentURL, |
173 GetLiveVars | 173 GetLiveVars |
174 }; | 174 }; |
175 return &testing_interface; | 175 return &testing_interface; |
176 } | 176 } |
177 | 177 |
178 } // namespace ppapi_proxy | 178 } // namespace ppapi_proxy |
OLD | NEW |