Bug 1403706 - Remove race conditions in temporary blob - part 7 - Remove TemporaryBlobImpl, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 05 Oct 2017 07:41:43 +0200
changeset 384665 4888323f23616d82416cc4b357e2b6b38b7d508d
parent 384664 1cf438d8a527223b202a4c772fd0133c848406c6
child 384666 f02f92a497027d957a9cc23bbe681bcc34a13549
push id32634
push userkwierso@gmail.com
push dateFri, 06 Oct 2017 19:55:44 +0000
treeherdermozilla-central@2d7b8b5dd174 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1403706
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1403706 - Remove race conditions in temporary blob - part 7 - Remove TemporaryBlobImpl, r=smaug
dom/file/Blob.cpp
dom/file/Blob.h
dom/file/TemporaryBlobImpl.cpp
dom/file/TemporaryBlobImpl.h
dom/file/ipc/IPCBlobUtils.h
dom/file/moz.build
--- a/dom/file/Blob.cpp
+++ b/dom/file/Blob.cpp
@@ -6,17 +6,16 @@
 
 #include "Blob.h"
 #include "File.h"
 #include "MemoryBlobImpl.h"
 #include "mozilla/dom/BlobBinding.h"
 #include "MultipartBlobImpl.h"
 #include "nsIInputStream.h"
 #include "nsPIDOMWindow.h"
-#include "TemporaryBlobImpl.h"
 #include "StreamBlobImpl.h"
 #include "StringBlobImpl.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Blob)
 
@@ -89,27 +88,16 @@ Blob::CreateMemoryBlob(nsISupports* aPar
                        uint64_t aLength, const nsAString& aContentType)
 {
   RefPtr<Blob> blob = Blob::Create(aParent,
     new MemoryBlobImpl(aMemoryBuffer, aLength, aContentType));
   MOZ_ASSERT(!blob->mImpl->IsFile());
   return blob.forget();
 }
 
