Bug 1462964: Remove obsolete nsIDOMBlob interface. r=bz

MozReview-Commit-ID: 2HIlaSrvfBe

--HG--
extra : rebase_source : 944a6244dbfe1f0a37dd34a041d1329624a86f93
extra : histedit_source : d7859be664fed00f8504e40969480d3af3d674e7%2C4456b502db338bd06823654306e47c2583101396
This commit is contained in:
Kris Maglione 2018-05-21 17:32:44 -07:00
parent 6b12d08f7d
commit 8134b33e89
33 changed files with 71 additions and 73 deletions

View file

@ -109,7 +109,7 @@ DataTransferItem::KindFromData(nsIVariant* aData)
nsresult rv = aData->GetAsISupports(getter_AddRefs(supports));
if (NS_SUCCEEDED(rv) && supports) {
// Check if we have one of the supported file data formats
if (nsCOMPtr<nsIDOMBlob>(do_QueryInterface(supports)) ||
if (RefPtr<Blob>(do_QueryObject(supports)) ||
nsCOMPtr<BlobImpl>(do_QueryInterface(supports)) ||
nsCOMPtr<nsIFile>(do_QueryInterface(supports))) {
return KIND_FILE;
@ -292,8 +292,7 @@ DataTransferItem::GetAsFile(nsIPrincipal& aSubjectPrincipal,
return nullptr;
}
if (nsCOMPtr<nsIDOMBlob> domBlob = do_QueryInterface(supports)) {
Blob* blob = static_cast<Blob*>(domBlob.get());
if (RefPtr<Blob> blob = do_QueryObject(supports)) {
mCachedFile = blob->ToFile();
} else if (nsCOMPtr<BlobImpl> blobImpl = do_QueryInterface(supports)) {
MOZ_ASSERT(blobImpl->IsFile());

View file

@ -34,8 +34,12 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Blob)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMBlob)
NS_INTERFACE_MAP_ENTRY(nsIDOMBlob)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMutable)
// Alas, there is no helper macro for this.
if (aIID.Equals(NS_GET_IID(Blob))) {
*aInstancePtr = do_AddRef(this).take();
return NS_OK;
} else
NS_INTERFACE_MAP_ENTRY(nsIMutable)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END

View file

@ -13,7 +13,6 @@
#include "mozilla/dom/BlobImpl.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCOMPtr.h"
#include "nsIDOMBlob.h"
#include "nsIMutable.h"
#include "nsWrapperCache.h"
#include "nsWeakReference.h"
@ -27,17 +26,21 @@ struct BlobPropertyBag;
class File;
class OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString;
class Blob : public nsIDOMBlob
, public nsIMutable
#define NS_DOM_BLOB_IID \
{ 0x648c2a83, 0xbdb1, 0x4a7d, \
{ 0xb5, 0x0a, 0xca, 0xcd, 0x92, 0x87, 0x45, 0xc2 } }
class Blob : public nsIMutable
, public nsSupportsWeakReference
, public nsWrapperCache
{
public:
NS_DECL_NSIDOMBLOB
NS_DECL_NSIMUTABLE
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Blob, nsIDOMBlob)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Blob, nsIMutable)
NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOM_BLOB_IID)
typedef OwningArrayBufferViewOrArrayBufferOrBlobOrUSVString BlobPart;
@ -147,6 +150,8 @@ private:
nsCOMPtr<nsISupports> mParent;
};
NS_DEFINE_STATIC_IID_ACCESSOR(Blob, NS_DOM_BLOB_IID)
// Override BindingJSObjectMallocBytes for blobs to tell the JS GC how much
// memory is held live by the binding object.
size_t BindingJSObjectMallocBytes(Blob* aBlob);
@ -154,4 +159,10 @@ size_t BindingJSObjectMallocBytes(Blob* aBlob);
} // namespace dom
} // namespace mozilla
inline nsISupports*
ToSupports(mozilla::dom::Blob* aBlob)
{
return static_cast<nsIMutable*>(aBlob);
}
#endif // mozilla_dom_Blob_h

View file

