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

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

Issue 6334016: Refactor PPAPI proxy resource handling to maintain which host they came from,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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_url_response_info_proxy.h ('k') | ppapi/proxy/ppp_instance_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) 2010 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_url_response_info_proxy.h" 5 #include "ppapi/proxy/ppb_url_response_info_proxy.h"
6 6
7 #include "ppapi/c/ppb_url_response_info.h" 7 #include "ppapi/c/ppb_url_response_info.h"
8 #include "ppapi/proxy/plugin_dispatcher.h" 8 #include "ppapi/proxy/plugin_dispatcher.h"
9 #include "ppapi/proxy/plugin_resource.h" 9 #include "ppapi/proxy/plugin_resource.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/proxy/serialized_var.h" 11 #include "ppapi/proxy/serialized_var.h"
12 12
13 namespace pp { 13 namespace pp {
14 namespace proxy { 14 namespace proxy {
15 15
16 class URLResponseInfo : public PluginResource { 16 class URLResponseInfo : public PluginResource {
17 public: 17 public:
18 URLResponseInfo(PP_Instance instance) : PluginResource(instance) {} 18 URLResponseInfo(const HostResource& resource)
19 : PluginResource(resource) {
20 }
19 virtual ~URLResponseInfo() {} 21 virtual ~URLResponseInfo() {}
20 22
21 // Resource overrides. 23 // Resource overrides.
22 virtual URLResponseInfo* AsURLResponseInfo() { return this; } 24 virtual URLResponseInfo* AsURLResponseInfo() { return this; }
23 25
24 private: 26 private:
25 DISALLOW_COPY_AND_ASSIGN(URLResponseInfo); 27 DISALLOW_COPY_AND_ASSIGN(URLResponseInfo);
26 }; 28 };
27 29
28 namespace { 30 namespace {
29 31
30 PP_Bool IsURLResponseInfo(PP_Resource resource) { 32 PP_Bool IsURLResponseInfo(PP_Resource resource) {
31 URLResponseInfo* object = PluginResource::GetAs<URLResponseInfo>(resource); 33 URLResponseInfo* object = PluginResource::GetAs<URLResponseInfo>(resource);
32 return BoolToPPBool(!!object); 34 return BoolToPPBool(!!object);
33 } 35 }
34 36
35 PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { 37 PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) {
36 URLResponseInfo* object = PluginResource::GetAs<URLResponseInfo>(response); 38 URLResponseInfo* object = PluginResource::GetAs<URLResponseInfo>(response);
37 if (!object) 39 if (!object)
38 return PP_MakeUndefined(); 40 return PP_MakeUndefined();
39 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( 41 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(
40 object->instance()); 42 object->instance());
41 if (!dispatcher) 43 if (!dispatcher)
42 return PP_MakeUndefined(); 44 return PP_MakeUndefined();
43 45
44 ReceiveSerializedVarReturnValue result; 46 ReceiveSerializedVarReturnValue result;
45 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetProperty( 47 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetProperty(
46 INTERFACE_ID_PPB_URL_RESPONSE_INFO, response, property, &result)); 48 INTERFACE_ID_PPB_URL_RESPONSE_INFO, object->host_resource(), property,
49 &result));
47 return result.Return(dispatcher); 50 return result.Return(dispatcher);
48 } 51 }
49 52
50 PP_Resource GetBodyAsFileRef(PP_Resource response) { 53 PP_Resource GetBodyAsFileRef(PP_Resource response) {
51 PP_Resource result = 0;
52 /* 54 /*
53 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef( 55 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef(
54 INTERFACE_ID_PPB_URL_RESPONSE_INFO, response, &result)); 56 INTERFACE_ID_PPB_URL_RESPONSE_INFO, response, &result));
55 // TODO(brettw) when we have FileRef proxied, make an object from that 57 // TODO(brettw) when we have FileRef proxied, make an object from that
56 // ref so we can track it properly and then uncomment this. 58 // ref so we can track it properly and then uncomment this.
57 */ 59 */
58 return result; 60 return 0;
59 } 61 }
60 62
61 const PPB_URLResponseInfo ppb_urlresponseinfo = { 63 const PPB_URLResponseInfo ppb_urlresponseinfo = {
62 &IsURLResponseInfo, 64 &IsURLResponseInfo,
63 &GetProperty, 65 &GetProperty,
64 &GetBodyAsFileRef 66 &GetBodyAsFileRef
65 }; 67 };
66 68
67 } // namespace 69 } // namespace
68 70
69 PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy( 71 PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy(
70 Dispatcher* dispatcher, 72 Dispatcher* dispatcher,
71 const void* target_interface) 73 const void* target_interface)
72 : InterfaceProxy(dispatcher, target_interface) { 74 : InterfaceProxy(dispatcher, target_interface) {
73 } 75 }
74 76
75 PPB_URLResponseInfo_Proxy::~PPB_URLResponseInfo_Proxy() { 77 PPB_URLResponseInfo_Proxy::~PPB_URLResponseInfo_Proxy() {
76 } 78 }
77 79
78 // static 80 // static
79 void PPB_URLResponseInfo_Proxy::TrackPluginResource( 81 PP_Resource PPB_URLResponseInfo_Proxy::CreateResponseForResource(
80 PP_Instance instance, 82 const HostResource& resource) {
81 PP_Resource response_resource) { 83 linked_ptr<URLResponseInfo> object(new URLResponseInfo(resource));
82 linked_ptr<URLResponseInfo> object(new URLResponseInfo(instance)); 84 return PluginResourceTracker::GetInstance()->AddResource(object);
83 PluginResourceTracker::GetInstance()->AddResource(
84 response_resource, object);
85 } 85 }
86 86
87 const void* PPB_URLResponseInfo_Proxy::GetSourceInterface() const { 87 const void* PPB_URLResponseInfo_Proxy::GetSourceInterface() const {
88 return &ppb_urlresponseinfo; 88 return &ppb_urlresponseinfo;
89 } 89 }
90 90
91 InterfaceID PPB_URLResponseInfo_Proxy::GetInterfaceId() const { 91 InterfaceID PPB_URLResponseInfo_Proxy::GetInterfaceId() const {
92 return INTERFACE_ID_PPB_URL_RESPONSE_INFO; 92 return INTERFACE_ID_PPB_URL_RESPONSE_INFO;
93 } 93 }
94 94
95 bool PPB_URLResponseInfo_Proxy::OnMessageReceived(const IPC::Message& msg) { 95 bool PPB_URLResponseInfo_Proxy::OnMessageReceived(const IPC::Message& msg) {
96 bool handled = true; 96 bool handled = true;
97 IPC_BEGIN_MESSAGE_MAP(PPB_URLResponseInfo_Proxy, msg) 97 IPC_BEGIN_MESSAGE_MAP(PPB_URLResponseInfo_Proxy, msg)
98 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetProperty, 98 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetProperty,
99 OnMsgGetProperty) 99 OnMsgGetProperty)
100 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef, 100 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef,
101 OnMsgGetBodyAsFileRef) 101 OnMsgGetBodyAsFileRef)
102 IPC_MESSAGE_UNHANDLED(handled = false) 102 IPC_MESSAGE_UNHANDLED(handled = false)
103 IPC_END_MESSAGE_MAP() 103 IPC_END_MESSAGE_MAP()
104 // TODO(brettw): handle bad messages. 104 // TODO(brettw): handle bad messages.
105 return handled; 105 return handled;
106 } 106 }
107 107
108 void PPB_URLResponseInfo_Proxy::OnMsgGetProperty( 108 void PPB_URLResponseInfo_Proxy::OnMsgGetProperty(
109 PP_Resource response, 109 HostResource response,
110 int32_t property, 110 int32_t property,
111 SerializedVarReturnValue result) { 111 SerializedVarReturnValue result) {
112 result.Return(dispatcher(), ppb_url_response_info_target()->GetProperty( 112 result.Return(dispatcher(), ppb_url_response_info_target()->GetProperty(
113 response, static_cast<PP_URLResponseProperty>(property))); 113 response.host_resource(), static_cast<PP_URLResponseProperty>(property)));
114 } 114 }
115 115
116 void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef( 116 void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef(
117 PP_Resource response, 117 HostResource response,
118 PP_Resource* file_ref_result) { 118 HostResource* file_ref_result) {
119 *file_ref_result = ppb_url_response_info_target()->GetBodyAsFileRef(response); 119 file_ref_result->SetHostResource(
120 response.instance(),
121 ppb_url_response_info_target()->GetBodyAsFileRef(
122 response.host_resource()));
120 } 123 }
121 124
122 } // namespace proxy 125 } // namespace proxy
123 } // namespace pp 126 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_url_response_info_proxy.h ('k') | ppapi/proxy/ppp_instance_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698