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: Source/bindings/v8/SerializedScriptValue.cpp

Issue 100023005: Make cloning of File objects more useful. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reupload Created 7 years 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/bindings/v8/SerializedScriptValue.h ('k') | Source/core/fileapi/File.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/SerializedScriptValue.cpp
diff --git a/Source/bindings/v8/SerializedScriptValue.cpp b/Source/bindings/v8/SerializedScriptValue.cpp
index f067774e36bb9221dced0e7938c974740067e937..72f3560274859d1976525d08925f14eb1469278c 100644
--- a/Source/bindings/v8/SerializedScriptValue.cpp
+++ b/Source/bindings/v8/SerializedScriptValue.cpp
@@ -549,9 +549,24 @@ public:
private:
void doWriteFile(const File& file)
{
- doWriteWebCoreString(file.path());
+ doWriteWebCoreString(file.hasBackingFile() ? file.path() : "");
+ doWriteWebCoreString(file.name());
+ doWriteWebCoreString(file.webkitRelativePath());
doWriteWebCoreString(file.uuid());
doWriteWebCoreString(file.type());
+
+ // FIXME don't use 4 bytes to encode a flag.
+ if (file.hasValidSnapshotMetadata()) {
+ doWriteUint32(static_cast<uint8_t>(1));
+
+ long long size;
+ double lastModified;
+ file.captureSnapshot(size, lastModified);
+ doWriteUint64(static_cast<uint64_t>(size));
+ doWriteNumber(lastModified);
+ } else {
+ append(static_cast<uint8_t>(0));
+ }
}
void doWriteArrayBuffer(const ArrayBuffer& arrayBuffer)
@@ -1886,15 +1901,32 @@ private:
if (m_version < 3)
return 0;
String path;
+ String name;
+ String relativePath;
String uuid;
String type;
+ uint32_t hasSnapshot = 0;
+ uint64_t size = 0;
+ double lastModified = 0;
if (!readWebCoreString(&path))
return 0;
+ if (m_version >= 4 && !readWebCoreString(&name))
+ return 0;
+ if (m_version >= 4 && !readWebCoreString(&relativePath))
+ return 0;
if (!readWebCoreString(&uuid))
return 0;
if (!readWebCoreString(&type))
return 0;
- return File::create(path, getOrCreateBlobDataHandle(uuid, type));
+ if (m_version >= 4 && !doReadUint32(&hasSnapshot))
+ return 0;
+ if (hasSnapshot) {
+ if (!doReadUint64(&size))
+ return 0;
+ if (!doReadNumber(&lastModified))
+ return 0;
+ }
+ return File::create(path, name, relativePath, hasSnapshot > 0, size, lastModified, getOrCreateBlobDataHandle(uuid, type));
}
template<class T>
« no previous file with comments | « Source/bindings/v8/SerializedScriptValue.h ('k') | Source/core/fileapi/File.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698