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_response_info_proxy.h" | 5 #include "ppapi/proxy/ppb_url_response_info_proxy.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_url_response_info_dev.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() {} | 18 URLResponseInfo() {} |
19 virtual ~URLResponseInfo() {} | 19 virtual ~URLResponseInfo() {} |
20 | 20 |
21 // Resource overrides. | 21 // Resource overrides. |
22 virtual URLResponseInfo* AsURLResponseInfo() { return this; } | 22 virtual URLResponseInfo* AsURLResponseInfo() { return this; } |
23 | 23 |
24 private: | 24 private: |
25 DISALLOW_COPY_AND_ASSIGN(URLResponseInfo); | 25 DISALLOW_COPY_AND_ASSIGN(URLResponseInfo); |
26 }; | 26 }; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 PP_Bool IsURLResponseInfo(PP_Resource resource) { | 30 PP_Bool IsURLResponseInfo(PP_Resource resource) { |
31 URLResponseInfo* object = PluginResource::GetAs<URLResponseInfo>(resource); | 31 URLResponseInfo* object = PluginResource::GetAs<URLResponseInfo>(resource); |
32 return BoolToPPBool(!!object); | 32 return BoolToPPBool(!!object); |
33 } | 33 } |
34 | 34 |
35 PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty_Dev property) { | 35 PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { |
36 Dispatcher* dispatcher = PluginDispatcher::Get(); | 36 Dispatcher* dispatcher = PluginDispatcher::Get(); |
37 ReceiveSerializedVarReturnValue result; | 37 ReceiveSerializedVarReturnValue result; |
38 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetProperty( | 38 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetProperty( |
39 INTERFACE_ID_PPB_URL_RESPONSE_INFO, response, property, &result)); | 39 INTERFACE_ID_PPB_URL_RESPONSE_INFO, response, property, &result)); |
40 return result.Return(dispatcher); | 40 return result.Return(dispatcher); |
41 } | 41 } |
42 | 42 |
43 PP_Resource GetBody(PP_Resource response) { | 43 PP_Resource GetBodyAsFileRef(PP_Resource response) { |
44 PP_Resource result = 0; | 44 PP_Resource result = 0; |
45 /* | 45 /* |
46 Dispatcher* dispatcher = PluginDispatcher::Get(); | 46 Dispatcher* dispatcher = PluginDispatcher::Get(); |
47 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetBody( | 47 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef( |
48 INTERFACE_ID_PPB_URL_RESPONSE_INFO, response, &result)); | 48 INTERFACE_ID_PPB_URL_RESPONSE_INFO, response, &result)); |
49 // TODO(brettw) when we have FileRef proxied, make an object from that | 49 // TODO(brettw) when we have FileRef proxied, make an object from that |
50 // ref so we can track it properly and then uncomment this. | 50 // ref so we can track it properly and then uncomment this. |
51 */ | 51 */ |
52 return result; | 52 return result; |
53 } | 53 } |
54 | 54 |
55 const PPB_URLResponseInfo_Dev ppb_urlresponseinfo = { | 55 const PPB_URLResponseInfo ppb_urlresponseinfo = { |
56 &IsURLResponseInfo, | 56 &IsURLResponseInfo, |
57 &GetProperty, | 57 &GetProperty, |
58 &GetBody | 58 &GetBodyAsFileRef |
59 }; | 59 }; |
60 | 60 |
61 } // namespace | 61 } // namespace |
62 | 62 |
63 PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy( | 63 PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy( |
64 Dispatcher* dispatcher, | 64 Dispatcher* dispatcher, |
65 const void* target_interface) | 65 const void* target_interface) |
66 : InterfaceProxy(dispatcher, target_interface) { | 66 : InterfaceProxy(dispatcher, target_interface) { |
67 } | 67 } |
68 | 68 |
(...skipping 13 matching lines...) Expand all Loading... |
82 } | 82 } |
83 | 83 |
84 InterfaceID PPB_URLResponseInfo_Proxy::GetInterfaceId() const { | 84 InterfaceID PPB_URLResponseInfo_Proxy::GetInterfaceId() const { |
85 return INTERFACE_ID_PPB_URL_RESPONSE_INFO; | 85 return INTERFACE_ID_PPB_URL_RESPONSE_INFO; |
86 } | 86 } |
87 | 87 |
88 void PPB_URLResponseInfo_Proxy::OnMessageReceived(const IPC::Message& msg) { | 88 void PPB_URLResponseInfo_Proxy::OnMessageReceived(const IPC::Message& msg) { |
89 IPC_BEGIN_MESSAGE_MAP(PPB_URLResponseInfo_Proxy, msg) | 89 IPC_BEGIN_MESSAGE_MAP(PPB_URLResponseInfo_Proxy, msg) |
90 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetProperty, | 90 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetProperty, |
91 OnMsgGetProperty) | 91 OnMsgGetProperty) |
92 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetBody, | 92 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef, |
93 OnMsgGetBody) | 93 OnMsgGetBodyAsFileRef) |
94 IPC_END_MESSAGE_MAP() | 94 IPC_END_MESSAGE_MAP() |
95 // TODO(brettw): handle bad messages. | 95 // TODO(brettw): handle bad messages. |
96 } | 96 } |
97 | 97 |
98 void PPB_URLResponseInfo_Proxy::OnMsgGetProperty( | 98 void PPB_URLResponseInfo_Proxy::OnMsgGetProperty( |
99 PP_Resource response, | 99 PP_Resource response, |
100 int32_t property, | 100 int32_t property, |
101 SerializedVarReturnValue result) { | 101 SerializedVarReturnValue result) { |
102 result.Return(dispatcher(), ppb_url_response_info_target()->GetProperty( | 102 result.Return(dispatcher(), ppb_url_response_info_target()->GetProperty( |
103 response, static_cast<PP_URLResponseProperty_Dev>(property))); | 103 response, static_cast<PP_URLResponseProperty>(property))); |
104 } | 104 } |
105 | 105 |
106 void PPB_URLResponseInfo_Proxy::OnMsgGetBody(PP_Resource response, | 106 void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef( |
107 PP_Resource* file_ref_result) { | 107 PP_Resource response, |
108 *file_ref_result = ppb_url_response_info_target()->GetBody(response); | 108 PP_Resource* file_ref_result) { |
| 109 *file_ref_result = ppb_url_response_info_target()->GetBodyAsFileRef(response); |
109 } | 110 } |
110 | 111 |
111 } // namespace proxy | 112 } // namespace proxy |
112 } // namespace pp | 113 } // namespace pp |
OLD | NEW |