Bug 1159401 - patch 2 - Avoid multiple inheritance of nsIDOMBlob, r=bz
☠☠ backed out by 86efbb9287a4 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 11 May 2015 18:50:52 +0100
changeset 243271 adfee1efb1e19048d713d2e5c340038786690367
parent 243270 70c63c8546e37c369faf303912197b2208d23419
child 243272 56e4c68dc3dad5701658799c543f5ebfafbb976d
push id59630
push useramarchesini@mozilla.com
push dateMon, 11 May 2015 17:51:15 +0000
treeherdermozilla-inbound@37b877eb0834 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1159401
milestone40.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 1159401 - patch 2 - Avoid multiple inheritance of nsIDOMBlob, r=bz
dom/base/nsIDOMFile.idl
dom/bluetooth/bluedroid/BluetoothOppManager.cpp
dom/bluetooth/bluetooth1/BluetoothAdapter.cpp
dom/bluetooth/bluetooth1/BluetoothAdapter.h
dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
dom/bluetooth/bluetooth2/BluetoothAdapter.h
dom/camera/TestGonkCameraHardware.cpp
dom/media/imagecapture/ImageCapture.cpp
dom/media/webrtc/MediaEngine.h
dom/media/webrtc/MediaEngineGonkVideoSource.cpp
--- a/dom/base/nsIDOMFile.idl
+++ b/dom/base/nsIDOMFile.idl
@@ -49,18 +49,22 @@ interface nsIDOMBlob : nsISupports
   // Called before the blob is stored in a database to decide if it can be
   // shared or needs to be copied. It can be called on any thread.
   [notxpcom] FileInfo getFileInfo(in FileManager aFileManager);
 
   // Return true if this blob is a memory file.
   [notxpcom] bool isMemoryFile();
 };
 
-[scriptable, builtinclass, uuid(74657f92-aa61-492b-8649-fd1cca62e255)]
-interface nsIDOMFile : nsIDOMBlob
+// We want to avoid multiple inheritance of nsIDOMBlob so we can downcast from
+// nsIDOMBlob to Blob safely.  Our chain is:
+//  - Blob -> nsIDOMBlob
+//  - File -> nsIDOMFile and Blob
+[scriptable, builtinclass, uuid(cc28cf12-f1d4-44ff-843f-9289aa14613b)]
+interface nsIDOMFile : nsISupports
 {
   readonly attribute DOMString name;
 
   readonly attribute DOMString path;
 
   [implicit_jscontext]
   readonly attribute jsval lastModifiedDate;
 
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
@@ -408,17 +408,17 @@ BluetoothOppManager::StartSendingNextFil
 
 bool
 BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
                               BlobParent* aActor)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsRefPtr<FileImpl> impl = aActor->GetBlobImpl();
-  nsCOMPtr<nsIDOMBlob> blob = new File(nullptr, impl);
+  nsRefPtr<Blob> blob = Blob::Create(nullptr, impl);
 
   return SendFile(aDeviceAddress, blob.get());
 }
 
 bool
 BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
                               nsIDOMBlob* aBlob)
 {
--- a/dom/bluetooth/bluetooth1/BluetoothAdapter.cpp
+++ b/dom/bluetooth/bluetooth1/BluetoothAdapter.cpp
@@ -761,17 +761,17 @@ BluetoothAdapter::IsConnected(const uint
   }
   bs->IsConnected(aServiceUuid, results);
 
   return request.forget();
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
-                           File& aBlob, ErrorResult& aRv)
+                           Blob& aBlob, ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
--- a/dom/bluetooth/bluetooth1/BluetoothAdapter.h
+++ b/dom/bluetooth/bluetooth1/BluetoothAdapter.h
@@ -10,17 +10,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "BluetoothCommon.h"
 #include "BluetoothPropertyContainer.h"
 #include "nsCOMPtr.h"
 
 namespace mozilla {
 namespace dom {
-class File;
+class Blob;
 class DOMRequest;
 struct MediaMetaData;
 struct MediaPlayStatus;
 }
 }
 
 BEGIN_BLUETOOTH_NAMESPACE
 
