Bug 939509 - File constuctor should use lastModified attribute, r=bz

This commit is contained in:
Andrea Marchesini 2015-02-06 23:35:24 +00:00
parent dff0b85534
commit 98235662c7
2 changed files with 21 additions and 0 deletions

View File

@ -616,6 +616,10 @@ File::Constructor(
}
MOZ_ASSERT(impl->IsFile());
if (aBag.mLastModified.WasPassed()) {
impl->SetLastModified(aBag.mLastModified.Value());
}
nsRefPtr<File> file = new File(aGlobal.GetAsSupports(), impl);
return file.forget();
}
@ -792,6 +796,12 @@ FileImplBase::GetLastModified(ErrorResult& aRv)
return mLastModificationDate / PR_USEC_PER_MSEC;
}
void
FileImplBase::SetLastModified(int64_t aLastModified)
{
mLastModificationDate = aLastModified * PR_USEC_PER_MSEC;
}
int64_t
FileImplBase::GetFileId()
{
@ -1015,6 +1025,12 @@ FileImplFile::GetLastModified(ErrorResult& aRv)
return mLastModificationDate;
}
void
FileImplFile::SetLastModified(int64_t aLastModified)
{
MOZ_CRASH("SetLastModified of a real file is not allowed!");
}
const uint32_t sFileStreamFlags =
nsIFileInputStream::CLOSE_ON_EOF |
nsIFileInputStream::REOPEN_ON_REWIND |

View File

@ -236,6 +236,8 @@ public:
virtual int64_t GetLastModified(ErrorResult& aRv) = 0;
virtual void SetLastModified(int64_t aLastModified) = 0;
virtual void GetMozFullPath(nsAString& aName, ErrorResult& aRv) = 0;
virtual void GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) = 0;
@ -362,6 +364,8 @@ public:
virtual int64_t GetLastModified(ErrorResult& aRv) MOZ_OVERRIDE;
virtual void SetLastModified(int64_t aLastModified) MOZ_OVERRIDE;
virtual void GetMozFullPath(nsAString& aName, ErrorResult& aRv) MOZ_OVERRIDE;
virtual void GetMozFullPathInternal(nsAString& aFileName,
@ -738,6 +742,7 @@ public:
virtual uint64_t GetSize(ErrorResult& aRv) MOZ_OVERRIDE;
virtual void GetType(nsAString& aType) MOZ_OVERRIDE;
virtual int64_t GetLastModified(ErrorResult& aRv) MOZ_OVERRIDE;
virtual void SetLastModified(int64_t aLastModified) MOZ_OVERRIDE;
virtual void GetMozFullPathInternal(nsAString& aFullPath,
ErrorResult& aRv) MOZ_OVERRIDE;
virtual nsresult GetInternalStream(nsIInputStream**) MOZ_OVERRIDE;