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

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

Issue 556563002: Adding ArrayBuffer support to ServiceWorker Response and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Style fixes Created 6 years, 3 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: Source/modules/serviceworkers/Response.cpp
diff --git a/Source/modules/serviceworkers/Response.cpp b/Source/modules/serviceworkers/Response.cpp
index 5752a45b580d848c612fdf2a4eea9587d125439c..b12be8c26201e07ba676c13a23ccbe0a9390c58a 100644
--- a/Source/modules/serviceworkers/Response.cpp
+++ b/Source/modules/serviceworkers/Response.cpp
@@ -11,6 +11,7 @@
#include "modules/serviceworkers/FetchBodyStream.h"
#include "modules/serviceworkers/ResponseInit.h"
#include "public/platform/WebServiceWorkerResponse.h"
+#include "wtf/ArrayBuffer.h"
namespace blink {
@@ -60,6 +61,15 @@ Response* Response::create(const String& body, const Dictionary& responseInit, E
return create(blob.get(), ResponseInit(responseInit), exceptionState);
}
+Response* Response::create(const ArrayBuffer* body, const Dictionary& responseInit, ExceptionState& exceptionState)
+{
+ OwnPtr<BlobData> blobData = BlobData::create();
+ blobData->appendArrayBuffer(body);
+ const long long length = blobData->length();
+ RefPtrWillBeRawPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release(), length));
+ return create(blob.get(), ResponseInit(responseInit), exceptionState);
+}
+
Response* Response::create(Blob* body, const ResponseInit& responseInit, ExceptionState& exceptionState)
{
// "1. If |init|'s status member is not in the range 200 to 599, throw a

Powered by Google App Engine
This is Rietveld 408576698