@@ -129,17 +129,17 @@ public:
   already_AddRefed<DOMRequest>
     IsConnected(const uint16_t aServiceUuid,
                 ErrorResult& aRv);
 
   already_AddRefed<DOMRequest>
     GetConnectedDevices(uint16_t aServiceUuid, ErrorResult& aRv);
 
   already_AddRefed<DOMRequest>
-    SendFile(const nsAString& aDeviceAddress, File& aBlob,
+    SendFile(const nsAString& aDeviceAddress, Blob& aBlob,
              ErrorResult& aRv);
   already_AddRefed<DOMRequest>
     StopSendingFile(const nsAString& aDeviceAddress, ErrorResult& aRv);
   already_AddRefed<DOMRequest>
     ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirmation,
                          ErrorResult& aRv);
 
   already_AddRefed<DOMRequest> ConnectSco(ErrorResult& aRv);
--- a/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
+++ b/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
@@ -1256,17 +1256,17 @@ BluetoothAdapter::Disconnect(BluetoothDe
   }
   bs->Disconnect(address, serviceUuid, results);
 
   return request.forget();
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
-                           File& aBlob, ErrorResult& aRv)
+                           Blob& aBlob, ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
--- a/dom/bluetooth/bluetooth2/BluetoothAdapter.h
+++ b/dom/bluetooth/bluetooth2/BluetoothAdapter.h
@@ -12,18 +12,18 @@
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/BluetoothAdapter2Binding.h"
 #include "mozilla/dom/BluetoothDeviceEvent.h"
 #include "mozilla/dom/Promise.h"
 #include "nsCOMPtr.h"
 
 namespace mozilla {
 namespace dom {
+class Blob;
 class DOMRequest;
-class File;
 struct MediaMetaData;
 struct MediaPlayStatus;
 }
 }
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothDevice;
@@ -127,17 +127,17 @@ public:
     Disconnect(BluetoothDevice& aDevice,
                const Optional<short unsigned int>& aServiceUuid,
                ErrorResult& aRv);
   already_AddRefed<DOMRequest> GetConnectedDevices(uint16_t aServiceUuid,
                                                    ErrorResult& aRv);
 
   // OPP file transfer related methods
   already_AddRefed<DOMRequest> SendFile(const nsAString& aDeviceAddress,
-                                        File& aBlob,
+                                        Blob& aBlob,
                                         ErrorResult& aRv);
   already_AddRefed<DOMRequest> StopSendingFile(const nsAString& aDeviceAddress,
                                                ErrorResult& aRv);
   already_AddRefed<DOMRequest>
     ConfirmReceivingFile(const nsAString& aDeviceAddress,
                          bool aConfirmation,
                          ErrorResult& aRv);
 
