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

Unified Diff: content/renderer/pepper/url_response_info_util.cc

Issue 21966004: Pepper: Move FileRef to the "new" resource proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bug in GetAbsolutePath (fixes FlashDRM test failure) Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
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..af64f7e5d7c45bc581ca910d709aac5fcd381dcc 100644
--- a/content/renderer/pepper/url_response_info_util.cc
+++ b/content/renderer/pepper/url_response_info_util.cc
@@ -7,7 +7,9 @@
#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 "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 +45,21 @@ bool IsRedirect(int32_t status) {
return status >= 300 && status <= 399;
}
+void DidCreateResourceHost(ppapi::URLResponseInfoData data,
+ const base::FilePath& external_path,
+ DataFromWebURLResponseCallback callback,
+ int pending_resource_id) {
+ data.body_as_file_ref =
+ ppapi::MakeExternalFileRefCreateInfo(external_path, pending_resource_id);
+ base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, data));
+}
+
} // namespace
void DataFromWebURLResponse(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 +74,18 @@ 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);
+ IPC::Message create_msg =
+ PpapiHostMsg_FileRef_CreateExternal(external_path);
+ RendererPpapiHost::GetForPPInstance(pp_instance)->CreateBrowserResourceHost(
+ pp_instance,
+ create_msg,
+ base::Bind(&DidCreateResourceHost, data, external_path, 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

Powered by Google App Engine
This is Rietveld 408576698