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 "ppapi/proxy/ppb_testing_proxy.h" | 5 #include "ppapi/proxy/ppb_testing_proxy.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "ppapi/c/dev/ppb_testing_dev.h" | 8 #include "ppapi/c/dev/ppb_testing_dev.h" |
9 #include "ppapi/proxy/enter_proxy.h" | 9 #include "ppapi/proxy/enter_proxy.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 API_ID_PPB_TESTING, instance_id, input_event_data)); | 88 API_ID_PPB_TESTING, instance_id, input_event_data)); |
89 } | 89 } |
90 | 90 |
91 PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) { | 91 PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) { |
92 EnterInstance enter(instance); | 92 EnterInstance enter(instance); |
93 if (enter.failed()) | 93 if (enter.failed()) |
94 return PP_MakeUndefined(); | 94 return PP_MakeUndefined(); |
95 return enter.functions()->GetDocumentURL(instance, components); | 95 return enter.functions()->GetDocumentURL(instance, components); |
96 } | 96 } |
97 | 97 |
| 98 // TODO(dmichael): Ideally we could get a way to check the number of vars in the |
| 99 // host-side tracker when running out-of-process, to make sure the proxy does |
| 100 // not leak host-side vars. |
| 101 uint32_t GetLiveVars(PP_Var live_vars[], uint32_t array_size) { |
| 102 std::vector<PP_Var> vars = |
| 103 PpapiGlobals::Get()->GetVarTracker()->GetLiveVars(); |
| 104 for (size_t i = 0u; |
| 105 i < std::min(static_cast<size_t>(array_size), vars.size()); |
| 106 ++i) |
| 107 live_vars[i] = vars[i]; |
| 108 return vars.size(); |
| 109 } |
| 110 |
98 const PPB_Testing_Dev testing_interface = { | 111 const PPB_Testing_Dev testing_interface = { |
99 &ReadImageData, | 112 &ReadImageData, |
100 &RunMessageLoop, | 113 &RunMessageLoop, |
101 &QuitMessageLoop, | 114 &QuitMessageLoop, |
102 &GetLiveObjectsForInstance, | 115 &GetLiveObjectsForInstance, |
103 &IsOutOfProcess, | 116 &IsOutOfProcess, |
104 &SimulateInputEvent, | 117 &SimulateInputEvent, |
105 &GetDocumentURL | 118 &GetDocumentURL, |
| 119 &GetLiveVars |
106 }; | 120 }; |
107 | 121 |
108 InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) { | 122 InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) { |
109 return new PPB_Testing_Proxy(dispatcher); | 123 return new PPB_Testing_Proxy(dispatcher); |
110 } | 124 } |
111 | 125 |
112 } // namespace | 126 } // namespace |
113 | 127 |
114 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) | 128 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) |
115 : InterfaceProxy(dispatcher), | 129 : InterfaceProxy(dispatcher), |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 scoped_refptr<PPB_InputEvent_Shared> input_event_impl( | 191 scoped_refptr<PPB_InputEvent_Shared> input_event_impl( |
178 new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(), | 192 new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(), |
179 instance, | 193 instance, |
180 input_event)); | 194 input_event)); |
181 ppb_testing_impl_->SimulateInputEvent(instance, | 195 ppb_testing_impl_->SimulateInputEvent(instance, |
182 input_event_impl->pp_resource()); | 196 input_event_impl->pp_resource()); |
183 } | 197 } |
184 | 198 |
185 } // namespace proxy | 199 } // namespace proxy |
186 } // namespace ppapi | 200 } // namespace ppapi |
OLD | NEW |