--- a/dom/camera/TestGonkCameraHardware.cpp
+++ b/dom/camera/TestGonkCameraHardware.cpp
@@ -101,29 +101,29 @@ TestGonkCameraHardwareListener::HandleEv
     }
   } else if (eventType.EqualsLiteral("shutter")) {
     DOM_CAMERA_LOGI("Inject shutter event");
     OnShutter(mTarget);
   } else if (eventType.EqualsLiteral("picture")) {
     BlobEvent* event = aEvent->InternalDOMEvent()->AsBlobEvent();
 
     if (!NS_WARN_IF(!event)) {
-      File* file = event->GetData();
+      Blob* blob = event->GetData();
 
-      if (file) {
+      if (blob) {
         static const uint64_t MAX_FILE_SIZE = 2147483647;
         uint64_t dataLength = 0;
-        nsresult rv = file->GetSize(&dataLength);
+        nsresult rv = blob->GetSize(&dataLength);
 
         if (NS_WARN_IF(NS_FAILED(rv) || dataLength > MAX_FILE_SIZE)) {
           return NS_OK;
         }
 
         nsCOMPtr<nsIInputStream> inputStream;
-        rv = file->GetInternalStream(getter_AddRefs(inputStream));
+        rv = blob->GetInternalStream(getter_AddRefs(inputStream));
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return NS_OK;
         }
 
         uint8_t* data = new uint8_t[dataLength];
         rv = NS_ReadInputStreamToBuffer(inputStream,
                                         reinterpret_cast<void**>(&data),
                                         static_cast<uint32_t>(dataLength));
--- a/dom/media/imagecapture/ImageCapture.cpp
+++ b/dom/media/imagecapture/ImageCapture.cpp
@@ -97,19 +97,19 @@ ImageCapture::TakePhotoByMediaEngine()
       mStream->AddPrincipalChangeObserver(this);
     }
 
     void PrincipalChanged(DOMMediaStream* aMediaStream) override
     {
       mPrincipalChanged = true;
     }
 
-    nsresult PhotoComplete(already_AddRefed<File> aBlob) override
+    nsresult PhotoComplete(already_AddRefed<Blob> aBlob) override
     {
-      nsRefPtr<File> blob = aBlob;
+      nsRefPtr<Blob> blob = aBlob;
 
       if (mPrincipalChanged) {
         return PhotoError(NS_ERROR_DOM_SECURITY_ERR);
       }
       return mImageCapture->PostBlobEvent(blob);
     }
 
     nsresult PhotoError(nsresult aRv) override
--- a/dom/media/webrtc/MediaEngine.h
+++ b/dom/media/webrtc/MediaEngine.h
@@ -1,26 +1,25 @@
 /* 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 MEDIAENGINE_H_
 #define MEDIAENGINE_H_
 
 #include "mozilla/RefPtr.h"
-#include "nsIDOMFile.h"
 #include "DOMMediaStream.h"
 #include "MediaStreamGraph.h"
 #include "mozilla/dom/MediaStreamTrackBinding.h"
 #include "mozilla/dom/VideoStreamTrack.h"
 
 namespace mozilla {
 
 namespace dom {
-class File;
+class Blob;
 }
 
 enum {
   kVideoTrack = 1,
   kAudioTrack = 2,
   kTrackCount
 };
 
@@ -125,17 +124,17 @@ public:
   // Callback interface for TakePhoto(). Either PhotoComplete() or PhotoError()
   // should be called.
   class PhotoCallback {
   public:
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PhotoCallback)
 
     // aBlob is the image captured by MediaEngineSource. It is
     // called on main thread.
-    virtual nsresult PhotoComplete(already_AddRefed<dom::File> aBlob) = 0;
+    virtual nsresult PhotoComplete(already_AddRefed<dom::Blob> aBlob) = 0;
 
     // It is called on main thread. aRv is the error code.
     virtual nsresult PhotoError(nsresult aRv) = 0;
 
   protected:
     virtual ~PhotoCallback() {}
   };
 
--- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
@@ -609,21 +609,21 @@ MediaEngineGonkVideoSource::OnTakePictur
       mCallbacks.SwapElements(aCallbacks);
       mPhotoData = (uint8_t*) malloc(aLength);
       memcpy(mPhotoData, aData, mPhotoDataLength);
       mMimeType = aMimeType;
     }
 
     NS_IMETHOD Run()
     {
-      nsRefPtr<dom::File> blob =
-        dom::File::CreateMemoryFile(nullptr, mPhotoData, mPhotoDataLength, mMimeType);
+      nsRefPtr<dom::Blob> blob =
+        dom::Blob::CreateMemoryBlob(nullptr, mPhotoData, mPhotoDataLength, mMimeType);
       uint32_t callbackCounts = mCallbacks.Length();
       for (uint8_t i = 0; i < callbackCounts; i++) {
-        nsRefPtr<dom::File> tempBlob = blob;
+        nsRefPtr<dom::Blob> tempBlob = blob;
         mCallbacks[i]->PhotoComplete(tempBlob.forget());
       }
       // PhotoCallback needs to dereference on main thread.
       mCallbacks.Clear();
       return NS_OK;
     }
 
     nsTArray<nsRefPtr<PhotoCallback>> mCallbacks;