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

Unified Diff: ppapi/proxy/url_loader_resource.cc

Issue 21966004: Pepper: Move FileRef to the "new" resource proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove code duplication 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: ppapi/proxy/url_loader_resource.cc
diff --git a/ppapi/proxy/url_loader_resource.cc b/ppapi/proxy/url_loader_resource.cc
index 5bbc9372ff2dbea3af1b098d4a70a2673a93c211..bd429a6fc4e8d7d3125b3f606722f911914c60e2 100644
--- a/ppapi/proxy/url_loader_resource.cc
+++ b/ppapi/proxy/url_loader_resource.cc
@@ -4,13 +4,14 @@
#include "ppapi/proxy/url_loader_resource.h"
+#include "base/debug/stack_trace.h"
#include "base/logging.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/proxy/dispatch_reply_message.h"
+#include "ppapi/proxy/file_ref_resource.h"
#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/ppb_file_ref_proxy.h"
#include "ppapi/proxy/url_request_info_resource.h"
#include "ppapi/proxy/url_response_info_resource.h"
#include "ppapi/shared_impl/ppapi_globals.h"
@@ -158,9 +159,15 @@ int32_t URLLoaderResource::ReadResponseBody(
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
- if (!response_info_.get() ||
- !response_info_->data().body_as_file_ref.resource.is_null())
+ if (!response_info_.get())
return PP_ERROR_FAILED;
+
+ // Fail if we have a valid file ref.
+ // ReadResponseBody() is for reading to a user-provided buffer.
+ if (response_info_->data().body_as_file_ref.file_system_type !=
+ PP_FILESYSTEMTYPE_INVALID)
+ return PP_ERROR_FAILED;
+
if (bytes_to_read <= 0 || !buffer)
return PP_ERROR_BADARGUMENT;
@@ -186,8 +193,12 @@ int32_t URLLoaderResource::FinishStreamingToFile(
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
- if (!response_info_.get() ||
- response_info_->data().body_as_file_ref.resource.is_null())
+ if (!response_info_.get())
+ return PP_ERROR_FAILED;
+
+ // Fail if we do not have a valid file ref.
+ if (response_info_->data().body_as_file_ref.file_system_type ==
+ PP_FILESYSTEMTYPE_INVALID)
return PP_ERROR_FAILED;
// We may have already reached EOF.
@@ -357,10 +368,10 @@ void URLLoaderResource::RunCallback(int32_t result) {
void URLLoaderResource::SaveResponseInfo(const URLResponseInfoData& data) {
// Create a proxy resource for the the file ref host resource if needed.
PP_Resource body_as_file_ref = 0;
- if (!data.body_as_file_ref.resource.is_null()) {
- thunk::EnterResourceCreationNoLock enter(pp_instance());
- body_as_file_ref =
- enter.functions()->CreateFileRef(data.body_as_file_ref);
+ if (data.body_as_file_ref.file_system_type != PP_FILESYSTEMTYPE_INVALID) {
dmichael (off chromium) 2013/08/07 22:19:13 you check this a lot. How about a convenience func
teravest 2013/08/08 00:50:06 Done.
+ body_as_file_ref = FileRefResource::CreateFileRef(connection(),
+ pp_instance(),
+ data.body_as_file_ref);
}
response_info_ = new URLResponseInfoResource(
connection(), pp_instance(), data, body_as_file_ref);
@@ -389,4 +400,4 @@ size_t URLLoaderResource::FillUserBuffer() {
}
} // namespace proxy
-} // namespace ppapi
+} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698