Commit 8efba051 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Blob: Change the type of WebBlobInfo::LastModified()

from double, seconds from the Unix epoch, to base::Optional<base::Time>.

Bug: 988343
Change-Id: I6f36a98734aea86ed560c841d1b3dd565f4635af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935289Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719359}
parent 4403d4d0
...@@ -17,19 +17,16 @@ class BlobDataHandle; ...@@ -17,19 +17,16 @@ class BlobDataHandle;
class WebBlobInfo { class WebBlobInfo {
public: public:
WebBlobInfo() WebBlobInfo()
: is_file_(false), : is_file_(false), size_(std::numeric_limits<uint64_t>::max()) {}
size_(std::numeric_limits<uint64_t>::max()),
last_modified_(0) {}
BLINK_EXPORT WebBlobInfo(const WebString& uuid, BLINK_EXPORT WebBlobInfo(const WebString& uuid,
const WebString& type, const WebString& type,
uint64_t size, uint64_t size,
mojo::ScopedMessagePipeHandle); mojo::ScopedMessagePipeHandle);
// |last_modified| - Seconds from Unix epoch.
BLINK_EXPORT WebBlobInfo(const WebString& uuid, BLINK_EXPORT WebBlobInfo(const WebString& uuid,
const WebString& file_path, const WebString& file_path,
const WebString& file_name, const WebString& file_name,
const WebString& type, const WebString& type,
double last_modified, const base::Optional<base::Time>& last_modified,
uint64_t size, uint64_t size,
mojo::ScopedMessagePipeHandle); mojo::ScopedMessagePipeHandle);
...@@ -56,7 +53,7 @@ class WebBlobInfo { ...@@ -56,7 +53,7 @@ class WebBlobInfo {
uint64_t size() const { return size_; } uint64_t size() const { return size_; }
const WebString& FilePath() const { return file_path_; } const WebString& FilePath() const { return file_path_; }
const WebString& FileName() const { return file_name_; } const WebString& FileName() const { return file_name_; }
double LastModified() const { return last_modified_; } base::Optional<base::Time> LastModified() const { return last_modified_; }
BLINK_EXPORT mojo::ScopedMessagePipeHandle CloneBlobHandle() const; BLINK_EXPORT mojo::ScopedMessagePipeHandle CloneBlobHandle() const;
#if INSIDE_BLINK #if INSIDE_BLINK
...@@ -64,7 +61,7 @@ class WebBlobInfo { ...@@ -64,7 +61,7 @@ class WebBlobInfo {
BLINK_EXPORT WebBlobInfo(scoped_refptr<BlobDataHandle>, BLINK_EXPORT WebBlobInfo(scoped_refptr<BlobDataHandle>,
const WebString& file_path, const WebString& file_path,
const WebString& file_name, const WebString& file_name,
double last_modified); const base::Optional<base::Time>& last_modified);
// TODO(mek): Get rid of these constructors after ensuring that the // TODO(mek): Get rid of these constructors after ensuring that the
// BlobDataHandle always has the correct type and size. // BlobDataHandle always has the correct type and size.
BLINK_EXPORT WebBlobInfo(scoped_refptr<BlobDataHandle>, BLINK_EXPORT WebBlobInfo(scoped_refptr<BlobDataHandle>,
...@@ -74,7 +71,7 @@ class WebBlobInfo { ...@@ -74,7 +71,7 @@ class WebBlobInfo {
const WebString& file_path, const WebString& file_path,
const WebString& file_name, const WebString& file_name,
const WebString& type, const WebString& type,
double last_modified, const base::Optional<base::Time>& last_modified,
uint64_t size); uint64_t size);
BLINK_EXPORT scoped_refptr<BlobDataHandle> GetBlobHandle() const; BLINK_EXPORT scoped_refptr<BlobDataHandle> GetBlobHandle() const;
#endif #endif
...@@ -87,7 +84,7 @@ class WebBlobInfo { ...@@ -87,7 +84,7 @@ class WebBlobInfo {
WebPrivatePtr<BlobDataHandle> blob_handle_; WebPrivatePtr<BlobDataHandle> blob_handle_;
WebString file_path_; // Only for File WebString file_path_; // Only for File
WebString file_name_; // Only for File WebString file_name_; // Only for File
double last_modified_; // Only for File base::Optional<base::Time> last_modified_; // Only for File
}; };
} // namespace blink } // namespace blink
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "third_party/blink/renderer/core/streams/writable_stream.h" #include "third_party/blink/renderer/core/streams/writable_stream.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_shared_array_buffer.h" #include "third_party/blink/renderer/core/typed_arrays/dom_shared_array_buffer.h"
#include "third_party/blink/renderer/platform/file_metadata.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/date_math.h" #include "third_party/blink/renderer/platform/wtf/date_math.h"
#include "third_party/skia/include/core/SkFilterQuality.h" #include "third_party/skia/include/core/SkFilterQuality.h"
...@@ -633,8 +634,6 @@ File* V8ScriptValueDeserializer::ReadFileIndex() { ...@@ -633,8 +634,6 @@ File* V8ScriptValueDeserializer::ReadFileIndex() {
if (!ReadUint32(&index) || index >= blob_info_array_->size()) if (!ReadUint32(&index) || index >= blob_info_array_->size())
return nullptr; return nullptr;
const WebBlobInfo& info = (*blob_info_array_)[index]; const WebBlobInfo& info = (*blob_info_array_)[index];
// FIXME: transition WebBlobInfo.lastModified to be milliseconds-based also.
double last_modified_ms = info.LastModified() * kMsPerSecond;
auto blob_handle = info.GetBlobHandle(); auto blob_handle = info.GetBlobHandle();
if (!blob_handle) { if (!blob_handle) {
blob_handle = blob_handle =
...@@ -642,9 +641,9 @@ File* V8ScriptValueDeserializer::ReadFileIndex() { ...@@ -642,9 +641,9 @@ File* V8ScriptValueDeserializer::ReadFileIndex() {
} }
if (!blob_handle) if (!blob_handle)
return nullptr; return nullptr;
return File::CreateFromIndexedSerialization(info.FilePath(), info.FileName(), return File::CreateFromIndexedSerialization(
info.size(), last_modified_ms, info.FilePath(), info.FileName(), info.size(),
blob_handle); ToJsTimeOrNaN(info.LastModified()), blob_handle);
} }
DOMRectReadOnly* V8ScriptValueDeserializer::ReadDOMRectReadOnly() { DOMRectReadOnly* V8ScriptValueDeserializer::ReadDOMRectReadOnly() {
......
...@@ -627,14 +627,9 @@ bool V8ScriptValueSerializer::WriteFile(File* file, ...@@ -627,14 +627,9 @@ bool V8ScriptValueSerializer::WriteFile(File* file,
uint64_t size; uint64_t size;
base::Optional<base::Time> last_modified_time; base::Optional<base::Time> last_modified_time;
file->CaptureSnapshot(size, last_modified_time); file->CaptureSnapshot(size, last_modified_time);
// TODO(crbug.com/988343): transition WebBlobInfo.lastModified to be
// base::Time also.
double last_modified = last_modified_time
? last_modified_time->ToDoubleT()
: std::numeric_limits<double>::quiet_NaN();
blob_info_array_->emplace_back(file->GetBlobDataHandle(), file->GetPath(), blob_info_array_->emplace_back(file->GetBlobDataHandle(), file->GetPath(),
file->name(), file->type(), last_modified, file->name(), file->type(),
size); last_modified_time, size);
WriteUint32(static_cast<uint32_t>(index)); WriteUint32(static_cast<uint32_t>(index));
} else { } else {
WriteUTF8String(file->HasBackingFile() ? file->GetPath() : g_empty_string); WriteUTF8String(file->HasBackingFile() ? file->GetPath() : g_empty_string);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "third_party/blink/public/platform/file_path_conversion.h" #include "third_party/blink/public/platform/file_path_conversion.h"
#include "third_party/blink/public/platform/web_blob_info.h" #include "third_party/blink/public/platform/web_blob_info.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_key_range.h" #include "third_party/blink/renderer/modules/indexeddb/idb_key_range.h"
#include "third_party/blink/renderer/platform/file_metadata.h"
#include "third_party/blink/renderer/platform/mojo/string16_mojom_traits.h" #include "third_party/blink/renderer/platform/mojo/string16_mojom_traits.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -199,7 +200,7 @@ StructTraits<blink::mojom::IDBValueDataView, std::unique_ptr<blink::IDBValue>>:: ...@@ -199,7 +200,7 @@ StructTraits<blink::mojom::IDBValueDataView, std::unique_ptr<blink::IDBValue>>::
name = g_empty_string; name = g_empty_string;
blob_info->file->name = name; blob_info->file->name = name;
blob_info->file->last_modified = blob_info->file->last_modified =
base::Time::FromDoubleT(info.LastModified()); info.LastModified().value_or(base::Time());
} }
blob_info->size = info.size(); blob_info->size = info.size();
blob_info->uuid = info.Uuid(); blob_info->uuid = info.Uuid();
...@@ -241,11 +242,11 @@ bool StructTraits<blink::mojom::IDBValueDataView, ...@@ -241,11 +242,11 @@ bool StructTraits<blink::mojom::IDBValueDataView,
value_blob_info.ReserveInitialCapacity(blob_or_file_info.size()); value_blob_info.ReserveInitialCapacity(blob_or_file_info.size());
for (const auto& info : blob_or_file_info) { for (const auto& info : blob_or_file_info) {
if (info->file) { if (info->file) {
value_blob_info.emplace_back(info->uuid, value_blob_info.emplace_back(
blink::FilePathToWebString(info->file->path), info->uuid, blink::FilePathToWebString(info->file->path),
info->file->name, info->mime_type, info->file->name, info->mime_type,
info->file->last_modified.ToDoubleT(), blink::NullableTimeToOptionalTime(info->file->last_modified),
info->size, info->blob.PassPipe()); info->size, info->blob.PassPipe());
} else { } else {
value_blob_info.emplace_back(info->uuid, info->mime_type, info->size, value_blob_info.emplace_back(info->uuid, info->mime_type, info->size,
info->blob.PassPipe()); info->blob.PassPipe());
......
...@@ -26,7 +26,7 @@ WebBlobInfo::WebBlobInfo(const WebString& uuid, ...@@ -26,7 +26,7 @@ WebBlobInfo::WebBlobInfo(const WebString& uuid,
const WebString& file_path, const WebString& file_path,
const WebString& file_name, const WebString& file_name,
const WebString& type, const WebString& type,
double last_modified, const base::Optional<base::Time>& last_modified,
uint64_t size, uint64_t size,
mojo::ScopedMessagePipeHandle handle) mojo::ScopedMessagePipeHandle handle)
: WebBlobInfo( : WebBlobInfo(
...@@ -52,7 +52,7 @@ WebBlobInfo WebBlobInfo::FileForTesting(const WebString& uuid, ...@@ -52,7 +52,7 @@ WebBlobInfo WebBlobInfo::FileForTesting(const WebString& uuid,
const WebString& file_path, const WebString& file_path,
const WebString& file_name, const WebString& file_name,
const WebString& type) { const WebString& type) {
return WebBlobInfo(uuid, file_path, file_name, type, 0, return WebBlobInfo(uuid, file_path, file_name, type, base::nullopt,
std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::max(),
mojo::MessagePipe().handle0); mojo::MessagePipe().handle0);
} }
...@@ -79,7 +79,7 @@ WebBlobInfo::WebBlobInfo(scoped_refptr<BlobDataHandle> handle) ...@@ -79,7 +79,7 @@ WebBlobInfo::WebBlobInfo(scoped_refptr<BlobDataHandle> handle)
WebBlobInfo::WebBlobInfo(scoped_refptr<BlobDataHandle> handle, WebBlobInfo::WebBlobInfo(scoped_refptr<BlobDataHandle> handle,
const WebString& file_path, const WebString& file_path,
const WebString& file_name, const WebString& file_name,
double last_modified) const base::Optional<base::Time>& last_modified)
: WebBlobInfo(handle, : WebBlobInfo(handle,
file_path, file_path,
file_name, file_name,
...@@ -94,14 +94,13 @@ WebBlobInfo::WebBlobInfo(scoped_refptr<BlobDataHandle> handle, ...@@ -94,14 +94,13 @@ WebBlobInfo::WebBlobInfo(scoped_refptr<BlobDataHandle> handle,
uuid_(handle->Uuid()), uuid_(handle->Uuid()),
type_(type), type_(type),
size_(size), size_(size),
blob_handle_(std::move(handle)), blob_handle_(std::move(handle)) {}
last_modified_(0) {}
WebBlobInfo::WebBlobInfo(scoped_refptr<BlobDataHandle> handle, WebBlobInfo::WebBlobInfo(scoped_refptr<BlobDataHandle> handle,
const WebString& file_path, const WebString& file_path,
const WebString& file_name, const WebString& file_name,
const WebString& type, const WebString& type,
double last_modified, const base::Optional<base::Time>& last_modified,
uint64_t size) uint64_t size)
: is_file_(true), : is_file_(true),
uuid_(handle->Uuid()), uuid_(handle->Uuid()),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment