Skip to content

Commit

Permalink
Bug 1333077 - Remove 'temporary' attribute in File, r=qdot
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulf committed Jan 24, 2017
1 parent c238192 commit 6cda1f7
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 120 deletions.
2 changes: 1 addition & 1 deletion dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7826,7 +7826,7 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
continue;
}

blobImpl = new BlobImplFile(file, false);
blobImpl = new BlobImplFile(file);
ErrorResult rv;
// Ensure that file data is cached no that the content process
// has this data available to it when passed over:
Expand Down
1 change: 0 additions & 1 deletion dom/base/test/chrome/chrome.ini
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ support-files = ../file_bug357450.js
[test_registerElement_ep.xul]
[test_domparsing.xul]
[test_fileconstructor.xul]
[test_fileconstructor_tempfile.xul]
[test_nsITextInputProcessor.xul]
[test_range_getClientRectsAndTexts.html]
[test_title.xul]
Expand Down
93 changes: 0 additions & 93 deletions dom/base/test/chrome/test_fileconstructor_tempfile.xul

This file was deleted.

4 changes: 2 additions & 2 deletions dom/file/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ File::CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer,
}

/* static */ already_AddRefed<File>
File::CreateFromFile(nsISupports* aParent, nsIFile* aFile, bool aTemporary)
File::CreateFromFile(nsISupports* aParent, nsIFile* aFile)
{
RefPtr<File> file = new File(aParent, new BlobImplFile(aFile, aTemporary));
RefPtr<File> file = new File(aParent, new BlobImplFile(aFile));
return file.forget();
}

Expand Down
24 changes: 3 additions & 21 deletions dom/file/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class File final : public Blob
// Would be nice if we try to avoid to use this method outside the
// main-thread to avoid extra runnables.
static already_AddRefed<File>
CreateFromFile(nsISupports* aParent, nsIFile* aFile, bool aTemporary = false);
CreateFromFile(nsISupports* aParent, nsIFile* aFile);

static already_AddRefed<File>
CreateFromFile(nsISupports* aParent, nsIFile* aFile, const nsAString& aName,
Expand Down Expand Up @@ -676,11 +676,10 @@ class BlobImplFile : public BlobImplBase
NS_DECL_ISUPPORTS_INHERITED

// Create as a file
explicit BlobImplFile(nsIFile* aFile, bool aTemporary = false)
explicit BlobImplFile(nsIFile* aFile)
: BlobImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX)
, mFile(aFile)
, mWholeFile(true)
, mIsTemporary(aTemporary)
{
MOZ_ASSERT(mFile, "must have file");
// Lazily get the content type and size
Expand All @@ -694,7 +693,6 @@ class BlobImplFile : public BlobImplBase
: BlobImplBase(aName, aContentType, aLength, UINT64_MAX)
, mFile(aFile)
, mWholeFile(true)
, mIsTemporary(false)
{
MOZ_ASSERT(mFile, "must have file");
}
Expand All @@ -705,7 +703,6 @@ class BlobImplFile : public BlobImplBase
: BlobImplBase(aName, aContentType, aLength, aLastModificationDate)
, mFile(aFile)
, mWholeFile(true)
, mIsTemporary(false)
{
MOZ_ASSERT(mFile, "must have file");
}
Expand All @@ -716,7 +713,6 @@ class BlobImplFile : public BlobImplBase
: BlobImplBase(aName, aContentType, UINT64_MAX, INT64_MAX)
, mFile(aFile)
, mWholeFile(true)
, mIsTemporary(false)
{
MOZ_ASSERT(mFile, "must have file");
if (aContentType.IsEmpty()) {
Expand All @@ -742,19 +738,7 @@ class BlobImplFile : public BlobImplBase
virtual bool IsDateUnknown() const override { return false; }

protected:
virtual ~BlobImplFile() {
if (mFile && mIsTemporary) {
NS_WARNING("In temporary ~BlobImplFile");
// Ignore errors if any, not much we can do. Clean-up will be done by
// https://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsAnonymousTemporaryFile.cpp?rev=6c1c7e45c902#127
#ifdef DEBUG
nsresult rv =
#endif
mFile->Remove(false);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"Failed to remove temporary DOMFile.");
}
}
virtual ~BlobImplFile() = default;

private:
// Create slice
Expand All @@ -763,7 +747,6 @@ class BlobImplFile : public BlobImplBase
: BlobImplBase(aContentType, aOther->mStart + aStart, aLength)
, mFile(aOther->mFile)
, mWholeFile(false)
, mIsTemporary(false)
{
MOZ_ASSERT(mFile, "must have file");
mImmutable = aOther->mImmutable;
Expand All @@ -775,7 +758,6 @@ class BlobImplFile : public BlobImplBase

nsCOMPtr<nsIFile> mFile;
bool mWholeFile;
bool mIsTemporary;
};

class EmptyBlobImpl final : public BlobImplBase
Expand Down
2 changes: 1 addition & 1 deletion dom/file/MultipartBlobImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ MultipartBlobImpl::InitializeChromeFile(nsPIDOMWindowInner* aWindow,
aFile->GetLeafName(mName);
}

RefPtr<File> blob = File::CreateFromFile(aWindow, aFile, aBag.mTemporary);
RefPtr<File> blob = File::CreateFromFile(aWindow, aFile);

// Pre-cache size.
blob->GetSize(aRv);
Expand Down
1 change: 0 additions & 1 deletion dom/webidl/File.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dictionary FilePropertyBag {

dictionary ChromeFilePropertyBag : FilePropertyBag {
DOMString name = "";
boolean temporary = false;
};

// Mozilla extensions
Expand Down

0 comments on commit 6cda1f7

Please sign in to comment.