Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: ppapi/proxy/ppb_testing_proxy.cc

Issue 1114623002: Plugin Power Saver: Make PPS work well with prerendered pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comments Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ppapi/proxy/ppb_testing_proxy.h" 5 #include "ppapi/proxy/ppb_testing_proxy.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "ppapi/c/private/ppb_testing_private.h" 8 #include "ppapi/c/private/ppb_testing_private.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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 uint32_t result = 0; 73 uint32_t result = 0;
74 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( 74 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance(
75 API_ID_PPB_TESTING, instance_id, &result)); 75 API_ID_PPB_TESTING, instance_id, &result));
76 return result; 76 return result;
77 } 77 }
78 78
79 PP_Bool IsOutOfProcess() { 79 PP_Bool IsOutOfProcess() {
80 return PP_TRUE; 80 return PP_TRUE;
81 } 81 }
82 82
83 PP_Bool IsPeripheral(PP_Instance instance_id) { 83 PP_Var GetPowerSaverStatus(PP_Instance instance_id) {
84 ProxyAutoLock lock; 84 ProxyAutoLock lock;
85 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); 85 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
86 if (!dispatcher) 86 if (!dispatcher)
87 return PP_FALSE; 87 return PP_MakeUndefined();
88 88
89 PP_Bool result = PP_FALSE; 89 ReceiveSerializedVarReturnValue result;
90 dispatcher->Send(new PpapiHostMsg_PPBTesting_IsPeripheral( 90 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetPowerSaverStatus(
91 API_ID_PPB_TESTING, instance_id, &result)); 91 API_ID_PPB_TESTING, instance_id, &result));
92 return result; 92 return result.Return(dispatcher);
93 }
94
95 void SubscribeToPowerSaverNotifications(PP_Instance instance_id) {
96 ProxyAutoLock lock;
97 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
98 if (!dispatcher)
99 return;
100
101 dispatcher->Send(
102 new PpapiHostMsg_PPBTesting_SubscribeToPowerSaverNotifications(
103 API_ID_PPB_TESTING, instance_id));
93 } 104 }
94 105
95 void SimulateInputEvent(PP_Instance instance_id, PP_Resource input_event) { 106 void SimulateInputEvent(PP_Instance instance_id, PP_Resource input_event) {
96 ProxyAutoLock lock; 107 ProxyAutoLock lock;
97 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); 108 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
98 if (!dispatcher) 109 if (!dispatcher)
99 return; 110 return;
100 EnterResourceNoLock<PPB_InputEvent_API> enter(input_event, false); 111 EnterResourceNoLock<PPB_InputEvent_API> enter(input_event, false);
101 if (enter.failed()) 112 if (enter.failed())
102 return; 113 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // TODO(raymes): Implement this if we need it. 154 // TODO(raymes): Implement this if we need it.
144 NOTIMPLEMENTED(); 155 NOTIMPLEMENTED();
145 } 156 }
146 157
147 const PPB_Testing_Private testing_interface = { 158 const PPB_Testing_Private testing_interface = {
148 &ReadImageData, 159 &ReadImageData,
149 &RunMessageLoop, 160 &RunMessageLoop,
150 &QuitMessageLoop, 161 &QuitMessageLoop,
151 &GetLiveObjectsForInstance, 162 &GetLiveObjectsForInstance,
152 &IsOutOfProcess, 163 &IsOutOfProcess,
153 &IsPeripheral, 164 &GetPowerSaverStatus,
165 &SubscribeToPowerSaverNotifications,
154 &SimulateInputEvent, 166 &SimulateInputEvent,
155 &GetDocumentURL, 167 &GetDocumentURL,
156 &GetLiveVars, 168 &GetLiveVars,
157 &SetMinimumArrayBufferSizeForShmem, 169 &SetMinimumArrayBufferSizeForShmem,
158 &RunV8GC}; 170 &RunV8GC};
159 171
160 } // namespace 172 } // namespace
161 173
162 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) 174 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher)
163 : InterfaceProxy(dispatcher), 175 : InterfaceProxy(dispatcher),
(...skipping 15 matching lines...) Expand all
179 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { 191 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) {
180 if (!dispatcher()->permissions().HasPermission(PERMISSION_TESTING)) 192 if (!dispatcher()->permissions().HasPermission(PERMISSION_TESTING))
181 return false; 193 return false;
182 194
183 bool handled = true; 195 bool handled = true;
184 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg) 196 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg)
185 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData, 197 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData,
186 OnMsgReadImageData) 198 OnMsgReadImageData)
187 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, 199 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance,
188 OnMsgGetLiveObjectsForInstance) 200 OnMsgGetLiveObjectsForInstance)
189 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_IsPeripheral, OnMsgIsPeripheral) 201 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetPowerSaverStatus,
202 OnMsgGetPowerSaverStatus)
203 IPC_MESSAGE_HANDLER(
204 PpapiHostMsg_PPBTesting_SubscribeToPowerSaverNotifications,
205 OnMsgSubscribeToPowerSaverNotifications)
190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent, 206 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent,
191 OnMsgSimulateInputEvent) 207 OnMsgSimulateInputEvent)
192 IPC_MESSAGE_HANDLER( 208 IPC_MESSAGE_HANDLER(
193 PpapiHostMsg_PPBTesting_SetMinimumArrayBufferSizeForShmem, 209 PpapiHostMsg_PPBTesting_SetMinimumArrayBufferSizeForShmem,
194 OnMsgSetMinimumArrayBufferSizeForShmem) 210 OnMsgSetMinimumArrayBufferSizeForShmem)
195 IPC_MESSAGE_UNHANDLED(handled = false) 211 IPC_MESSAGE_UNHANDLED(handled = false)
196 IPC_END_MESSAGE_MAP() 212 IPC_END_MESSAGE_MAP()
197 return handled; 213 return handled;
198 } 214 }
199 215
(...skipping 12 matching lines...) Expand all
212 228
213 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { 229 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) {
214 ppb_testing_impl_->QuitMessageLoop(instance); 230 ppb_testing_impl_->QuitMessageLoop(instance);
215 } 231 }
216 232
217 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, 233 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance,
218 uint32_t* result) { 234 uint32_t* result) {
219 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); 235 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance);
220 } 236 }
221 237
222 void PPB_Testing_Proxy::OnMsgIsPeripheral(PP_Instance instance, 238 void PPB_Testing_Proxy::OnMsgGetPowerSaverStatus(
223 PP_Bool* result) { 239 PP_Instance instance,
224 *result = ppb_testing_impl_->IsPeripheral(instance); 240 SerializedVarReturnValue result) {
241 result.Return(dispatcher(), ppb_testing_impl_->GetPowerSaverStatus(instance));
242 }
243
244 void PPB_Testing_Proxy::OnMsgSubscribeToPowerSaverNotifications(
245 PP_Instance instance) {
246 ppb_testing_impl_->SubscribeToPowerSaverNotifications(instance);
225 } 247 }
226 248
227 void PPB_Testing_Proxy::OnMsgSimulateInputEvent( 249 void PPB_Testing_Proxy::OnMsgSimulateInputEvent(
228 PP_Instance instance, 250 PP_Instance instance,
229 const InputEventData& input_event) { 251 const InputEventData& input_event) {
230 scoped_refptr<PPB_InputEvent_Shared> input_event_impl( 252 scoped_refptr<PPB_InputEvent_Shared> input_event_impl(
231 new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event)); 253 new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event));
232 ppb_testing_impl_->SimulateInputEvent(instance, 254 ppb_testing_impl_->SimulateInputEvent(instance,
233 input_event_impl->pp_resource()); 255 input_event_impl->pp_resource());
234 } 256 }
235 257
236 void PPB_Testing_Proxy::OnMsgSetMinimumArrayBufferSizeForShmem( 258 void PPB_Testing_Proxy::OnMsgSetMinimumArrayBufferSizeForShmem(
237 uint32_t threshold) { 259 uint32_t threshold) {
238 RawVarDataGraph::SetMinimumArrayBufferSizeForShmemForTest(threshold); 260 RawVarDataGraph::SetMinimumArrayBufferSizeForShmemForTest(threshold);
239 } 261 }
240 262
241 } // namespace proxy 263 } // namespace proxy
242 } // namespace ppapi 264 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698