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 #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 | 10 |
10 #include "native_client/src/include/nacl_scoped_ptr.h" | 11 #include "native_client/src/include/nacl_scoped_ptr.h" |
11 #include "native_client/src/include/portability.h" | 12 #include "native_client/src/include/portability.h" |
12 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 13 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
13 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 14 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
14 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" | 15 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" |
| 16 #include "native_client/src/shared/ppapi_proxy/proxy_var_cache.h" |
15 #include "native_client/src/shared/ppapi_proxy/utility.h" | 17 #include "native_client/src/shared/ppapi_proxy/utility.h" |
16 #include "ppapi/c/dev/ppb_testing_dev.h" | 18 #include "ppapi/c/dev/ppb_testing_dev.h" |
17 #include "ppapi/c/pp_completion_callback.h" | 19 #include "ppapi/c/pp_completion_callback.h" |
18 #include "ppapi/c/pp_errors.h" | 20 #include "ppapi/c/pp_errors.h" |
19 #include "ppapi/c/pp_point.h" | 21 #include "ppapi/c/pp_point.h" |
20 #include "ppapi/c/pp_rect.h" | 22 #include "ppapi/c/pp_rect.h" |
21 #include "srpcgen/ppb_rpc.h" | 23 #include "srpcgen/ppb_rpc.h" |
22 | 24 |
23 namespace ppapi_proxy { | 25 namespace ppapi_proxy { |
24 | 26 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 struct PP_Var url = PP_MakeUndefined(); | 140 struct PP_Var url = PP_MakeUndefined(); |
139 if (srpc_result == NACL_SRPC_RESULT_OK) | 141 if (srpc_result == NACL_SRPC_RESULT_OK) |
140 (void) DeserializeTo(url_bytes.get(), url_size, 1, &url); | 142 (void) DeserializeTo(url_bytes.get(), url_size, 1, &url); |
141 | 143 |
142 DebugPrintf("PPB_Testing::GetDocumentURL: %s\n", | 144 DebugPrintf("PPB_Testing::GetDocumentURL: %s\n", |
143 NaClSrpcErrorString(srpc_result)); | 145 NaClSrpcErrorString(srpc_result)); |
144 | 146 |
145 return url; | 147 return url; |
146 } | 148 } |
147 | 149 |
| 150 // TODO(dmichael): Ideally we could get a way to check the number of vars in the |
| 151 // host-side tracker when running NaCl, to make sure the proxy does not leak |
| 152 // host-side vars. |
| 153 uint32_t GetLiveVars(PP_Var live_vars[], uint32_t array_size) { |
| 154 std::vector<PP_Var> vars = ProxyVarCache::GetInstance().GetLiveVars(); |
| 155 for (size_t i = 0u; |
| 156 i < std::min(static_cast<size_t>(array_size), vars.size()); |
| 157 ++i) |
| 158 live_vars[i] = vars[i]; |
| 159 return vars.size(); |
| 160 } |
| 161 |
148 } // namespace | 162 } // namespace |
149 | 163 |
150 const PPB_Testing_Dev* PluginTesting::GetInterface() { | 164 const PPB_Testing_Dev* PluginTesting::GetInterface() { |
151 static const PPB_Testing_Dev testing_interface = { | 165 static const PPB_Testing_Dev testing_interface = { |
152 ReadImageData, | 166 ReadImageData, |
153 RunMessageLoop, | 167 RunMessageLoop, |
154 QuitMessageLoop, | 168 QuitMessageLoop, |
155 GetLiveObjectsForInstance, | 169 GetLiveObjectsForInstance, |
156 IsOutOfProcess, | 170 IsOutOfProcess, |
157 SimulateInputEvent, | 171 SimulateInputEvent, |
158 GetDocumentURL | 172 GetDocumentURL, |
| 173 GetLiveVars |
159 }; | 174 }; |
160 return &testing_interface; | 175 return &testing_interface; |
161 } | 176 } |
162 | 177 |
163 } // namespace ppapi_proxy | 178 } // namespace ppapi_proxy |
OLD | NEW |