@ -9,12 +9,6 @@ with Files("**"):
DIRS += ['ipc']
XPIDL_SOURCES += [
'nsIDOMBlob.idl',
]
XPIDL_MODULE = 'dom_file'
EXPORTS += [
'nsHostObjectProtocolHandler.h',
'nsHostObjectURI.h',

View file

@ -1,12 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsISupports.idl"
[scriptable, builtinclass, uuid(f344146a-ee1f-417e-8a68-6984ca56f0ae)]
interface nsIDOMBlob : nsISupports
{
// Just an empty interface.
};

View file

@ -19,8 +19,10 @@
function childFrameScript() {
"use strict";
Cu.importGlobalProperties(["Blob"]);
addMessageListener("test:ipcClonedMessage", function(message) {
if (!(message.json instanceof Ci.nsIDOMBlob)) {
if (!Blob.isInstance(message.json)) {
sendAsyncMessage(message.name, message.json);
return;
}

View file

@ -18,6 +18,7 @@
#include "mozilla/dom/WheelEventBinding.h"
#include "nsAttrValueInlines.h"
#include "nsCRTGlue.h"
#include "nsQueryObject.h"
#include "nsITextControlElement.h"
#include "nsIDOMNSEditableElement.h"
@ -508,7 +509,7 @@ HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
while (NS_SUCCEEDED(iter->HasMoreElements(&hasMore)) && hasMore) {
iter->GetNext(getter_AddRefs(tmp));
nsCOMPtr<nsIDOMBlob> domBlob = do_QueryInterface(tmp);
RefPtr<Blob> domBlob = do_QueryObject(tmp);
MOZ_ASSERT(domBlob,
"Null file object from FilePicker's file enumerator?");
if (!domBlob) {
@ -516,7 +517,7 @@ HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
}
OwningFileOrDirectory* element = newFilesOrDirectories.AppendElement();
element->SetAsFile() = static_cast<File*>(domBlob.get());
element->SetAsFile() = domBlob->ToFile();
}
} else {
MOZ_ASSERT(mode == static_cast<int16_t>(nsIFilePicker::modeOpen) ||
@ -525,9 +526,9 @@ HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
nsresult rv = mFilePicker->GetDomFileOrDirectory(getter_AddRefs(tmp));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(tmp);
RefPtr<Blob> blob = do_QueryObject(tmp);
if (blob) {
RefPtr<File> file = static_cast<Blob*>(blob.get())->ToFile();
RefPtr<File> file = blob->ToFile();
MOZ_ASSERT(file);
OwningFileOrDirectory* element = newFilesOrDirectories.AppendElement();

View file

@ -915,8 +915,7 @@ IDBDatabase::GetOrCreateFileActorForBlob(Blob* aBlob)
// a) it is unique per blob, b) it is reference-counted so that we can
// guarantee that it stays alive, and c) it doesn't hold the actual File
// alive.
nsCOMPtr<nsIDOMBlob> blob = aBlob;
nsCOMPtr<nsIWeakReference> weakRef = do_GetWeakReference(blob);
nsCOMPtr<nsIWeakReference> weakRef = do_GetWeakReference(aBlob);
MOZ_ASSERT(weakRef);
PBackgroundIDBDatabaseFileChild* actor = nullptr;

View file

@ -110,8 +110,8 @@ function verifyBuffers(buffer1, buffer2)
function verifyBlob(blob1, blob2, fileId, blobReadHandler)
{
// eslint-disable-next-line mozilla/use-cc-etc
is(blob1 instanceof Components.interfaces.nsIDOMBlob, true,
"Instance of nsIDOMBlob");
is(SpecialPowers.wrap(Blob).isInstance(blob1), true,
"Instance of Blob");
is(blob1 instanceof File, blob2 instanceof File,
"Instance of DOM File");
is(blob1.size, blob2.size, "Correct size");

View file

@ -25,7 +25,7 @@ function childFrameScript() {
const blobText = blobData.join("");
const blobType = "text/plain";
Cu.importGlobalProperties(["indexedDB"]);
Cu.importGlobalProperties(["indexedDB", "Blob"]);
function info(msg) {
sendAsyncMessage(mmName, { op: "info", msg });
@ -66,7 +66,7 @@ function childFrameScript() {
let blob = message.data;
ok(blob instanceof Ci.nsIDOMBlob, "Message manager sent a blob");
ok(Blob.isInstance(blob), "Message manager sent a blob");
is(blob.size, blobText.length, "Blob has correct length");
is(blob.type, blobType, "Blob has correct type");
@ -82,7 +82,7 @@ function childFrameScript() {
let slice = blob.slice(0, blobData[0].length, blobType);
ok(slice instanceof Ci.nsIDOMBlob, "Slice returned a blob");
ok(Blob.isInstance(slice), "Slice returned a blob");
is(slice.size, blobData[0].length, "Slice has correct length");
is(slice.type, blobType, "Slice has correct type");
@ -143,7 +143,7 @@ function childFrameScript() {
blob = event.target.result;
ok(blob instanceof Ci.nsIDOMBlob, "Database gave us a blob");
ok(Blob.isInstance(blob), "Database gave us a blob");
is(blob.size, blobText.length, "Blob has correct length");
is(blob.type, blobType, "Blob has correct type");
@ -178,7 +178,7 @@ function childFrameScript() {
slice = event.target.result;
ok(slice instanceof Ci.nsIDOMBlob, "Database gave us a blob");
ok(Blob.isInstance(slice), "Database gave us a blob");
is(slice.size, blobData[0].length, "Slice has correct length");
is(slice.type, blobType, "Slice has correct type");

View file

@ -10,6 +10,8 @@ var { "classes": Cc, "interfaces": Ci, "utils": Cu } = Components;
ChromeUtils.import("resource://gre/modules/Services.jsm");
Cu.importGlobalProperties(["Blob"]);
if (!("self" in this)) {
this.self = this;
}
@ -426,7 +428,7 @@ function verifyBuffers(buffer1, buffer2)
function verifyBlob(blob1, blob2)
{
is(blob1 instanceof Ci.nsIDOMBlob, true,
is(Blob.isInstance(blob1), true,
"Instance of nsIDOMBlob");
is(blob1 instanceof File, blob2 instanceof File,
"Instance of DOM File");

View file

@ -6,7 +6,6 @@
#include "domstubs.idl"
interface nsIControllers;
interface nsIDOMBlob;
interface nsIDOMOfflineResourceList;
interface nsIPrompt;
interface nsIVariant;

View file

@ -52,7 +52,7 @@ function childFrameScript() {
let blob = message.data;
ok(blob instanceof Ci.nsIDOMBlob, "Received a Blob");
ok(Blob.isInstance(blob), "Received a Blob");
is(blob.size, blobText.length, "Blob has correct length");
is(blob.type, blobType, "Blob has correct type");
@ -71,7 +71,7 @@ function childFrameScript() {
let slice = blob.slice(firstSliceStart, firstSliceEnd, blobType);
ok(slice instanceof Ci.nsIDOMBlob, "Slice returned a Blob");
ok(Blob.isInstance(slice), "Slice returned a Blob");
is(slice.size, blobData[2].length, "Slice has correct length");
is(slice.type, blobType, "Slice has correct type");
@ -90,7 +90,7 @@ function childFrameScript() {
slice = slice.slice(secondSliceStart, secondSliceEnd, blobType);
ok(slice instanceof Ci.nsIDOMBlob, "Second slice returned a Blob");
ok(Blob.isInstance(slice), "Second slice returned a Blob");
is(slice.size, sliceText.length, "Second slice has correct length");
is(slice.type, blobType, "Second slice has correct type");

View file

@ -26,7 +26,7 @@ interface nsIGetUserMediaDevicesSuccessCallback : nsISupports
interface nsIDOMGetUserMediaSuccessCallback : nsISupports
{
/*
* value must be a nsIDOMBlob if picture is true and a
* value must be a Blob if picture is true and a
* DOMLocalMediaStream if either audio or video are true.
*/
void onSuccess(in nsISupports value);

View file

@ -808,7 +808,7 @@ PresentationService::SendSessionBinaryMsg(const nsAString& aSessionId,
NS_IMETHODIMP
PresentationService::SendSessionBlob(const nsAString& aSessionId,
uint8_t aRole,
nsIDOMBlob* aBlob)
Blob* aBlob)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!aSessionId.IsEmpty());

View file

@ -291,7 +291,7 @@ PresentationSessionInfo::SendBinaryMsg(const nsACString& aData)
}
nsresult
PresentationSessionInfo::SendBlob(nsIDOMBlob* aBlob)
PresentationSessionInfo::SendBlob(Blob* aBlob)
{
if (NS_WARN_IF(!IsSessionReady())) {
return NS_ERROR_DOM_INVALID_STATE_ERR;

View file

@ -102,7 +102,7 @@ public:
nsresult SendBinaryMsg(const nsACString& aData);
nsresult SendBlob(nsIDOMBlob* aBlob);
nsresult SendBlob(Blob* aBlob);
nsresult Close(nsresult aReason,
uint32_t aState);

View file

@ -424,7 +424,7 @@ PresentationTCPSessionTransport::SendBinaryMsg(const nsACString& aData)
}
NS_IMETHODIMP
PresentationTCPSessionTransport::SendBlob(nsIDOMBlob* aBlob)
PresentationTCPSessionTransport::SendBlob(Blob* aBlob)
{
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}

View file

@ -4,7 +4,6 @@
#include "nsISupports.idl"
interface nsIDOMBlob;
interface nsIInputStream;
interface nsIPresentationAvailabilityListener;
interface nsIPresentationRespondingListener;
@ -12,6 +11,7 @@ interface nsIPresentationSessionListener;
interface nsIPresentationTransportBuilderConstructor;
interface nsIPrincipal;
webidl Blob;
webidl EventTarget;
%{C++
@ -120,7 +120,7 @@ interface nsIPresentationService : nsISupports
*/
void sendSessionBlob(in DOMString sessionId,
in uint8_t role,
in nsIDOMBlob blob);
in Blob blob);
/*
* Close the session.

View file

@ -4,10 +4,11 @@
#include "nsISupports.idl"
interface nsIDOMBlob;
interface nsIInputStream;
interface nsINetAddr;
webidl Blob;
%{C++
#define PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID \
"@mozilla.org/presentation/presentationtcpsessiontransport;1"
@ -59,7 +60,7 @@ interface nsIPresentationSessionTransport : nsISupports
* Send the blob to the remote endpoint.
* @param blob: The input blob to be sent.
*/
void sendBlob(in nsIDOMBlob blob);
void sendBlob(in Blob blob);
/*
* Close this session transport.

View file

@ -84,7 +84,7 @@ PresentationSessionTransportIPC::SendBinaryMsg(const nsACString& aData)
}
NS_IMETHODIMP
PresentationSessionTransportIPC::SendBlob(nsIDOMBlob* aBlob)
PresentationSessionTransportIPC::SendBlob(Blob* aBlob)
{
return NS_OK;
}

View file

@ -46,7 +46,7 @@ PresentationContentSessionInfo::SendBinaryMsg(const nsACString& aData)
}
nsresult
PresentationContentSessionInfo::SendBlob(nsIDOMBlob* aBlob)
PresentationContentSessionInfo::SendBlob(Blob* aBlob)
{
if (NS_WARN_IF(!mTransport)) {
return NS_ERROR_NOT_AVAILABLE;

View file

@ -44,7 +44,7 @@ public:
nsresult SendBinaryMsg(const nsACString& aData);
nsresult SendBlob(nsIDOMBlob* aBlob);
nsresult SendBlob(Blob* aBlob);
nsresult Close(nsresult aReason);

View file

@ -129,7 +129,7 @@ PresentationIPCService::SendSessionBinaryMsg(const nsAString& aSessionId,
NS_IMETHODIMP
PresentationIPCService::SendSessionBlob(const nsAString& aSessionId,
uint8_t aRole,
nsIDOMBlob* aBlob)
Blob* aBlob)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!aSessionId.IsEmpty());

View file

@ -1045,7 +1045,7 @@ HTMLEditor::InsertObject(const nsACString& aType,
nsCOMPtr<nsINode> node = do_QueryInterface(aDestinationNode);
MOZ_ASSERT(node);
nsCOMPtr<nsIDOMBlob> domBlob = Blob::Create(node->GetOwnerGlobal(), blob);
RefPtr<Blob> domBlob = Blob::Create(node->GetOwnerGlobal(), blob);
NS_ENSURE_TRUE(domBlob, NS_ERROR_FAILURE);
return utils->SlurpBlob(domBlob, node->OwnerDoc()->GetWindow(), br);

View file

@ -7,9 +7,10 @@
#include "nsISupports.idl"
#include "domstubs.idl"
interface nsIDOMBlob;
interface mozIDOMWindowProxy;
webidl Blob;
[scriptable, builtinclass, uuid(eb8b8ad9-5d8f-43bd-8ce5-5b943c180d56)]
interface nsIEditorBlobListener : nsISupports
{
@ -27,6 +28,6 @@ interface nsIEditorUtils : nsISupports
/**
* Given a blob, returns the data from that blob, asynchronously.
*/
void slurpBlob(in nsIDOMBlob aBlob, in mozIDOMWindowProxy aScope,
void slurpBlob(in Blob aBlob, in mozIDOMWindowProxy aScope,
in nsIEditorBlobListener aListener);
};

View file

@ -11,8 +11,6 @@
#include "mozilla/Attributes.h"
#include "mozilla/ipc/Transport.h"
class nsIDOMBlob;
namespace mozilla {
namespace dom {

View file

@ -49,7 +49,7 @@
if (a instanceof File)
return 'file';
if (a instanceof Ci.nsIDOMBlob)
if (a instanceof Blob)
return 'blob';
if (TypedArrayThings.includes(a.constructor.name))

View file

@ -27,7 +27,7 @@ BlobComponent.prototype =
var f1 = new Blob([testContent], {"type" : "text/xml"});
// do some tests
Assert.ok(f1 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob");
Assert.ok(f1 instanceof Blob, "Should be a DOM Blob");
Assert.ok(!(f1 instanceof File), "Should not be a DOM File");

View file

@ -11,7 +11,7 @@ function run_test() {
var f1 = new Blob([testContent], {"type" : "text/xml"});
// do some tests
Assert.ok(f1 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob");
Assert.ok(f1 instanceof Blob, "Should be a DOM Blob");
Assert.ok(!(f1 instanceof File), "Should not be a DOM File");

View file

@ -69,7 +69,7 @@ var PropertyListUtils = Object.freeze({
/**
* Asynchronously reads a file as a property list.
*
* @param aFile (nsIDOMBlob/nsIFile)
* @param aFile (Blob/nsIFile)
* the file to be read as a property list.
* @param aCallback
* If the property list is read successfully, aPropertyListRoot is set

View file

@ -53,8 +53,7 @@ LocalFileToDirectoryOrBlob(nsPIDOMWindowInner* aWindow,
return NS_OK;
}
nsCOMPtr<nsIDOMBlob> blob = File::CreateFromFile(aWindow, aFile);
blob.forget(aResult);
*aResult = ToSupports(File::CreateFromFile(aWindow, aFile).take());
return NS_OK;
}

View file

@ -207,7 +207,7 @@ nsFilePickerProxy::GetDomFileOrDirectory(nsISupports** aValue)
MOZ_ASSERT(mFilesOrDirectories.Length() == 1);
if (mFilesOrDirectories[0].IsFile()) {
nsCOMPtr<nsIDOMBlob> blob = mFilesOrDirectories[0].GetAsFile().get();
nsCOMPtr<nsISupports> blob = ToSupports(mFilesOrDirectories[0].GetAsFile());
blob.forget(aValue);
return NS_OK;
}
@ -247,7 +247,7 @@ public:
uint32_t index = mIndex++;
if (mFilesOrDirectories[index].IsFile()) {
nsCOMPtr<nsIDOMBlob> blob = mFilesOrDirectories[index].GetAsFile().get();
nsCOMPtr<nsISupports> blob = ToSupports(mFilesOrDirectories[index].GetAsFile());
blob.forget(aValue);
return NS_OK;
}