| 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" |
| 11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 12 #include "ppapi/proxy/ppb_file_ref_proxy.h" | 12 #include "ppapi/proxy/ppb_file_ref_proxy.h" |
| 13 #include "ppapi/proxy/serialized_var.h" | 13 #include "ppapi/proxy/serialized_var.h" |
| 14 #include "ppapi/shared_impl/resource.h" | 14 #include "ppapi/shared_impl/resource.h" |
| 15 #include "ppapi/thunk/ppb_url_response_info_api.h" | 15 #include "ppapi/thunk/ppb_url_response_info_api.h" |
| 16 #include "ppapi/thunk/thunk.h" | 16 #include "ppapi/thunk/thunk.h" |
| 17 | 17 |
| 18 using ppapi::thunk::PPB_URLResponseInfo_API; | 18 using ppapi::thunk::PPB_URLResponseInfo_API; |
| 19 | 19 |
| 20 namespace ppapi { | 20 namespace ppapi { |
| 21 namespace proxy { | 21 namespace proxy { |
| 22 | 22 |
| 23 namespace { | |
| 24 | |
| 25 InterfaceProxy* CreateURLResponseInfoProxy(Dispatcher* dispatcher, | |
| 26 const void* target_interface) { | |
| 27 return new PPB_URLResponseInfo_Proxy(dispatcher, target_interface); | |
| 28 } | |
| 29 | |
| 30 } // namespace | |
| 31 | |
| 32 // URLResponseInfo ------------------------------------------------------------- | 23 // URLResponseInfo ------------------------------------------------------------- |
| 33 | 24 |
| 34 class URLResponseInfo : public Resource, public PPB_URLResponseInfo_API { | 25 class URLResponseInfo : public Resource, public PPB_URLResponseInfo_API { |
| 35 public: | 26 public: |
| 36 URLResponseInfo(const HostResource& resource); | 27 URLResponseInfo(const HostResource& resource); |
| 37 virtual ~URLResponseInfo(); | 28 virtual ~URLResponseInfo(); |
| 38 | 29 |
| 39 // Resource override. | 30 // Resource override. |
| 40 virtual PPB_URLResponseInfo_API* AsPPB_URLResponseInfo_API() OVERRIDE; | 31 virtual PPB_URLResponseInfo_API* AsPPB_URLResponseInfo_API() OVERRIDE; |
| 41 | 32 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // IPC here. | 64 // IPC here. |
| 74 PPB_FileRef_CreateInfo create_info; | 65 PPB_FileRef_CreateInfo create_info; |
| 75 PluginDispatcher::GetForResource(this)->Send( | 66 PluginDispatcher::GetForResource(this)->Send( |
| 76 new PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef( | 67 new PpapiHostMsg_PPBURLResponseInfo_GetBodyAsFileRef( |
| 77 INTERFACE_ID_PPB_URL_RESPONSE_INFO, host_resource(), &create_info)); | 68 INTERFACE_ID_PPB_URL_RESPONSE_INFO, host_resource(), &create_info)); |
| 78 return PPB_FileRef_Proxy::DeserializeFileRef(create_info); | 69 return PPB_FileRef_Proxy::DeserializeFileRef(create_info); |
| 79 } | 70 } |
| 80 | 71 |
| 81 // PPB_URLResponseInfo_Proxy --------------------------------------------------- | 72 // PPB_URLResponseInfo_Proxy --------------------------------------------------- |
| 82 | 73 |
| 83 PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy( | 74 PPB_URLResponseInfo_Proxy::PPB_URLResponseInfo_Proxy(Dispatcher* dispatcher) |
| 84 Dispatcher* dispatcher, | 75 : InterfaceProxy(dispatcher) { |
| 85 const void* target_interface) | |
| 86 : InterfaceProxy(dispatcher, target_interface) { | |
| 87 } | 76 } |
| 88 | 77 |
| 89 PPB_URLResponseInfo_Proxy::~PPB_URLResponseInfo_Proxy() { | 78 PPB_URLResponseInfo_Proxy::~PPB_URLResponseInfo_Proxy() { |
| 90 } | 79 } |
| 91 | 80 |
| 92 // static | 81 // static |
| 93 const InterfaceProxy::Info* PPB_URLResponseInfo_Proxy::GetInfo() { | |
| 94 static const Info info = { | |
| 95 ppapi::thunk::GetPPB_URLResponseInfo_Thunk(), | |
| 96 PPB_URLRESPONSEINFO_INTERFACE, | |
| 97 INTERFACE_ID_PPB_URL_RESPONSE_INFO, | |
| 98 false, | |
| 99 &CreateURLResponseInfoProxy, | |
| 100 }; | |
| 101 return &info; | |
| 102 } | |
| 103 | |
| 104 // static | |
| 105 PP_Resource PPB_URLResponseInfo_Proxy::CreateResponseForResource( | 82 PP_Resource PPB_URLResponseInfo_Proxy::CreateResponseForResource( |
| 106 const HostResource& resource) { | 83 const HostResource& resource) { |
| 107 return (new URLResponseInfo(resource))->GetReference(); | 84 return (new URLResponseInfo(resource))->GetReference(); |
| 108 } | 85 } |
| 109 | 86 |
| 110 bool PPB_URLResponseInfo_Proxy::OnMessageReceived(const IPC::Message& msg) { | 87 bool PPB_URLResponseInfo_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 111 bool handled = true; | 88 bool handled = true; |
| 112 IPC_BEGIN_MESSAGE_MAP(PPB_URLResponseInfo_Proxy, msg) | 89 IPC_BEGIN_MESSAGE_MAP(PPB_URLResponseInfo_Proxy, msg) |
| 113 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetProperty, | 90 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBURLResponseInfo_GetProperty, |
| 114 OnMsgGetProperty) | 91 OnMsgGetProperty) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 135 | 112 |
| 136 void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef( | 113 void PPB_URLResponseInfo_Proxy::OnMsgGetBodyAsFileRef( |
| 137 const HostResource& response, | 114 const HostResource& response, |
| 138 PPB_FileRef_CreateInfo* result) { | 115 PPB_FileRef_CreateInfo* result) { |
| 139 EnterHostFromHostResource<PPB_URLResponseInfo_API> enter(response); | 116 EnterHostFromHostResource<PPB_URLResponseInfo_API> enter(response); |
| 140 PP_Resource file_ref = 0; | 117 PP_Resource file_ref = 0; |
| 141 if (enter.succeeded()) | 118 if (enter.succeeded()) |
| 142 file_ref = enter.object()->GetBodyAsFileRef(); | 119 file_ref = enter.object()->GetBodyAsFileRef(); |
| 143 | 120 |
| 144 // Use the FileRef proxy to serialize. | 121 // Use the FileRef proxy to serialize. |
| 145 DCHECK(!dispatcher()->IsPlugin()); | |
| 146 HostDispatcher* host_disp = static_cast<HostDispatcher*>(dispatcher()); | |
| 147 PPB_FileRef_Proxy* file_ref_proxy = static_cast<PPB_FileRef_Proxy*>( | 122 PPB_FileRef_Proxy* file_ref_proxy = static_cast<PPB_FileRef_Proxy*>( |
| 148 host_disp->GetOrCreatePPBInterfaceProxy(INTERFACE_ID_PPB_FILE_REF)); | 123 dispatcher()->GetInterfaceProxy(INTERFACE_ID_PPB_FILE_REF)); |
| 149 file_ref_proxy->SerializeFileRef(file_ref, result); | 124 file_ref_proxy->SerializeFileRef(file_ref, result); |
| 150 } | 125 } |
| 151 | 126 |
| 152 } // namespace proxy | 127 } // namespace proxy |
| 153 } // namespace ppapi | 128 } // namespace ppapi |
| OLD | NEW |