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

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

Issue 7874002: This patch tries to remove most of the manual registration for Pepper interfaces, and replaces it... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/ppb_flash_tcp_socket_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_flash_proxy.h" 5 #include "ppapi/proxy/ppb_flash_proxy.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "ppapi/c/dev/ppb_font_dev.h" 10 #include "ppapi/c/dev/ppb_font_dev.h"
11 #include "ppapi/c/dev/ppb_var_deprecated.h" 11 #include "ppapi/c/dev/ppb_var_deprecated.h"
12 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/c/pp_resource.h" 13 #include "ppapi/c/pp_resource.h"
14 #include "ppapi/c/private/ppb_flash.h" 14 #include "ppapi/c/private/ppb_flash.h"
15 #include "ppapi/proxy/host_dispatcher.h" 15 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/plugin_dispatcher.h" 16 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/plugin_resource_tracker.h" 17 #include "ppapi/proxy/plugin_resource_tracker.h"
18 #include "ppapi/proxy/ppapi_messages.h" 18 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/proxy/proxy_module.h" 19 #include "ppapi/proxy/proxy_module.h"
20 #include "ppapi/proxy/serialized_var.h" 20 #include "ppapi/proxy/serialized_var.h"
21 #include "ppapi/shared_impl/resource.h" 21 #include "ppapi/shared_impl/resource.h"
22 #include "ppapi/shared_impl/scoped_pp_resource.h" 22 #include "ppapi/shared_impl/scoped_pp_resource.h"
23 #include "ppapi/shared_impl/var.h"
23 #include "ppapi/thunk/enter.h" 24 #include "ppapi/thunk/enter.h"
24 #include "ppapi/thunk/ppb_url_request_info_api.h" 25 #include "ppapi/thunk/ppb_url_request_info_api.h"
25 #include "ppapi/thunk/resource_creation_api.h" 26 #include "ppapi/thunk/resource_creation_api.h"
26 27
27 namespace ppapi { 28 namespace ppapi {
28 namespace proxy { 29 namespace proxy {
29 30
30 namespace { 31 namespace {
31 32
32 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { 33 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // 146 //
146 // On Linux, it would be better to go directly to the browser process for 147 // On Linux, it would be better to go directly to the browser process for
147 // this message rather than proxy it through some instance in a renderer. 148 // this message rather than proxy it through some instance in a renderer.
148 double result = 0; 149 double result = 0;
149 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( 150 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset(
150 INTERFACE_ID_PPB_FLASH, instance, t, &result)); 151 INTERFACE_ID_PPB_FLASH, instance, t, &result));
151 return result; 152 return result;
152 } 153 }
153 154
154 PP_Var GetCommandLineArgs(PP_Module pp_module) { 155 PP_Var GetCommandLineArgs(PP_Module pp_module) {
155 const PPB_Var_Deprecated* var_deprecated =
156 static_cast<const PPB_Var_Deprecated*>(
157 PluginDispatcher::GetInterfaceFromDispatcher(
158 PPB_VAR_DEPRECATED_INTERFACE));
159 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); 156 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs();
160 return var_deprecated->VarFromUtf8(pp_module, args.data(), args.length()); 157 return StringVar::StringToPPVar(pp_module, args);
161 } 158 }
162 159
163 const PPB_Flash flash_interface = { 160 const PPB_Flash flash_interface = {
164 &SetInstanceAlwaysOnTop, 161 &SetInstanceAlwaysOnTop,
165 &DrawGlyphs, 162 &DrawGlyphs,
166 &GetProxyForURL, 163 &GetProxyForURL,
167 &Navigate, 164 &Navigate,
168 &RunMessageLoop, 165 &RunMessageLoop,
169 &QuitMessageLoop, 166 &QuitMessageLoop,
170 &GetLocalTimeZoneOffset, 167 &GetLocalTimeZoneOffset,
171 &GetCommandLineArgs 168 &GetCommandLineArgs
172 }; 169 };
173 170
174 InterfaceProxy* CreateFlashProxy(Dispatcher* dispatcher, 171 InterfaceProxy* CreateFlashProxy(Dispatcher* dispatcher) {
175 const void* target_interface) { 172 return new PPB_Flash_Proxy(dispatcher);
176 return new PPB_Flash_Proxy(dispatcher, target_interface);
177 } 173 }
178 174
179 } // namespace 175 } // namespace
180 176
181 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher, 177 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher)
182 const void* target_interface) 178 : InterfaceProxy(dispatcher),
183 : InterfaceProxy(dispatcher, target_interface) { 179 ppb_flash_impl_(NULL) {
180 if (!dispatcher->IsPlugin())
181 ppb_flash_impl_ = static_cast<const PPB_Flash*>(
182 dispatcher->local_get_interface()(PPB_FLASH_INTERFACE));
184 } 183 }
185 184
186 PPB_Flash_Proxy::~PPB_Flash_Proxy() { 185 PPB_Flash_Proxy::~PPB_Flash_Proxy() {
187 } 186 }
188 187
189 // static 188 // static
190 const InterfaceProxy::Info* PPB_Flash_Proxy::GetInfo() { 189 const InterfaceProxy::Info* PPB_Flash_Proxy::GetInfo() {
191 static const Info info = { 190 static const Info info = {
192 &flash_interface, 191 &flash_interface,
193 PPB_FLASH_INTERFACE, 192 PPB_FLASH_INTERFACE,
(...skipping 27 matching lines...) Expand all
221 OnMsgGetLocalTimeZoneOffset) 220 OnMsgGetLocalTimeZoneOffset)
222 IPC_MESSAGE_UNHANDLED(handled = false) 221 IPC_MESSAGE_UNHANDLED(handled = false)
223 IPC_END_MESSAGE_MAP() 222 IPC_END_MESSAGE_MAP()
224 // TODO(brettw) handle bad messages! 223 // TODO(brettw) handle bad messages!
225 return handled; 224 return handled;
226 } 225 }
227 226
228 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop( 227 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop(
229 PP_Instance instance, 228 PP_Instance instance,
230 PP_Bool on_top) { 229 PP_Bool on_top) {
231 ppb_flash_target()->SetInstanceAlwaysOnTop(instance, on_top); 230 ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top);
232 } 231 }
233 232
234 void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params, 233 void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params,
235 PP_Bool* result) { 234 PP_Bool* result) {
236 *result = PP_FALSE; 235 *result = PP_FALSE;
237 236
238 PP_FontDescription_Dev font_desc; 237 PP_FontDescription_Dev font_desc;
239 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); 238 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false);
240 239
241 if (params.glyph_indices.size() != params.glyph_advances.size() || 240 if (params.glyph_indices.size() != params.glyph_advances.size() ||
242 params.glyph_indices.empty()) 241 params.glyph_indices.empty())
243 return; 242 return;
244 243
245 *result = ppb_flash_target()->DrawGlyphs( 244 *result = ppb_flash_impl_->DrawGlyphs(
246 0, // Unused instance param. 245 0, // Unused instance param.
247 params.image_data.host_resource(), &font_desc, 246 params.image_data.host_resource(), &font_desc,
248 params.color, params.position, params.clip, 247 params.color, params.position, params.clip,
249 const_cast<float(*)[3]>(params.transformation), 248 const_cast<float(*)[3]>(params.transformation),
250 static_cast<uint32_t>(params.glyph_indices.size()), 249 static_cast<uint32_t>(params.glyph_indices.size()),
251 const_cast<uint16_t*>(&params.glyph_indices[0]), 250 const_cast<uint16_t*>(&params.glyph_indices[0]),
252 const_cast<PP_Point*>(&params.glyph_advances[0])); 251 const_cast<PP_Point*>(&params.glyph_advances[0]));
253 } 252 }
254 253
255 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance, 254 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance,
256 const std::string& url, 255 const std::string& url,
257 SerializedVarReturnValue result) { 256 SerializedVarReturnValue result) {
258 result.Return(dispatcher(), ppb_flash_target()->GetProxyForURL( 257 result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL(
259 instance, url.c_str())); 258 instance, url.c_str()));
260 } 259 }
261 260
262 void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance, 261 void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance,
263 const PPB_URLRequestInfo_Data& data, 262 const PPB_URLRequestInfo_Data& data,
264 const std::string& target, 263 const std::string& target,
265 bool from_user_action, 264 bool from_user_action,
266 int32_t* result) { 265 int32_t* result) {
267 DCHECK(!dispatcher()->IsPlugin()); 266 DCHECK(!dispatcher()->IsPlugin());
268 267
(...skipping 16 matching lines...) Expand all
285 // Make a temporary request resource. 284 // Make a temporary request resource.
286 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true); 285 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true);
287 if (enter.failed()) { 286 if (enter.failed()) {
288 *result = PP_ERROR_FAILED; 287 *result = PP_ERROR_FAILED;
289 return; 288 return;
290 } 289 }
291 ScopedPPResource request_resource( 290 ScopedPPResource request_resource(
292 ScopedPPResource::PassRef(), 291 ScopedPPResource::PassRef(),
293 enter.functions()->CreateURLRequestInfo(instance, data)); 292 enter.functions()->CreateURLRequestInfo(instance, data));
294 293
295 *result = ppb_flash_target()->Navigate(request_resource, 294 *result = ppb_flash_impl_->Navigate(request_resource,
296 target.c_str(), 295 target.c_str(),
297 from_user_action); 296 from_user_action);
298 } 297 }
299 298
300 void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { 299 void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) {
301 ppb_flash_target()->RunMessageLoop(instance); 300 ppb_flash_impl_->RunMessageLoop(instance);
302 } 301 }
303 302
304 void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { 303 void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) {
305 ppb_flash_target()->QuitMessageLoop(instance); 304 ppb_flash_impl_->QuitMessageLoop(instance);
306 } 305 }
307 306
308 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, 307 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance,
309 PP_Time t, 308 PP_Time t,
310 double* result) { 309 double* result) {
311 *result = ppb_flash_target()->GetLocalTimeZoneOffset(instance, t); 310 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t);
312 } 311 }
313 312
314 } // namespace proxy 313 } // namespace proxy
315 } // namespace ppapi 314 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/ppb_flash_tcp_socket_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698