Bug 953425 - Part a: Store bools directly in MetadataParameters; r=janv

This commit is contained in:
Ms2ger 2014-01-20 08:58:24 +01:00
Родитель 0f553f3383
Коммит 47fc8d091f
3 изменённых файлов: 21 добавлений и 27 удалений

Просмотреть файл

@ -151,8 +151,7 @@ FileHandle::GetFile(ErrorResult& aError)
nsRefPtr<FileRequest> request =
FileRequest::Create(GetOwner(), lockedFile, false);
nsRefPtr<MetadataParameters> params = new MetadataParameters();
params->Init(true, false);
nsRefPtr<MetadataParameters> params = new MetadataParameters(true, false);
nsRefPtr<GetFileHelper> helper =
new GetFileHelper(lockedFile, request, params, this);

Просмотреть файл

@ -541,19 +541,23 @@ LockedFile::GetMetadata(JS::Handle<JS::Value> aParameters,
return NS_OK;
}
nsRefPtr<MetadataParameters> params = new MetadataParameters();
// Get optional arguments.
bool size, lastModified;
if (!JSVAL_IS_VOID(aParameters) && !JSVAL_IS_NULL(aParameters)) {
nsresult rv = params->Init(aCx, aParameters);
idl::DOMFileMetadataParameters config;
nsresult rv = config.Init(aCx, aParameters.address());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
if (!params->IsConfigured()) {
return NS_ERROR_TYPE_ERR;
}
size = config.size;
lastModified = config.lastModified;
}
else {
params->Init(true, true);
size = lastModified = true;
}
nsRefPtr<MetadataParameters> params =
new MetadataParameters(size, lastModified);
if (!params->IsConfigured()) {
return NS_ERROR_TYPE_ERR;
}
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();

Просмотреть файл

@ -12,8 +12,6 @@
#include "nsIFileStreams.h"
#include "DictionaryHelpers.h"
#include "AsyncHelper.h"
#include "FileHelper.h"
@ -30,35 +28,28 @@ class MetadataParameters
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MetadataParameters)
nsresult
Init(JSContext* aCx, JS::Handle<JS::Value> aVal)
MetadataParameters(bool aSizeRequested, bool aLastModifiedRequested)
: mSizeRequested(aSizeRequested)
, mLastModifiedRequested(aLastModifiedRequested)
{
return mConfig.Init(aCx, aVal.address());
}
void
Init(bool aRequestSize, bool aRequestLastModified)
{
mConfig.size = aRequestSize;
mConfig.lastModified = aRequestLastModified;
}
bool
IsConfigured() const
{
return mConfig.size || mConfig.lastModified;
return mSizeRequested || mLastModifiedRequested;
}
bool
SizeRequested() const
{
return mConfig.size;
return mSizeRequested;
}
bool
LastModifiedRequested() const
{
return mConfig.lastModified;
return mLastModifiedRequested;
}
uint64_t
@ -74,10 +65,10 @@ public:
}
private:
mozilla::idl::DOMFileMetadataParameters mConfig;
uint64_t mSize;
int64_t mLastModified;
bool mSizeRequested;
bool mLastModifiedRequested;
};
class MetadataHelper : public FileHelper