| OLD | NEW |
| 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_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/enter_proxy.h" | 8 #include "ppapi/proxy/enter_proxy.h" |
| 9 #include "ppapi/proxy/host_dispatcher.h" | 9 #include "ppapi/proxy/host_dispatcher.h" |
| 10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 PPB_URLResponseInfo_API* URLResponseInfo::AsPPB_URLResponseInfo_API() { | 48 PPB_URLResponseInfo_API* URLResponseInfo::AsPPB_URLResponseInfo_API() { |
| 49 return this; | 49 return this; |
| 50 } | 50 } |
| 51 | 51 |
| 52 PP_Var URLResponseInfo::GetProperty(PP_URLResponseProperty property) { | 52 PP_Var URLResponseInfo::GetProperty(PP_URLResponseProperty property) { |
| 53 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); | 53 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); |
| 54 ReceiveSerializedVarReturnValue result; | 54 ReceiveSerializedVarReturnValue result; |
| 55 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetProperty( | 55 dispatcher->Send(new PpapiHostMsg_PPBURLResponseInfo_GetProperty( |
| 56 INTERFACE_ID_PPB_URL_RESPONSE_INFO, host_resource(), property, &result)); | 56 API_ID_PPB_URL_RESPONSE_INFO, host_resource(), property, &result)); |
| 57 return result.Return(dispatcher); | 57 return result.Return(dispatcher); |
| 58 } | 58 } |
| 59 | 59 |
| 60 PP_Resource URLResponseInfo::GetBodyAsFileRef() { | 60 PP_Resource URLResponseInfo::GetBodyAsFileRef() { |
| 61 // This could be more efficient by having the host automatically send us the | 61 // This could be more efficient by having the host automatically send us the |
| 62 // file ref when the request is streaming to a file and it's in the state | 62 // file ref when the request is streaming to a file and it's in the state |
| 63 // where the file is ready. This will prevent us from having to do this sync | 63 // where the file is ready. This will prevent us from having to do this sync |
| 64 // IPC here. | 64 // IPC here. |
| 65 PPB_FileRef_CreateInfo create_info; | 65 PPB_FileRef_CreateInfo create_info; |
| 66 PluginDispatcher::GetForResource(this)->Send( | 66 PluginDispatcher::GetForResource(this)->Send( |
| 67 new PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef( | 67 new PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef( |
| 68 INTERFACE_ID_PPB_URL_RESPONSE_INFO, host_resource(), &create_info)); | 68 API_ID_PPB_URL_RESPONSE_INFO, host_resource(), &create_info)); |
| 69 return PPB_FileRef_Proxy::DeserializeFileRef(create_info); | 69 return PPB_FileRef_Proxy::DeserializeFileRef(create_info); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // PPB_URLResponseInfo_Proxy --------------------------------------------------- | 72 // PPB_URLResponseInfo_Proxy --------------------------------------------------- |
| 73 | 73 |
| 74 PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy(Dispatcher* dispatcher) | 74 PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy(Dispatcher* dispatcher) |
| 75 : InterfaceProxy(dispatcher) { | 75 : InterfaceProxy(dispatcher) { |
| 76 } | 76 } |
| 77 | 77 |
| 78 PPB_URLResponseInfo_Proxy::~PPB_URLResponseInfo_Proxy() { | 78 PPB_URLResponseInfo_Proxy::~PPB_URLResponseInfo_Proxy() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef( | 113 void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef( |
| 114 const HostResource& response, | 114 const HostResource& response, |
| 115 PPB_FileRef_CreateInfo* result) { | 115 PPB_FileRef_CreateInfo* result) { |
| 116 EnterHostFromHostResource<PPB_URLResponseInfo_API> enter(response); | 116 EnterHostFromHostResource<PPB_URLResponseInfo_API> enter(response); |
| 117 PP_Resource file_ref = 0; | 117 PP_Resource file_ref = 0; |
| 118 if (enter.succeeded()) | 118 if (enter.succeeded()) |
| 119 file_ref = enter.object()->GetBodyAsFileRef(); | 119 file_ref = enter.object()->GetBodyAsFileRef(); |
| 120 | 120 |
| 121 // Use the FileRef proxy to serialize. | 121 // Use the FileRef proxy to serialize. |
| 122 PPB_FileRef_Proxy* file_ref_proxy = static_cast<PPB_FileRef_Proxy*>( | 122 PPB_FileRef_Proxy* file_ref_proxy = static_cast<PPB_FileRef_Proxy*>( |
| 123 dispatcher()->GetInterfaceProxy(INTERFACE_ID_PPB_FILE_REF)); | 123 dispatcher()->GetInterfaceProxy(API_ID_PPB_FILE_REF)); |
| 124 file_ref_proxy->SerializeFileRef(file_ref, result); | 124 file_ref_proxy->SerializeFileRef(file_ref, result); |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace proxy | 127 } // namespace proxy |
| 128 } // namespace ppapi | 128 } // namespace ppapi |
| OLD | NEW |