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

Unified Diff: webkit/plugins/ppapi/ppb_url_loader_impl.cc

Issue 10993031: Refactor the URLResponseInfo to use new design (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_url_loader_impl.h ('k') | webkit/plugins/ppapi/ppb_url_response_info_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_url_loader_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index 62dd4f46cfc8e182f4fde41f42e2486ea0b9461d..67c42e84ed2b35a7e183f0e4745336d963230cbc 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -10,6 +10,8 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/url_response_info_data.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_url_request_info_api.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
@@ -30,7 +32,7 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_helper.h"
#include "webkit/plugins/ppapi/url_request_info_util.h"
-#include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
+#include "webkit/plugins/ppapi/url_response_info_util.h"
using appcache::WebApplicationCacheHostImpl;
using ppapi::Resource;
@@ -219,9 +221,20 @@ PP_Bool PPB_URLLoader_Impl::GetDownloadProgress(
}
PP_Resource PPB_URLLoader_Impl::GetResponseInfo() {
- if (!response_info_)
+ ::ppapi::thunk::EnterResourceCreationNoLock enter(pp_instance());
+ if (enter.failed() || !response_info_.get())
return 0;
- return response_info_->GetReference();
+
+ // Since we're the "host" the process-local resource for the file ref is
+ // the same as the host resource. We pass a ref to the file ref.
+ if (!response_info_->body_as_file_ref.resource.is_null()) {
+ ::ppapi::PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(
+ response_info_->body_as_file_ref.resource.host_resource());
+ }
+ return enter.functions()->CreateURLResponseInfo(
+ pp_instance(),
+ *response_info_,
+ response_info_->body_as_file_ref.resource.host_resource());
}
int32_t PPB_URLLoader_Impl::ReadResponseBody(
@@ -231,7 +244,8 @@ int32_t PPB_URLLoader_Impl::ReadResponseBody(
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
- if (!response_info_ || response_info_->body())
+ if (!response_info_.get() ||
+ !response_info_->body_as_file_ref.resource.is_null())
return PP_ERROR_FAILED;
if (bytes_to_read <= 0 || !buffer)
return PP_ERROR_BADARGUMENT;
@@ -258,7 +272,8 @@ int32_t PPB_URLLoader_Impl::FinishStreamingToFile(
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
- if (!response_info_ || !response_info_->body())
+ if (!response_info_.get() ||
+ response_info_->body_as_file_ref.resource.is_null())
return PP_ERROR_FAILED;
// We may have already reached EOF.
@@ -292,6 +307,21 @@ void PPB_URLLoader_Impl::SetStatusCallback(
status_callback_ = cb;
}
+bool PPB_URLLoader_Impl::GetResponseInfoData(
+ ::ppapi::URLResponseInfoData* data) {
+ if (!response_info_.get())
+ return false;
+
+ *data = *response_info_;
+
+ // We transfer one plugin reference to the FileRef to the caller.
+ if (!response_info_->body_as_file_ref.resource.is_null()) {
+ ::ppapi::PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(
+ response_info_->body_as_file_ref.resource.host_resource());
+ }
+ return true;
+}
+
void PPB_URLLoader_Impl::willSendRequest(
WebURLLoader* loader,
WebURLRequest& new_request,
@@ -473,10 +503,13 @@ size_t PPB_URLLoader_Impl::FillUserBuffer() {
}
void PPB_URLLoader_Impl::SaveResponse(const WebURLResponse& response) {
- scoped_refptr<PPB_URLResponseInfo_Impl> response_info(
- new PPB_URLResponseInfo_Impl(pp_instance()));
- if (response_info->Initialize(response))
- response_info_ = response_info;
+ // DataFromWebURLResponse returns a file ref with one reference to it, which
+ // we take over via our ScopedPPResource.
+ response_info_.reset(new ::ppapi::URLResponseInfoData(
+ DataFromWebURLResponse(pp_instance(), response)));
+ response_info_file_ref_ = ::ppapi::ScopedPPResource(
+ ::ppapi::ScopedPPResource::PassRef(),
+ response_info_->body_as_file_ref.resource.host_resource());
}
void PPB_URLLoader_Impl::UpdateStatus() {
« no previous file with comments | « webkit/plugins/ppapi/ppb_url_loader_impl.h ('k') | webkit/plugins/ppapi/ppb_url_response_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698