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

Unified Diff: Source/core/fileapi/File.cpp

Issue 1257253004: [HTMLCanvasElement.toBlob] Default callback version without scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Basic Callback version of toBlob function of HTMLCanvasElement Implemented Created 5 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: Source/core/fileapi/File.cpp
diff --git a/Source/core/fileapi/File.cpp b/Source/core/fileapi/File.cpp
index e541d7923cb1475bdd9063545c3ff44aad2159cb..6a99843c1733c2d4abcba52e6b8f8b1a8e458dd2 100644
--- a/Source/core/fileapi/File.cpp
+++ b/Source/core/fileapi/File.cpp
@@ -31,6 +31,7 @@
#include "core/fileapi/FilePropertyBag.h"
#include "platform/FileMetadata.h"
#include "platform/MIMETypeRegistry.h"
+#include "platform/blob/BlobData.h"
#include "public/platform/Platform.h"
#include "public/platform/WebFileUtilities.h"
#include "wtf/CurrentTime.h"
@@ -101,7 +102,6 @@ File* File::create(const HeapVector<BlobOrStringOrArrayBufferViewOrArrayBuffer>&
lastModified = static_cast<double>(options.lastModified());
else
lastModified = currentTimeMS();
-
ASSERT(options.hasEndings());
bool normalizeLineEndingsToNative = options.endings() == "native";
@@ -113,6 +113,19 @@ File* File::create(const HeapVector<BlobOrStringOrArrayBufferViewOrArrayBuffer>&
return File::create(fileName, lastModified, BlobDataHandle::create(blobData.release(), fileSize));
}
+File* File::create(Vector<char>* encodedImage, const String& mimeType)
+{
+ ASSERT(encodedImage);
+
+ OwnPtr<BlobData> blobData = BlobData::create();
+ blobData->setContentType(mimeType);
Justin Novosad 2015/08/13 21:03:40 your test should be checking that setting the mime
xlai (Olivia) 2015/08/20 19:46:44 Acknowledged. Planning to write one more layout te
+ blobData->appendBytes(encodedImage->data(), encodedImage->size());
+ long long blobSize = blobData->length();
+
+ // create blob as the type of file with two additional attributes -- name and lastModificationTime
+ return File::create("", currentTimeMS(), BlobDataHandle::create(blobData.release(), blobSize));
+}
+
File* File::createWithRelativePath(const String& path, const String& relativePath)
{
File* file = new File(path, File::AllContentTypes, File::IsUserVisible);

Powered by Google App Engine
This is Rietveld 408576698