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

Unified Diff: Source/modules/serviceworkers/Response.cpp

Issue 307063002: ServiceWorker: Add a Response ctor that accepts the body as a Blob (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: don't crash on null body Created 6 years, 7 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
« no previous file with comments | « Source/modules/serviceworkers/Response.h ('k') | Source/modules/serviceworkers/Response.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/Response.cpp
diff --git a/Source/modules/serviceworkers/Response.cpp b/Source/modules/serviceworkers/Response.cpp
index 9b4c9c1111f453ba1207b4b4e99458c70d57dcb5..5f4596bddf0c2269c78c127dd27ab4f160c55eb7 100644
--- a/Source/modules/serviceworkers/Response.cpp
+++ b/Source/modules/serviceworkers/Response.cpp
@@ -6,20 +6,26 @@
#include "Response.h"
#include "bindings/v8/Dictionary.h"
+#include "core/fileapi/Blob.h"
#include "modules/serviceworkers/ResponseInit.h"
#include "platform/NotImplemented.h"
#include "public/platform/WebServiceWorkerResponse.h"
namespace WebCore {
-PassRefPtr<Response> Response::create()
+// FIXME: Remove this legacy function when the required Chromium-side patch lands.
+PassRefPtr<Response> Response::create(const Dictionary& responseInit)
{
- return create(Dictionary());
+ return create(nullptr, responseInit);
}
-PassRefPtr<Response> Response::create(const Dictionary& responseInit)
+PassRefPtr<Response> Response::create(Blob* body, const Dictionary& responseInit)
{
- return adoptRef(new Response(ResponseInit(responseInit)));
+ RefPtr<BlobDataHandle> blobDataHandle = body ? body->blobDataHandle() : nullptr;
+
+ // FIXME: Maybe append or override content-length and content-type headers using the blob. The spec will clarify what to do:
+ // https://github.com/slightlyoff/ServiceWorker/issues/192
+ return adoptRef(new Response(blobDataHandle.release(), ResponseInit(responseInit)));
}
PassRefPtr<HeaderMap> Response::headers() const
@@ -33,12 +39,14 @@ void Response::populateWebServiceWorkerResponse(blink::WebServiceWorkerResponse&
response.setStatus(status());
response.setStatusText(statusText());
response.setHeaders(m_headers->headerMap());
+ response.setBlobDataHandle(m_blobDataHandle);
}
-Response::Response(const ResponseInit& responseInit)
+Response::Response(PassRefPtr<BlobDataHandle> blobDataHandle, const ResponseInit& responseInit)
: m_status(responseInit.status)
, m_statusText(responseInit.statusText)
, m_headers(responseInit.headers)
+ , m_blobDataHandle(blobDataHandle)
{
ScriptWrappable::init(this);
« no previous file with comments | « Source/modules/serviceworkers/Response.h ('k') | Source/modules/serviceworkers/Response.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698