Commit cb51073c authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Blob: Change the type of |expected_modification_time| arguments of BlobData

from double to base::Optional<base::Time>.

This CL also changes a double argument of File::CaptureSnapshot() to
base::Optional<base::Time>.

This CL has no behavior changes.

Bug: 988343
Change-Id: Ida6d0d415cc8f72d2c965bfd242b584080570791
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933668
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718857}
parent c3b33fdb
...@@ -24,6 +24,7 @@ class WebBlobInfo { ...@@ -24,6 +24,7 @@ class WebBlobInfo {
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,
......
...@@ -94,6 +94,7 @@ class WebHTTPBody { ...@@ -94,6 +94,7 @@ class WebHTTPBody {
BLINK_PLATFORM_EXPORT void AppendData(const WebData&); BLINK_PLATFORM_EXPORT void AppendData(const WebData&);
BLINK_PLATFORM_EXPORT void AppendFile(const WebString&); BLINK_PLATFORM_EXPORT void AppendFile(const WebString&);
// Passing -1 to |file_length| means to the end of the file. // Passing -1 to |file_length| means to the end of the file.
// |modification_time| - Seconds from Unix epoch.
BLINK_PLATFORM_EXPORT void AppendFileRange(const WebString&, BLINK_PLATFORM_EXPORT void AppendFileRange(const WebString&,
int64_t file_start, int64_t file_start,
int64_t file_length, int64_t file_length,
......
...@@ -625,10 +625,13 @@ bool V8ScriptValueSerializer::WriteFile(File* file, ...@@ -625,10 +625,13 @@ bool V8ScriptValueSerializer::WriteFile(File* file,
size_t index = blob_info_array_->size(); size_t index = blob_info_array_->size();
DCHECK_LE(index, std::numeric_limits<uint32_t>::max()); DCHECK_LE(index, std::numeric_limits<uint32_t>::max());
uint64_t size; uint64_t size;
double last_modified_ms = InvalidFileTime(); base::Optional<base::Time> last_modified_time;
file->CaptureSnapshot(size, last_modified_ms); file->CaptureSnapshot(size, last_modified_time);
// FIXME: transition WebBlobInfo.lastModified to be milliseconds-based also. // TODO(crbug.com/988343): transition WebBlobInfo.lastModified to be
double last_modified = last_modified_ms / kMsPerSecond; // 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(), last_modified,
size); size);
...@@ -644,11 +647,12 @@ bool V8ScriptValueSerializer::WriteFile(File* file, ...@@ -644,11 +647,12 @@ bool V8ScriptValueSerializer::WriteFile(File* file,
if (file->HasValidSnapshotMetadata()) { if (file->HasValidSnapshotMetadata()) {
WriteUint32(1); WriteUint32(1);
uint64_t size; uint64_t size;
double last_modified_ms; base::Optional<base::Time> last_modified;
file->CaptureSnapshot(size, last_modified_ms); file->CaptureSnapshot(size, last_modified);
DCHECK_NE(size, std::numeric_limits<uint64_t>::max()); DCHECK_NE(size, std::numeric_limits<uint64_t>::max());
WriteUint64(size); WriteUint64(size);
WriteDouble(last_modified_ms); WriteDouble(last_modified ? last_modified->ToJsTimeIgnoringNull()
: std::numeric_limits<double>::quiet_NaN());
} else { } else {
WriteUint32(0); WriteUint32(0);
} }
......
...@@ -48,7 +48,7 @@ WebBlob WebBlob::CreateFromUUID(const WebString& uuid, ...@@ -48,7 +48,7 @@ WebBlob WebBlob::CreateFromUUID(const WebString& uuid,
WebBlob WebBlob::CreateFromFile(const WebString& path, uint64_t size) { WebBlob WebBlob::CreateFromFile(const WebString& path, uint64_t size) {
auto blob_data = std::make_unique<BlobData>(); auto blob_data = std::make_unique<BlobData>();
blob_data->AppendFile(path, 0, size, InvalidFileTime()); blob_data->AppendFile(path, 0, size, base::nullopt);
return Blob::Create(BlobDataHandle::Create(std::move(blob_data), size)); return Blob::Create(BlobDataHandle::Create(std::move(blob_data), size));
} }
......
...@@ -415,9 +415,9 @@ class ComplexFormDataBytesConsumer final : public BytesConsumer { ...@@ -415,9 +415,9 @@ class ComplexFormDataBytesConsumer final : public BytesConsumer {
return; return;
} }
} }
blob_data->AppendFile(element.filename_, element.file_start_, blob_data->AppendFile(
file_length, element.filename_, element.file_start_, file_length,
element.expected_file_modification_time_); DoubleTToOptionalTime(element.expected_file_modification_time_));
break; break;
} }
case FormDataElement::kEncodedBlob: case FormDataElement::kEncodedBlob:
......
...@@ -95,13 +95,11 @@ static std::unique_ptr<BlobData> CreateBlobDataForFileWithMetadata( ...@@ -95,13 +95,11 @@ static std::unique_ptr<BlobData> CreateBlobDataForFileWithMetadata(
std::unique_ptr<BlobData> blob_data; std::unique_ptr<BlobData> blob_data;
if (metadata.length == BlobData::kToEndOfFile) { if (metadata.length == BlobData::kToEndOfFile) {
blob_data = BlobData::CreateForFileWithUnknownSize( blob_data = BlobData::CreateForFileWithUnknownSize(
metadata.platform_path, metadata.platform_path, metadata.modification_time);
ToJsTimeOrNaN(metadata.modification_time) / kMsPerSecond);
} else { } else {
blob_data = std::make_unique<BlobData>(); blob_data = std::make_unique<BlobData>();
blob_data->AppendFile( blob_data->AppendFile(metadata.platform_path, 0, metadata.length,
metadata.platform_path, 0, metadata.length, metadata.modification_time);
ToJsTimeOrNaN(metadata.modification_time) / kMsPerSecond);
} }
blob_data->SetContentType(GetContentTypeFromFileName( blob_data->SetContentType(GetContentTypeFromFileName(
file_system_name, File::kWellKnownContentTypes)); file_system_name, File::kWellKnownContentTypes));
...@@ -114,13 +112,11 @@ static std::unique_ptr<BlobData> CreateBlobDataForFileSystemURL( ...@@ -114,13 +112,11 @@ static std::unique_ptr<BlobData> CreateBlobDataForFileSystemURL(
std::unique_ptr<BlobData> blob_data; std::unique_ptr<BlobData> blob_data;
if (metadata.length == BlobData::kToEndOfFile) { if (metadata.length == BlobData::kToEndOfFile) {
blob_data = BlobData::CreateForFileSystemURLWithUnknownSize( blob_data = BlobData::CreateForFileSystemURLWithUnknownSize(
file_system_url, file_system_url, metadata.modification_time);
ToJsTimeOrNaN(metadata.modification_time) / kMsPerSecond);
} else { } else {
blob_data = std::make_unique<BlobData>(); blob_data = std::make_unique<BlobData>();
blob_data->AppendFileSystemURL( blob_data->AppendFileSystemURL(file_system_url, 0, metadata.length,
file_system_url, 0, metadata.length, metadata.modification_time);
ToJsTimeOrNaN(metadata.modification_time) / kMsPerSecond);
} }
blob_data->SetContentType(GetContentTypeFromFileName( blob_data->SetContentType(GetContentTypeFromFileName(
file_system_url.GetPath(), File::kWellKnownContentTypes)); file_system_url.GetPath(), File::kWellKnownContentTypes));
...@@ -364,24 +360,25 @@ Blob* File::slice(int64_t start, ...@@ -364,24 +360,25 @@ Blob* File::slice(int64_t start,
// FIXME: This involves synchronous file operation. We need to figure out how // FIXME: This involves synchronous file operation. We need to figure out how
// to make it asynchronous. // to make it asynchronous.
uint64_t size; uint64_t size;
double modification_time_ms; base::Optional<base::Time> modification_time;
CaptureSnapshot(size, modification_time_ms); CaptureSnapshot(size, modification_time);
ClampSliceOffsets(size, start, end); ClampSliceOffsets(size, start, end);
uint64_t length = end - start; uint64_t length = end - start;
auto blob_data = std::make_unique<BlobData>(); auto blob_data = std::make_unique<BlobData>();
blob_data->SetContentType(NormalizeType(content_type)); blob_data->SetContentType(NormalizeType(content_type));
DCHECK(!path_.IsEmpty()); DCHECK(!path_.IsEmpty());
blob_data->AppendFile(path_, start, length, blob_data->AppendFile(path_, start, length, modification_time);
modification_time_ms / kMsPerSecond);
return Blob::Create(BlobDataHandle::Create(std::move(blob_data), length)); return Blob::Create(BlobDataHandle::Create(std::move(blob_data), length));
} }
void File::CaptureSnapshot(uint64_t& snapshot_size, void File::CaptureSnapshot(
double& snapshot_modification_time_ms) const { uint64_t& snapshot_size,
base::Optional<base::Time>& snapshot_modification_time) const {
if (HasValidSnapshotMetadata()) { if (HasValidSnapshotMetadata()) {
snapshot_size = *snapshot_size_; snapshot_size = *snapshot_size_;
snapshot_modification_time_ms = snapshot_modification_time_ms_; snapshot_modification_time =
JsTimeToOptionalTime(snapshot_modification_time_ms_);
return; return;
} }
...@@ -392,12 +389,12 @@ void File::CaptureSnapshot(uint64_t& snapshot_size, ...@@ -392,12 +389,12 @@ void File::CaptureSnapshot(uint64_t& snapshot_size,
FileMetadata metadata; FileMetadata metadata;
if (!HasBackingFile() || !GetFileMetadata(path_, metadata)) { if (!HasBackingFile() || !GetFileMetadata(path_, metadata)) {
snapshot_size = 0; snapshot_size = 0;
snapshot_modification_time_ms = InvalidFileTime(); snapshot_modification_time = base::nullopt;
return; return;
} }
snapshot_size = static_cast<uint64_t>(metadata.length); snapshot_size = static_cast<uint64_t>(metadata.length);
snapshot_modification_time_ms = ToJsTimeOrNaN(metadata.modification_time); snapshot_modification_time = metadata.modification_time;
} }
void File::AppendTo(BlobData& blob_data) const { void File::AppendTo(BlobData& blob_data) const {
...@@ -409,10 +406,10 @@ void File::AppendTo(BlobData& blob_data) const { ...@@ -409,10 +406,10 @@ void File::AppendTo(BlobData& blob_data) const {
// FIXME: This involves synchronous file operation. We need to figure out how // FIXME: This involves synchronous file operation. We need to figure out how
// to make it asynchronous. // to make it asynchronous.
uint64_t size; uint64_t size;
double modification_time_ms; base::Optional<base::Time> modification_time;
CaptureSnapshot(size, modification_time_ms); CaptureSnapshot(size, modification_time);
DCHECK(!path_.IsEmpty()); DCHECK(!path_.IsEmpty());
blob_data.AppendFile(path_, 0, size, modification_time_ms / kMsPerSecond); blob_data.AppendFile(path_, 0, size, modification_time);
} }
bool File::HasSameSource(const File& other) const { bool File::HasSameSource(const File& other) const {
......
...@@ -219,8 +219,9 @@ class CORE_EXPORT File final : public Blob { ...@@ -219,8 +219,9 @@ class CORE_EXPORT File final : public Blob {
// Note that this involves synchronous file operation. Think twice before // Note that this involves synchronous file operation. Think twice before
// calling this function. // calling this function.
void CaptureSnapshot(uint64_t& snapshot_size, void CaptureSnapshot(
double& snapshot_modification_time_ms) const; uint64_t& snapshot_size,
base::Optional<base::Time>& snapshot_modification_time) const;
// Returns true if this has a valid snapshot metadata // Returns true if this has a valid snapshot metadata
// (i.e. m_snapshotSize >= 0). // (i.e. m_snapshotSize >= 0).
......
...@@ -575,7 +575,7 @@ void FileSystemDispatcher::DidCreateSnapshotFile( ...@@ -575,7 +575,7 @@ void FileSystemDispatcher::DidCreateSnapshotFile(
auto blob_data = std::make_unique<BlobData>(); auto blob_data = std::make_unique<BlobData>();
blob_data->AppendFile(file_metadata.platform_path, 0, file_metadata.length, blob_data->AppendFile(file_metadata.platform_path, 0, file_metadata.length,
InvalidFileTime()); base::nullopt);
scoped_refptr<BlobDataHandle> snapshot_blob = scoped_refptr<BlobDataHandle> snapshot_blob =
BlobDataHandle::Create(std::move(blob_data), file_metadata.length); BlobDataHandle::Create(std::move(blob_data), file_metadata.length);
......
...@@ -120,24 +120,23 @@ std::unique_ptr<BlobData> BlobData::CreateForFileWithUnknownSize( ...@@ -120,24 +120,23 @@ std::unique_ptr<BlobData> BlobData::CreateForFileWithUnknownSize(
std::unique_ptr<BlobData> BlobData::CreateForFileWithUnknownSize( std::unique_ptr<BlobData> BlobData::CreateForFileWithUnknownSize(
const String& path, const String& path,
double expected_modification_time) { const base::Optional<base::Time>& expected_modification_time) {
std::unique_ptr<BlobData> data = base::WrapUnique( std::unique_ptr<BlobData> data = base::WrapUnique(
new BlobData(FileCompositionStatus::SINGLE_UNKNOWN_SIZE_FILE)); new BlobData(FileCompositionStatus::SINGLE_UNKNOWN_SIZE_FILE));
data->elements_.push_back(DataElement::NewFile(DataElementFile::New( data->elements_.push_back(DataElement::NewFile(
WebStringToFilePath(path), 0, BlobData::kToEndOfFile, DataElementFile::New(WebStringToFilePath(path), 0, BlobData::kToEndOfFile,
base::Time::FromDoubleT(expected_modification_time)))); expected_modification_time)));
return data; return data;
} }
std::unique_ptr<BlobData> BlobData::CreateForFileSystemURLWithUnknownSize( std::unique_ptr<BlobData> BlobData::CreateForFileSystemURLWithUnknownSize(
const KURL& file_system_url, const KURL& file_system_url,
double expected_modification_time) { const base::Optional<base::Time>& expected_modification_time) {
std::unique_ptr<BlobData> data = base::WrapUnique( std::unique_ptr<BlobData> data = base::WrapUnique(
new BlobData(FileCompositionStatus::SINGLE_UNKNOWN_SIZE_FILE)); new BlobData(FileCompositionStatus::SINGLE_UNKNOWN_SIZE_FILE));
data->elements_.push_back( data->elements_.push_back(DataElement::NewFileFilesystem(
DataElement::NewFileFilesystem(DataElementFilesystemURL::New( DataElementFilesystemURL::New(file_system_url, 0, BlobData::kToEndOfFile,
file_system_url, 0, BlobData::kToEndOfFile, expected_modification_time)));
base::Time::FromDoubleT(expected_modification_time))));
return data; return data;
} }
...@@ -162,10 +161,11 @@ void BlobData::AppendData(scoped_refptr<RawData> data) { ...@@ -162,10 +161,11 @@ void BlobData::AppendData(scoped_refptr<RawData> data) {
AppendDataInternal(base::make_span(data->data(), data->length()), data); AppendDataInternal(base::make_span(data->data(), data->length()), data);
} }
void BlobData::AppendFile(const String& path, void BlobData::AppendFile(
int64_t offset, const String& path,
int64_t length, int64_t offset,
double expected_modification_time) { int64_t length,
const base::Optional<base::Time>& expected_modification_time) {
DCHECK_EQ(file_composition_, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) DCHECK_EQ(file_composition_, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES)
<< "Blobs with a unknown-size file cannot have other items."; << "Blobs with a unknown-size file cannot have other items.";
DCHECK_NE(length, BlobData::kToEndOfFile) DCHECK_NE(length, BlobData::kToEndOfFile)
...@@ -177,8 +177,7 @@ void BlobData::AppendFile(const String& path, ...@@ -177,8 +177,7 @@ void BlobData::AppendFile(const String& path,
if (length == 0) if (length == 0)
return; return;
elements_.push_back(DataElement::NewFile(DataElementFile::New( elements_.push_back(DataElement::NewFile(DataElementFile::New(
WebStringToFilePath(path), offset, length, WebStringToFilePath(path), offset, length, expected_modification_time)));
base::Time::FromDoubleT(expected_modification_time))));
} }
void BlobData::AppendBlob(scoped_refptr<BlobDataHandle> data_handle, void BlobData::AppendBlob(scoped_refptr<BlobDataHandle> data_handle,
...@@ -195,10 +194,11 @@ void BlobData::AppendBlob(scoped_refptr<BlobDataHandle> data_handle, ...@@ -195,10 +194,11 @@ void BlobData::AppendBlob(scoped_refptr<BlobDataHandle> data_handle,
DataElementBlob::New(data_handle->CloneBlobRemote(), offset, length))); DataElementBlob::New(data_handle->CloneBlobRemote(), offset, length)));
} }
void BlobData::AppendFileSystemURL(const KURL& url, void BlobData::AppendFileSystemURL(
int64_t offset, const KURL& url,
int64_t length, int64_t offset,
double expected_modification_time) { int64_t length,
const base::Optional<base::Time>& expected_modification_time) {
DCHECK_EQ(file_composition_, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES) DCHECK_EQ(file_composition_, FileCompositionStatus::NO_UNKNOWN_SIZE_FILES)
<< "Blobs with a unknown-size file cannot have other items."; << "Blobs with a unknown-size file cannot have other items.";
// Skip zero-byte items, as they don't matter for the contents of the blob. // Skip zero-byte items, as they don't matter for the contents of the blob.
...@@ -206,8 +206,7 @@ void BlobData::AppendFileSystemURL(const KURL& url, ...@@ -206,8 +206,7 @@ void BlobData::AppendFileSystemURL(const KURL& url,
return; return;
elements_.push_back( elements_.push_back(
DataElement::NewFileFilesystem(DataElementFilesystemURL::New( DataElement::NewFileFilesystem(DataElementFilesystemURL::New(
url, offset, length, url, offset, length, expected_modification_time)));
base::Time::FromDoubleT(expected_modification_time))));
} }
void BlobData::AppendText(const String& text, void BlobData::AppendText(const String& text,
......
...@@ -113,10 +113,10 @@ class PLATFORM_EXPORT BlobData { ...@@ -113,10 +113,10 @@ class PLATFORM_EXPORT BlobData {
const String& path); const String& path);
static std::unique_ptr<BlobData> CreateForFileWithUnknownSize( static std::unique_ptr<BlobData> CreateForFileWithUnknownSize(
const String& path, const String& path,
double expected_modification_time); const base::Optional<base::Time>& expected_modification_time);
static std::unique_ptr<BlobData> CreateForFileSystemURLWithUnknownSize( static std::unique_ptr<BlobData> CreateForFileSystemURLWithUnknownSize(
const KURL& file_system_url, const KURL& file_system_url,
double expected_modification_time); const base::Optional<base::Time>& expected_modification_time);
// Detaches from current thread so that it can be passed to another thread. // Detaches from current thread so that it can be passed to another thread.
void DetachFromCurrentThread(); void DetachFromCurrentThread();
...@@ -134,17 +134,18 @@ class PLATFORM_EXPORT BlobData { ...@@ -134,17 +134,18 @@ class PLATFORM_EXPORT BlobData {
void AppendFile(const String& path, void AppendFile(const String& path,
int64_t offset, int64_t offset,
int64_t length, int64_t length,
double expected_modification_time); const base::Optional<base::Time>& expected_modification_time);
// The given blob must not be a file with unknown size. Please use the // The given blob must not be a file with unknown size. Please use the
// File::appendTo instead. // File::appendTo instead.
void AppendBlob(scoped_refptr<BlobDataHandle>, void AppendBlob(scoped_refptr<BlobDataHandle>,
int64_t offset, int64_t offset,
int64_t length); int64_t length);
void AppendFileSystemURL(const KURL&, void AppendFileSystemURL(
int64_t offset, const KURL&,
int64_t length, int64_t offset,
double expected_modification_time); int64_t length,
const base::Optional<base::Time>& expected_modification_time);
void AppendText(const String&, bool normalize_line_endings_to_native); void AppendText(const String&, bool normalize_line_endings_to_native);
// The value of the size property for a Blob who has this data. // The value of the size property for a Blob who has this data.
......
...@@ -284,8 +284,8 @@ TEST_F(BlobDataHandleTest, CreateFromEmptyElements) { ...@@ -284,8 +284,8 @@ TEST_F(BlobDataHandleTest, CreateFromEmptyElements) {
auto data = std::make_unique<BlobData>(); auto data = std::make_unique<BlobData>();
data->AppendBytes(small_test_data_.data(), 0); data->AppendBytes(small_test_data_.data(), 0);
data->AppendBlob(empty_blob_, 0, 0); data->AppendBlob(empty_blob_, 0, 0);
data->AppendFile("path", 0, 0, 0.0); data->AppendFile("path", 0, 0, base::Time::UnixEpoch());
data->AppendFileSystemURL(NullURL(), 0, 0, 0.0); data->AppendFileSystemURL(NullURL(), 0, 0, base::Time::UnixEpoch());
TestCreateBlob(std::move(data), {}); TestCreateBlob(std::move(data), {});
} }
...@@ -359,18 +359,17 @@ TEST_F(BlobDataHandleTest, CreateFromMergedSmallAndLargeBytes) { ...@@ -359,18 +359,17 @@ TEST_F(BlobDataHandleTest, CreateFromMergedSmallAndLargeBytes) {
} }
TEST_F(BlobDataHandleTest, CreateFromFileAndFileSystemURL) { TEST_F(BlobDataHandleTest, CreateFromFileAndFileSystemURL) {
double timestamp1 = base::Time::Now().ToDoubleT(); base::Time timestamp1 = base::Time::Now();
double timestamp2 = timestamp1 + 1; base::Time timestamp2 = timestamp1 + base::TimeDelta::FromSeconds(1);
KURL url(NullURL(), "http://example.com/"); KURL url(NullURL(), "http://example.com/");
auto data = std::make_unique<BlobData>(); auto data = std::make_unique<BlobData>();
data->AppendFile("path", 4, 32, timestamp1); data->AppendFile("path", 4, 32, timestamp1);
data->AppendFileSystemURL(url, 15, 876, timestamp2); data->AppendFileSystemURL(url, 15, 876, timestamp2);
Vector<ExpectedElement> expected_elements; Vector<ExpectedElement> expected_elements;
expected_elements.push_back(ExpectedElement::File( expected_elements.push_back(ExpectedElement::File("path", 4, 32, timestamp1));
"path", 4, 32, base::Time::FromDoubleT(timestamp1))); expected_elements.push_back(
expected_elements.push_back(ExpectedElement::FileFilesystem( ExpectedElement::FileFilesystem(url, 15, 876, timestamp2));
url, 15, 876, base::Time::FromDoubleT(timestamp2)));
TestCreateBlob(std::move(data), std::move(expected_elements)); TestCreateBlob(std::move(data), std::move(expected_elements));
} }
...@@ -385,11 +384,11 @@ TEST_F(BlobDataHandleTest, CreateFromFileWithUnknownSize) { ...@@ -385,11 +384,11 @@ TEST_F(BlobDataHandleTest, CreateFromFileWithUnknownSize) {
} }
TEST_F(BlobDataHandleTest, CreateFromFilesystemFileWithUnknownSize) { TEST_F(BlobDataHandleTest, CreateFromFilesystemFileWithUnknownSize) {
double timestamp = base::Time::Now().ToDoubleT(); base::Time timestamp = base::Time::Now();
KURL url(NullURL(), "http://example.com/"); KURL url(NullURL(), "http://example.com/");
Vector<ExpectedElement> expected_elements; Vector<ExpectedElement> expected_elements;
expected_elements.push_back(ExpectedElement::FileFilesystem( expected_elements.push_back(
url, 0, uint64_t(-1), base::Time::FromDoubleT(timestamp))); ExpectedElement::FileFilesystem(url, 0, uint64_t(-1), timestamp));
TestCreateBlob( TestCreateBlob(
BlobData::CreateForFileSystemURLWithUnknownSize(url, timestamp), BlobData::CreateForFileSystemURLWithUnknownSize(url, timestamp),
......
...@@ -85,6 +85,22 @@ inline double ToJsTimeOrNaN(base::Optional<base::Time> time) { ...@@ -85,6 +85,22 @@ inline double ToJsTimeOrNaN(base::Optional<base::Time> time) {
return time ? time->ToJsTimeIgnoringNull() : InvalidFileTime(); return time ? time->ToJsTimeIgnoringNull() : InvalidFileTime();
} }
// TODO(crbug.com/988343): Temporary conversion function. This should be
// removed.
inline base::Optional<base::Time> JsTimeToOptionalTime(double ms) {
if (!IsValidFileTime(ms))
return base::nullopt;
return base::Time::FromJsTime(ms);
}
// TODO(crbug.com/988343): Temporary conversion function. This should be
// removed.
inline base::Optional<base::Time> DoubleTToOptionalTime(double ms) {
if (!IsValidFileTime(ms))
return base::nullopt;
return base::Time::FromDoubleT(ms);
}
inline base::Optional<base::Time> NullableTimeToOptionalTime(base::Time time) { inline base::Optional<base::Time> NullableTimeToOptionalTime(base::Time time) {
if (time.is_null()) if (time.is_null())
return base::nullopt; return base::nullopt;
......
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