OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_url_loader_proxy.h" | 5 #include "ppapi/proxy/ppb_url_loader_proxy.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 void Close(PP_Resource loader_id) { | 239 void Close(PP_Resource loader_id) { |
240 URLLoader* loader_object; | 240 URLLoader* loader_object; |
241 PluginDispatcher* dispatcher; | 241 PluginDispatcher* dispatcher; |
242 if (!RoutingDataFromURLLoader(loader_id, &loader_object, &dispatcher)) | 242 if (!RoutingDataFromURLLoader(loader_id, &loader_object, &dispatcher)) |
243 return; | 243 return; |
244 | 244 |
245 dispatcher->Send(new PpapiHostMsg_PPBURLLoader_Close( | 245 dispatcher->Send(new PpapiHostMsg_PPBURLLoader_Close( |
246 INTERFACE_ID_PPB_URL_LOADER, loader_object->host_resource())); | 246 INTERFACE_ID_PPB_URL_LOADER, loader_object->host_resource())); |
247 } | 247 } |
248 | 248 |
249 const PPB_URLLoader ppb_urlloader = { | 249 const PPB_URLLoader urlloader_interface = { |
250 &Create, | 250 &Create, |
251 &IsURLLoader, | 251 &IsURLLoader, |
252 &Open, | 252 &Open, |
253 &FollowRedirect, | 253 &FollowRedirect, |
254 &GetUploadProgress, | 254 &GetUploadProgress, |
255 &GetDownloadProgress, | 255 &GetDownloadProgress, |
256 &GetResponseInfo, | 256 &GetResponseInfo, |
257 &ReadResponseBody, | 257 &ReadResponseBody, |
258 &FinishStreamingToFile, | 258 &FinishStreamingToFile, |
259 &Close | 259 &Close |
260 }; | 260 }; |
261 | 261 |
| 262 InterfaceProxy* CreateURLLoaderProxy(Dispatcher* dispatcher, |
| 263 const void* target_interface) { |
| 264 return new PPB_URLLoader_Proxy(dispatcher, target_interface); |
| 265 } |
| 266 |
262 // Plugin URLLoaderTrusted implementation -------------------------------------- | 267 // Plugin URLLoaderTrusted implementation -------------------------------------- |
263 | 268 |
264 void GrantUniversalAccess(PP_Resource loader_id) { | 269 void GrantUniversalAccess(PP_Resource loader_id) { |
265 URLLoader* loader_object; | 270 URLLoader* loader_object; |
266 PluginDispatcher* dispatcher; | 271 PluginDispatcher* dispatcher; |
267 if (!RoutingDataFromURLLoader(loader_id, &loader_object, &dispatcher)) | 272 if (!RoutingDataFromURLLoader(loader_id, &loader_object, &dispatcher)) |
268 return; | 273 return; |
269 | 274 |
270 dispatcher->Send( | 275 dispatcher->Send( |
271 new PpapiHostMsg_PPBURLLoaderTrusted_GrantUniversalAccess( | 276 new PpapiHostMsg_PPBURLLoaderTrusted_GrantUniversalAccess( |
272 INTERFACE_ID_PPB_URL_LOADER_TRUSTED, loader_object->host_resource())); | 277 INTERFACE_ID_PPB_URL_LOADER_TRUSTED, loader_object->host_resource())); |
273 } | 278 } |
274 | 279 |
275 const PPB_URLLoaderTrusted ppb_urlloader_trusted = { | 280 const PPB_URLLoaderTrusted urlloader_trusted_interface = { |
276 &GrantUniversalAccess, | 281 &GrantUniversalAccess, |
277 NULL, // RegisterStatusCallback is used internally by the proxy only. | 282 NULL, // RegisterStatusCallback is used internally by the proxy only. |
278 }; | 283 }; |
279 | 284 |
| 285 InterfaceProxy* CreateURLLoaderTrustedProxy(Dispatcher* dispatcher, |
| 286 const void* target_interface) { |
| 287 return new PPB_URLLoaderTrusted_Proxy(dispatcher, target_interface); |
| 288 } |
| 289 |
280 } // namespace | 290 } // namespace |
281 | 291 |
282 // PPB_URLLoader_Proxy --------------------------------------------------------- | 292 // PPB_URLLoader_Proxy --------------------------------------------------------- |
283 | 293 |
284 struct PPB_URLLoader_Proxy::ReadCallbackInfo { | 294 struct PPB_URLLoader_Proxy::ReadCallbackInfo { |
285 HostResource resource; | 295 HostResource resource; |
286 std::string read_buffer; | 296 std::string read_buffer; |
287 }; | 297 }; |
288 | 298 |
289 PPB_URLLoader_Proxy::PPB_URLLoader_Proxy(Dispatcher* dispatcher, | 299 PPB_URLLoader_Proxy::PPB_URLLoader_Proxy(Dispatcher* dispatcher, |
290 const void* target_interface) | 300 const void* target_interface) |
291 : InterfaceProxy(dispatcher, target_interface), | 301 : InterfaceProxy(dispatcher, target_interface), |
292 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 302 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
293 } | 303 } |
294 | 304 |
295 PPB_URLLoader_Proxy::~PPB_URLLoader_Proxy() { | 305 PPB_URLLoader_Proxy::~PPB_URLLoader_Proxy() { |
296 } | 306 } |
297 | 307 |
298 // static | 308 // static |
299 PP_Resource PPB_URLLoader_Proxy::TrackPluginResource( | 309 PP_Resource PPB_URLLoader_Proxy::TrackPluginResource( |
300 const HostResource& url_loader_resource) { | 310 const HostResource& url_loader_resource) { |
301 linked_ptr<URLLoader> object(new URLLoader(url_loader_resource)); | 311 linked_ptr<URLLoader> object(new URLLoader(url_loader_resource)); |
302 return PluginResourceTracker::GetInstance()->AddResource(object); | 312 return PluginResourceTracker::GetInstance()->AddResource(object); |
303 } | 313 } |
304 | 314 |
305 const void* PPB_URLLoader_Proxy::GetSourceInterface() const { | 315 // static |
306 return &ppb_urlloader; | 316 const InterfaceProxy::Info* PPB_URLLoader_Proxy::GetInfo() { |
307 } | 317 static const Info info = { |
308 | 318 &urlloader_interface, |
309 InterfaceID PPB_URLLoader_Proxy::GetInterfaceId() const { | 319 PPB_URLLOADER_INTERFACE, |
310 return INTERFACE_ID_PPB_URL_LOADER; | 320 INTERFACE_ID_PPB_URL_LOADER, |
| 321 false, |
| 322 &CreateURLLoaderProxy, |
| 323 }; |
| 324 return &info; |
311 } | 325 } |
312 | 326 |
313 bool PPB_URLLoader_Proxy::OnMessageReceived(const IPC::Message& msg) { | 327 bool PPB_URLLoader_Proxy::OnMessageReceived(const IPC::Message& msg) { |
314 bool handled = true; | 328 bool handled = true; |
315 IPC_BEGIN_MESSAGE_MAP(PPB_URLLoader_Proxy, msg) | 329 IPC_BEGIN_MESSAGE_MAP(PPB_URLLoader_Proxy, msg) |
316 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLLoader_Create, | 330 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLLoader_Create, |
317 OnMsgCreate) | 331 OnMsgCreate) |
318 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLLoader_Open, | 332 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLLoader_Open, |
319 OnMsgOpen) | 333 OnMsgOpen) |
320 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLLoader_FollowRedirect, | 334 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLLoader_FollowRedirect, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 497 |
484 PPB_URLLoaderTrusted_Proxy::PPB_URLLoaderTrusted_Proxy( | 498 PPB_URLLoaderTrusted_Proxy::PPB_URLLoaderTrusted_Proxy( |
485 Dispatcher* dispatcher, | 499 Dispatcher* dispatcher, |
486 const void* target_interface) | 500 const void* target_interface) |
487 : InterfaceProxy(dispatcher, target_interface) { | 501 : InterfaceProxy(dispatcher, target_interface) { |
488 } | 502 } |
489 | 503 |
490 PPB_URLLoaderTrusted_Proxy::~PPB_URLLoaderTrusted_Proxy() { | 504 PPB_URLLoaderTrusted_Proxy::~PPB_URLLoaderTrusted_Proxy() { |
491 } | 505 } |
492 | 506 |
493 const void* PPB_URLLoaderTrusted_Proxy::GetSourceInterface() const { | 507 // static |
494 return &ppb_urlloader_trusted; | 508 const InterfaceProxy::Info* PPB_URLLoaderTrusted_Proxy::GetInfo() { |
495 } | 509 static const Info info = { |
496 | 510 &urlloader_trusted_interface, |
497 InterfaceID PPB_URLLoaderTrusted_Proxy::GetInterfaceId() const { | 511 PPB_URLLOADERTRUSTED_INTERFACE, |
498 return INTERFACE_ID_PPB_URL_LOADER_TRUSTED; | 512 INTERFACE_ID_PPB_URL_LOADER_TRUSTED, |
| 513 true, |
| 514 &CreateURLLoaderTrustedProxy, |
| 515 }; |
| 516 return &info; |
499 } | 517 } |
500 | 518 |
501 bool PPB_URLLoaderTrusted_Proxy::OnMessageReceived(const IPC::Message& msg) { | 519 bool PPB_URLLoaderTrusted_Proxy::OnMessageReceived(const IPC::Message& msg) { |
502 bool handled = true; | 520 bool handled = true; |
503 IPC_BEGIN_MESSAGE_MAP(PPB_URLLoaderTrusted_Proxy, msg) | 521 IPC_BEGIN_MESSAGE_MAP(PPB_URLLoaderTrusted_Proxy, msg) |
504 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLLoaderTrusted_GrantUniversalAccess, | 522 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLLoaderTrusted_GrantUniversalAccess, |
505 OnMsgGrantUniversalAccess) | 523 OnMsgGrantUniversalAccess) |
506 IPC_MESSAGE_UNHANDLED(handled = false) | 524 IPC_MESSAGE_UNHANDLED(handled = false) |
507 IPC_END_MESSAGE_MAP(); | 525 IPC_END_MESSAGE_MAP(); |
508 // TODO(brettw) handle bad messages! | 526 // TODO(brettw) handle bad messages! |
509 return handled; | 527 return handled; |
510 } | 528 } |
511 | 529 |
512 void PPB_URLLoaderTrusted_Proxy::OnMsgGrantUniversalAccess( | 530 void PPB_URLLoaderTrusted_Proxy::OnMsgGrantUniversalAccess( |
513 const HostResource& loader) { | 531 const HostResource& loader) { |
514 ppb_url_loader_trusted_target()->GrantUniversalAccess(loader.host_resource()); | 532 ppb_url_loader_trusted_target()->GrantUniversalAccess(loader.host_resource()); |
515 } | 533 } |
516 | 534 |
517 } // namespace proxy | 535 } // namespace proxy |
518 } // namespace pp | 536 } // namespace pp |
OLD | NEW |