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

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

Issue 558793002: Adding ArrayBufferView as a constructor type to Response (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@response-work1
Patch Set: 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
« 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 b12be8c26201e07ba676c13a23ccbe0a9390c58a..cd41cffba78a7d8c8e8517928c558dba7a5d710b 100644
--- a/Source/modules/serviceworkers/Response.cpp
+++ b/Source/modules/serviceworkers/Response.cpp
@@ -12,6 +12,8 @@
#include "modules/serviceworkers/ResponseInit.h"
#include "public/platform/WebServiceWorkerResponse.h"
#include "wtf/ArrayBuffer.h"
+#include "wtf/ArrayBufferView.h"
+#include "wtf/RefPtr.h"
namespace blink {
@@ -70,6 +72,15 @@ Response* Response::create(const ArrayBuffer* body, const Dictionary& responseIn
return create(blob.get(), ResponseInit(responseInit), exceptionState);
}
+Response* Response::create(const ArrayBufferView* body, const Dictionary& responseInit, ExceptionState& exceptionState)
+{
+ OwnPtr<BlobData> blobData = BlobData::create();
+ blobData->appendArrayBufferView(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
« 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