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

Unified Diff: Source/bindings/core/v8/ScriptValueSerializer.cpp

Issue 884393002: Upgrade Blink to milliseconds-based last modified filetimes, part 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sof-fileinfo-modtime-in-ms-1
Patch Set: Stop using time_t over getFileModificationTime(); not sound Created 5 years, 10 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/bindings/core/v8/ScriptValueSerializer.cpp
diff --git a/Source/bindings/core/v8/ScriptValueSerializer.cpp b/Source/bindings/core/v8/ScriptValueSerializer.cpp
index f070c230c7abf6160994b516f10dfc2781ed623f..03c7bbb00833a7405e7597a69f854fe3558f54a7 100644
--- a/Source/bindings/core/v8/ScriptValueSerializer.cpp
+++ b/Source/bindings/core/v8/ScriptValueSerializer.cpp
@@ -18,6 +18,7 @@
#include "core/fileapi/FileList.h"
#include "public/platform/Platform.h"
#include "public/platform/WebBlobInfo.h"
+#include "wtf/DateMath.h"
#include "wtf/text/StringHash.h"
#include "wtf/text/StringUTF8Adaptor.h"
@@ -381,10 +382,10 @@ void SerializedScriptValueWriter::doWriteFile(const File& file)
doWriteUint32(static_cast<uint8_t>(1));
long long size;
- double lastModified;
- file.captureSnapshot(size, lastModified);
+ double lastModifiedMS;
+ file.captureSnapshot(size, lastModifiedMS);
doWriteUint64(static_cast<uint64_t>(size));
- doWriteNumber(lastModified);
+ doWriteNumber(lastModifiedMS);
} else {
doWriteUint32(static_cast<uint8_t>(0));
}
@@ -989,9 +990,11 @@ bool ScriptValueSerializer::appendFileInfo(const File* file, int* index)
return false;
long long size = -1;
- double lastModified = invalidFileTime();
- file->captureSnapshot(size, lastModified);
+ double lastModifiedMS = invalidFileTime();
+ file->captureSnapshot(size, lastModifiedMS);
*index = m_blobInfo->size();
+ // FIXME: transition WebBlobInfo.lastModified to be milliseconds-based also.
+ double lastModified = lastModifiedMS / msPerSecond;
m_blobInfo->append(WebBlobInfo(file->uuid(), file->path(), file->name(), file->type(), lastModified, size));
return true;
}
@@ -1598,7 +1601,7 @@ File* SerializedScriptValueReader::readFileHelper()
String type;
uint32_t hasSnapshot = 0;
uint64_t size = 0;
- double lastModified = 0;
+ double lastModifiedMS = 0;
if (!readWebCoreString(&path))
return nullptr;
if (m_version >= 4 && !readWebCoreString(&name))
@@ -1614,14 +1617,16 @@ File* SerializedScriptValueReader::readFileHelper()
if (hasSnapshot) {
if (!doReadUint64(&size))
return nullptr;
- if (!doReadNumber(&lastModified))
+ if (!doReadNumber(&lastModifiedMS))
return nullptr;
+ if (m_version < 8)
+ lastModifiedMS *= msPerSecond;
}
uint32_t isUserVisible = 1;
if (m_version >= 7 && !doReadUint32(&isUserVisible))
return nullptr;
const File::UserVisibility userVisibility = (isUserVisible > 0) ? File::IsUserVisible : File::IsNotUserVisible;
- return File::createFromSerialization(path, name, relativePath, userVisibility, hasSnapshot > 0, size, lastModified, getOrCreateBlobDataHandle(uuid, type));
+ return File::createFromSerialization(path, name, relativePath, userVisibility, hasSnapshot > 0, size, lastModifiedMS, getOrCreateBlobDataHandle(uuid, type));
}
File* SerializedScriptValueReader::readFileIndexHelper()
@@ -1633,7 +1638,9 @@ File* SerializedScriptValueReader::readFileIndexHelper()
if (!doReadUint32(&index) || index >= m_blobInfo->size())
return nullptr;
const WebBlobInfo& info = (*m_blobInfo)[index];
- return File::createFromIndexedSerialization(info.filePath(), info.fileName(), info.size(), info.lastModified(), getOrCreateBlobDataHandle(info.uuid(), info.type(), info.size()));
+ // FIXME: transition WebBlobInfo.lastModified to be milliseconds-based also.
+ double lastModifiedMS = info.lastModified() * msPerSecond;
+ return File::createFromIndexedSerialization(info.filePath(), info.fileName(), info.size(), lastModifiedMS, getOrCreateBlobDataHandle(info.uuid(), info.type(), info.size()));
}
bool SerializedScriptValueReader::doReadUint32(uint32_t* value)
« no previous file with comments | « LayoutTests/fast/storage/resources/serialized-script-value.js ('k') | Source/bindings/core/v8/SerializedScriptValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698