mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1535397 - Part 3 - use native Maybe syntax in place of FileRequestSize and FileRequestLastModified in IDPL; r=baku
Differential Revision: https://phabricator.services.mozilla.com/D23560 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
eb509085f9
commit
e226477611
@ -1988,9 +1988,9 @@ nsresult GetMetadataOp::DoFileWork(FileHandle* aFileHandle) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mMetadata.size() = uint64_t(size);
|
||||
mMetadata.size() = Some(uint64_t(size));
|
||||
} else {
|
||||
mMetadata.size() = void_t();
|
||||
mMetadata.size() = Nothing();
|
||||
}
|
||||
|
||||
if (mParams.lastModified()) {
|
||||
@ -2000,9 +2000,9 @@ nsresult GetMetadataOp::DoFileWork(FileHandle* aFileHandle) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
mMetadata.lastModified() = lastModified;
|
||||
mMetadata.lastModified() = Some(lastModified);
|
||||
} else {
|
||||
mMetadata.lastModified() = void_t();
|
||||
mMetadata.lastModified() = Nothing();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -11,22 +11,10 @@ using struct mozilla::void_t
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
union FileRequestSize
|
||||
{
|
||||
void_t;
|
||||
uint64_t;
|
||||
};
|
||||
|
||||
union FileRequestLastModified
|
||||
{
|
||||
void_t;
|
||||
int64_t;
|
||||
};
|
||||
|
||||
struct FileRequestMetadata
|
||||
{
|
||||
FileRequestSize size;
|
||||
FileRequestLastModified lastModified;
|
||||
uint64_t? size;
|
||||
int64_t? lastModified;
|
||||
};
|
||||
|
||||
struct FileRequestGetMetadataResponse
|
||||
|
@ -1224,24 +1224,19 @@ class MOZ_STACK_CLASS FileHandleResultHelper final
|
||||
return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
const FileRequestSize& size = aMetadata->size();
|
||||
if (size.type() != FileRequestSize::Tvoid_t) {
|
||||
MOZ_ASSERT(size.type() == FileRequestSize::Tuint64_t);
|
||||
|
||||
JS::Rooted<JS::Value> number(aCx, JS_NumberValue(size.get_uint64_t()));
|
||||
const Maybe<uint64_t>& size = aMetadata->size();
|
||||
if (size.isSome()) {
|
||||
JS::Rooted<JS::Value> number(aCx, JS_NumberValue(size.value()));
|
||||
|
||||
if (NS_WARN_IF(!JS_DefineProperty(aCx, obj, "size", number, 0))) {
|
||||
return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
const FileRequestLastModified& lastModified = aMetadata->lastModified();
|
||||
if (lastModified.type() != FileRequestLastModified::Tvoid_t) {
|
||||
MOZ_ASSERT(lastModified.type() == FileRequestLastModified::Tint64_t);
|
||||
|
||||
const Maybe<int64_t>& lastModified = aMetadata->lastModified();
|
||||
if (lastModified.isSome()) {
|
||||
JS::Rooted<JSObject*> date(
|
||||
aCx,
|
||||
JS::NewDateObject(aCx, JS::TimeClip(lastModified.get_int64_t())));
|
||||
aCx, JS::NewDateObject(aCx, JS::TimeClip(lastModified.value())));
|
||||
if (NS_WARN_IF(!date)) {
|
||||
return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
|
||||
}
|
||||
@ -1265,15 +1260,15 @@ already_AddRefed<File> ConvertActorToFile(
|
||||
|
||||
const FileRequestMetadata& metadata = aResponse.metadata();
|
||||
|
||||
const FileRequestSize& size = metadata.size();
|
||||
MOZ_ASSERT(size.type() == FileRequestSize::Tuint64_t);
|
||||
const Maybe<uint64_t>& size = metadata.size();
|
||||
MOZ_ASSERT(size.isSome());
|
||||
|
||||
const FileRequestLastModified& lastModified = metadata.lastModified();
|
||||
MOZ_ASSERT(lastModified.type() == FileRequestLastModified::Tint64_t);
|
||||
const Maybe<int64_t>& lastModified = metadata.lastModified();
|
||||
MOZ_ASSERT(lastModified.isSome());
|
||||
|
||||
RefPtr<BlobImpl> blobImpl = actor->SetPendingInfoAndDeleteActor(
|
||||
mutableFile->Name(), mutableFile->Type(), size.get_uint64_t(),
|
||||
lastModified.get_int64_t());
|
||||
mutableFile->Name(), mutableFile->Type(), size.value(),
|
||||
lastModified.value());
|
||||
MOZ_ASSERT(blobImpl);
|
||||
|
||||
RefPtr<BlobImpl> blobImplSnapshot =
|
||||
|
Loading…
Reference in New Issue
Block a user