-/* static */ already_AddRefed<Blob>
-Blob::CreateTemporaryBlob(nsISupports* aParent, PRFileDesc* aFD,
-                          uint64_t aStartPos, uint64_t aLength,
-                          const nsAString& aContentType)
-{
-  RefPtr<Blob> blob = Blob::Create(aParent,
-    new TemporaryBlobImpl(aFD, aStartPos, aLength, aContentType));
-  MOZ_ASSERT(!blob->mImpl->IsFile());
-  return blob.forget();
-}
-
 Blob::Blob(nsISupports* aParent, BlobImpl* aImpl)
   : mImpl(aImpl)
   , mParent(aParent)
 {
   MOZ_ASSERT(mImpl);
 
 #ifdef DEBUG
   {
--- a/dom/file/Blob.h
+++ b/dom/file/Blob.h
@@ -54,21 +54,16 @@ public:
 
   // The returned Blob takes ownership of aMemoryBuffer. aMemoryBuffer will be
   // freed by free so it must be allocated by malloc or something
   // compatible with it.
   static already_AddRefed<Blob>
   CreateMemoryBlob(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
                    const nsAString& aContentType);
 
-  static already_AddRefed<Blob>
-  CreateTemporaryBlob(nsISupports* aParent, PRFileDesc* aFD,
-                      uint64_t aStartPos, uint64_t aLength,
-                      const nsAString& aContentType);
-
   BlobImpl* Impl() const
   {
     return mImpl;
   }
 
   bool IsFile() const;
 
   const nsTArray<RefPtr<BlobImpl>>* GetSubBlobImpls() const;
deleted file mode 100644
--- a/dom/file/TemporaryBlobImpl.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TemporaryBlobImpl.h"
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_ISUPPORTS_INHERITED0(TemporaryBlobImpl, BlobImpl)
-
-TemporaryBlobImpl::TemporaryBlobImpl(PRFileDesc* aFD, uint64_t aStartPos,
-                                     uint64_t aLength,
-                                     const nsAString& aContentType)
-  : BaseBlobImpl(aContentType, aLength)
-  , mStartPos(aStartPos)
-{
-  mFileDescOwner = new nsTemporaryFileInputStream::FileDescOwner(aFD);
-}
-
-TemporaryBlobImpl::TemporaryBlobImpl(const TemporaryBlobImpl* aOther,
-                                     uint64_t aStart, uint64_t aLength,
-                                     const nsAString& aContentType)
-  : BaseBlobImpl(aContentType, aLength)
-  , mStartPos(aStart)
-  , mFileDescOwner(aOther->mFileDescOwner)
-{}
-
-already_AddRefed<BlobImpl>
-TemporaryBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength,
-                               const nsAString& aContentType,
-                               ErrorResult& aRv)
-{
-  if (aStart + aLength > mLength) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-
-  RefPtr<BlobImpl> impl =
-    new TemporaryBlobImpl(this, aStart + mStartPos,
-                              aLength, aContentType);
-  return impl.forget();
-}
-
-void
-TemporaryBlobImpl::CreateInputStream(nsIInputStream** aStream,
-                                     ErrorResult& aRv)
-{
-  nsCOMPtr<nsIInputStream> stream =
-    new nsTemporaryFileInputStream(mFileDescOwner, mStartPos,
-                                   mStartPos + mLength);
-  stream.forget(aStream);
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/file/TemporaryBlobImpl.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_TemporaryBlobImpl_h
-#define mozilla_dom_TemporaryBlobImpl_h
-
-#include "BaseBlobImpl.h"
-#include "nsTemporaryFileInputStream.h"
-
-namespace mozilla {
-namespace dom {
-
-class TemporaryBlobImpl final : public BaseBlobImpl
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  TemporaryBlobImpl(PRFileDesc* aFD, uint64_t aStartPos,
-                   uint64_t aLength, const nsAString& aContentType);
-
-  virtual void CreateInputStream(nsIInputStream** aStream,
-                                 ErrorResult& aRv) override;
-
-  virtual already_AddRefed<BlobImpl>
-  CreateSlice(uint64_t aStart, uint64_t aLength,
-              const nsAString& aContentType, ErrorResult& aRv) override;
-
-private:
-  TemporaryBlobImpl(const TemporaryBlobImpl* aOther,
-                    uint64_t aStart, uint64_t aLength,
-                    const nsAString& aContentType);
-
-  ~TemporaryBlobImpl() = default;
-
-  uint64_t mStartPos;
-  RefPtr<nsTemporaryFileInputStream::FileDescOwner> mFileDescOwner;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_TemporaryBlobImpl_h
--- a/dom/file/ipc/IPCBlobUtils.h
+++ b/dom/file/ipc/IPCBlobUtils.h
@@ -28,17 +28,16 @@
  * properties (size, type, name if it's a file) and the nsIInputStream.
  *
  * Before talking about the nsIInputStream it's important to say that we have
  * different kinds of Blobs, based on the different kinds of sources. A non
  * exaustive list is:
  * - a memory buffer: MemoryBlobImpl
  * - a string: StringBlobImpl
  * - a real OS file: FileBlobImpl
- * - a temporary OS file: TemporaryBlobImpl
  * - a generic nsIInputStream: StreamBlobImpl
  * - an empty blob: EmptyBlobImpl
  * - more blobs combined together: MultipartBlobImpl
  * Each one of these implementations has a custom ::CreateInputStream method.
  * So, basically, each one has a different kind of nsIInputStream (nsFileStream,
  * nsIStringInputStream, SlicedInputStream, and so on).
  *
  * Another important point to keep in mind is that a Blob can be created on the
--- a/dom/file/moz.build
+++ b/dom/file/moz.build
@@ -52,17 +52,16 @@ UNIFIED_SOURCES += [
     'MemoryBlobImpl.cpp',
     'MultipartBlobImpl.cpp',
     'MutableBlobStorage.cpp',
     'MutableBlobStreamListener.cpp',
     'nsHostObjectProtocolHandler.cpp',
     'nsHostObjectURI.cpp',
     'StreamBlobImpl.cpp',
     'StringBlobImpl.cpp',
-    'TemporaryBlobImpl.cpp',
     'TemporaryFileBlobImpl.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/file/ipc',
     '/dom/workers',
 ]