Index: content/renderer/pepper/url_response_info_util.cc |
diff --git a/content/renderer/pepper/url_response_info_util.cc b/content/renderer/pepper/url_response_info_util.cc |
index a9eccefcecefb0a1cb6286d1f07bd43ad507963e..eda54d4ba5b22df3d2e619bee39d2aa8c587de6e 100644 |
--- a/content/renderer/pepper/url_response_info_util.cc |
+++ b/content/renderer/pepper/url_response_info_util.cc |
@@ -7,7 +7,11 @@ |
#include "base/bind.h" |
#include "base/files/file_path.h" |
#include "base/message_loop/message_loop.h" |
-#include "content/renderer/pepper/ppb_file_ref_impl.h" |
+#include "content/public/renderer/renderer_ppapi_host.h" |
+#include "content/renderer/pepper/pepper_file_ref_renderer_host.h" |
+#include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
+#include "ipc/ipc_message.h" |
+#include "ppapi/proxy/ppapi_messages.h" |
#include "ppapi/shared_impl/url_response_info_data.h" |
#include "third_party/WebKit/public/platform/WebCString.h" |
#include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" |
@@ -43,13 +47,34 @@ bool IsRedirect(int32_t status) { |
return status >= 300 && status <= 399; |
} |
+void DidCreateResourceHosts(const ppapi::URLResponseInfoData& in_data, |
+ const base::FilePath& external_path, |
+ int renderer_pending_host_id, |
+ const DataFromWebURLResponseCallback& callback, |
+ const std::vector<int>& browser_pending_host_ids) { |
+ DCHECK(browser_pending_host_ids.size() == 1); |
+ int browser_pending_host_id = 0; |
+ |
+ if (browser_pending_host_ids.size() == 1) |
+ browser_pending_host_id = browser_pending_host_ids[0]; |
+ |
+ ppapi::URLResponseInfoData data = in_data; |
+ |
+ data.body_as_file_ref = ppapi::MakeExternalFileRefCreateInfo( |
+ external_path, |
+ std::string(), |
+ browser_pending_host_id, |
+ renderer_pending_host_id); |
+ callback.Run(data); |
+} |
+ |
} // namespace |
-void DataFromWebURLResponse(PP_Instance pp_instance, |
+void DataFromWebURLResponse(RendererPpapiHostImpl* host_impl, |
+ PP_Instance pp_instance, |
const WebURLResponse& response, |
const DataFromWebURLResponseCallback& callback) { |
ppapi::URLResponseInfoData data; |
- |
data.url = response.url().spec(); |
data.status_code = response.httpStatusCode(); |
data.status_text = response.httpStatusText().utf8(); |
@@ -64,18 +89,30 @@ void DataFromWebURLResponse(PP_Instance pp_instance, |
WebString file_path = response.downloadFilePath(); |
if (!file_path.isEmpty()) { |
- scoped_refptr<PPB_FileRef_Impl> file_ref( |
- PPB_FileRef_Impl::CreateExternal( |
- pp_instance, |
- base::FilePath::FromUTF16Unsafe(file_path), |
- std::string())); |
- data.body_as_file_ref = file_ref->GetCreateInfo(); |
- file_ref->GetReference(); // The returned data has one ref for the plugin. |
+ base::FilePath external_path = base::FilePath::FromUTF16Unsafe(file_path); |
+ // TODO(teravest): Write a utility function to create resource hosts in the |
+ // renderer and browser. |
+ PepperFileRefRendererHost* renderer_host = |
+ new PepperFileRefRendererHost(host_impl, pp_instance, 0, external_path); |
+ int renderer_pending_host_id = |
+ host_impl->GetPpapiHost()->AddPendingResourceHost( |
+ scoped_ptr<ppapi::host::ResourceHost>(renderer_host)); |
+ |
+ std::vector<IPC::Message> create_msgs; |
+ create_msgs.push_back(PpapiHostMsg_FileRef_CreateExternal(external_path)); |
+ host_impl->CreateBrowserResourceHosts( |
+ pp_instance, |
+ create_msgs, |
+ base::Bind(&DidCreateResourceHosts, |
+ data, |
+ external_path, |
+ renderer_pending_host_id, |
+ callback)); |
+ } else { |
+ base::MessageLoop::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(callback, data)); |
} |
- |
- // We post data to a callback instead of returning it here because the new |
- // implementation for FileRef is asynchronous when creating the resource. |
- base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, data)); |
} |
} // namespace content |