Bug 1466023 - nsHostObjectURI renamed BlobURL, r=qdot

--HG--
rename : dom/file/nsHostObjectURI.cpp => dom/file/BlobURL.cpp
rename : dom/file/nsHostObjectURI.h => dom/file/BlobURL.h
This commit is contained in:
Andrea Marchesini 2018-06-02 15:51:42 +02:00
Родитель 962ddd4872
Коммит d13a49eca5
7 изменённых файлов: 70 добавлений и 64 удалений

Просмотреть файл

@ -4,24 +4,25 @@
* 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 "nsHostObjectURI.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "mozilla/dom/BlobURL.h"
#include "mozilla/dom/BlobURLProtocolHandler.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/URIUtils.h"
using namespace mozilla::dom;
static NS_DEFINE_CID(kHOSTOBJECTURICID, NS_HOSTOBJECTURI_CID);
static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
NS_THIS_SIMPLEURI_IMPLEMENTATION_CID);
NS_IMPL_ADDREF_INHERITED(nsHostObjectURI, mozilla::net::nsSimpleURI)
NS_IMPL_RELEASE_INHERITED(nsHostObjectURI, mozilla::net::nsSimpleURI)
NS_IMPL_ADDREF_INHERITED(BlobURL, mozilla::net::nsSimpleURI)
NS_IMPL_RELEASE_INHERITED(BlobURL, mozilla::net::nsSimpleURI)
NS_INTERFACE_MAP_BEGIN(nsHostObjectURI)
NS_INTERFACE_MAP_BEGIN(BlobURL)
NS_INTERFACE_MAP_ENTRY(nsIURIWithPrincipal)
if (aIID.Equals(kHOSTOBJECTURICID))
foundInterface = static_cast<nsIURI*>(this);
@ -38,7 +39,7 @@ NS_INTERFACE_MAP_END_INHERITING(mozilla::net::nsSimpleURI)
// nsIURIWithPrincipal methods:
NS_IMETHODIMP
nsHostObjectURI::GetPrincipal(nsIPrincipal** aPrincipal)
BlobURL::GetPrincipal(nsIPrincipal** aPrincipal)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIPrincipal> principal = mPrincipal.get();
@ -48,7 +49,7 @@ nsHostObjectURI::GetPrincipal(nsIPrincipal** aPrincipal)
}
NS_IMETHODIMP
nsHostObjectURI::GetPrincipalUri(nsIURI** aUri)
BlobURL::GetPrincipalUri(nsIURI** aUri)
{
if (mPrincipal) {
mPrincipal->GetURI(aUri);
@ -63,14 +64,14 @@ nsHostObjectURI::GetPrincipalUri(nsIURI** aUri)
// nsISerializable methods:
NS_IMETHODIMP
nsHostObjectURI::Read(nsIObjectInputStream* aStream)
BlobURL::Read(nsIObjectInputStream* aStream)
{
NS_NOTREACHED("Use nsIURIMutator.read() instead");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsHostObjectURI::ReadPrivate(nsIObjectInputStream *aStream)
BlobURL::ReadPrivate(nsIObjectInputStream *aStream)
{
nsresult rv = mozilla::net::nsSimpleURI::ReadPrivate(aStream);
NS_ENSURE_SUCCESS(rv, rv);
@ -85,7 +86,7 @@ nsHostObjectURI::ReadPrivate(nsIObjectInputStream *aStream)
}
NS_IMETHODIMP
nsHostObjectURI::Write(nsIObjectOutputStream* aStream)
BlobURL::Write(nsIObjectOutputStream* aStream)
{
nsresult rv = mozilla::net::nsSimpleURI::Write(aStream);
NS_ENSURE_SUCCESS(rv, rv);
@ -98,7 +99,7 @@ nsHostObjectURI::Write(nsIObjectOutputStream* aStream)
// nsIIPCSerializableURI methods:
void
nsHostObjectURI::Serialize(mozilla::ipc::URIParams& aParams)
BlobURL::Serialize(mozilla::ipc::URIParams& aParams)
{
using namespace mozilla::ipc;
@ -125,7 +126,7 @@ nsHostObjectURI::Serialize(mozilla::ipc::URIParams& aParams)
}
bool
nsHostObjectURI::Deserialize(const mozilla::ipc::URIParams& aParams)
BlobURL::Deserialize(const mozilla::ipc::URIParams& aParams)
{
using namespace mozilla::ipc;
@ -154,7 +155,7 @@ nsHostObjectURI::Deserialize(const mozilla::ipc::URIParams& aParams)
}
nsresult
nsHostObjectURI::SetScheme(const nsACString& aScheme)
BlobURL::SetScheme(const nsACString& aScheme)
{
// Disallow setting the scheme, since that could cause us to be associated
// with a different protocol handler that doesn't expect us to be carrying
@ -164,9 +165,9 @@ nsHostObjectURI::SetScheme(const nsACString& aScheme)
// nsIURI methods:
nsresult
nsHostObjectURI::CloneInternal(mozilla::net::nsSimpleURI::RefHandlingEnum aRefHandlingMode,
const nsACString& newRef,
nsIURI** aClone)
BlobURL::CloneInternal(mozilla::net::nsSimpleURI::RefHandlingEnum aRefHandlingMode,
const nsACString& newRef,
nsIURI** aClone)
{
nsCOMPtr<nsIURI> simpleClone;
nsresult rv =
@ -174,12 +175,12 @@ nsHostObjectURI::CloneInternal(mozilla::net::nsSimpleURI::RefHandlingEnum aRefHa
NS_ENSURE_SUCCESS(rv, rv);
#ifdef DEBUG
RefPtr<nsHostObjectURI> uriCheck;
RefPtr<BlobURL> uriCheck;
rv = simpleClone->QueryInterface(kHOSTOBJECTURICID, getter_AddRefs(uriCheck));
MOZ_ASSERT(NS_SUCCEEDED(rv) && uriCheck);
#endif
nsHostObjectURI* u = static_cast<nsHostObjectURI*>(simpleClone.get());
BlobURL* u = static_cast<BlobURL*>(simpleClone.get());
u->mPrincipal = mPrincipal;
@ -188,16 +189,16 @@ nsHostObjectURI::CloneInternal(mozilla::net::nsSimpleURI::RefHandlingEnum aRefHa
}
/* virtual */ nsresult
nsHostObjectURI::EqualsInternal(nsIURI* aOther,
mozilla::net::nsSimpleURI::RefHandlingEnum aRefHandlingMode,
bool* aResult)
BlobURL::EqualsInternal(nsIURI* aOther,
mozilla::net::nsSimpleURI::RefHandlingEnum aRefHandlingMode,
bool* aResult)
{
if (!aOther) {
*aResult = false;
return NS_OK;
}
RefPtr<nsHostObjectURI> otherUri;
RefPtr<BlobURL> otherUri;
aOther->QueryInterface(kHOSTOBJECTURICID, getter_AddRefs(otherUri));
if (!otherUri) {
*aResult = false;
@ -220,16 +221,16 @@ nsHostObjectURI::EqualsInternal(nsIURI* aOther,
}
// Queries this list of interfaces. If none match, it queries mURI.
NS_IMPL_NSIURIMUTATOR_ISUPPORTS(nsHostObjectURI::Mutator,
NS_IMPL_NSIURIMUTATOR_ISUPPORTS(BlobURL::Mutator,
nsIURISetters,
nsIURIMutator,
nsIPrincipalURIMutator,
nsISerializable)
NS_IMETHODIMP
nsHostObjectURI::Mutate(nsIURIMutator** aMutator)
BlobURL::Mutate(nsIURIMutator** aMutator)
{
RefPtr<nsHostObjectURI::Mutator> mutator = new nsHostObjectURI::Mutator();
RefPtr<BlobURL::Mutator> mutator = new BlobURL::Mutator();
nsresult rv = mutator->InitFromURI(this);
if (NS_FAILED(rv)) {
return rv;
@ -240,7 +241,7 @@ nsHostObjectURI::Mutate(nsIURIMutator** aMutator)
// nsIClassInfo methods:
NS_IMETHODIMP
nsHostObjectURI::GetInterfaces(uint32_t *count, nsIID * **array)
BlobURL::GetInterfaces(uint32_t *count, nsIID * **array)
{
*count = 0;
*array = nullptr;
@ -248,14 +249,14 @@ nsHostObjectURI::GetInterfaces(uint32_t *count, nsIID * **array)
}
NS_IMETHODIMP
nsHostObjectURI::GetScriptableHelper(nsIXPCScriptable **_retval)
BlobURL::GetScriptableHelper(nsIXPCScriptable **_retval)
{
*_retval = nullptr;
return NS_OK;
}
NS_IMETHODIMP
nsHostObjectURI::GetContractID(nsACString& aContractID)
BlobURL::GetContractID(nsACString& aContractID)
{
// Make sure to modify any subclasses as needed if this ever
// changes.
@ -264,14 +265,14 @@ nsHostObjectURI::GetContractID(nsACString& aContractID)
}
NS_IMETHODIMP
nsHostObjectURI::GetClassDescription(nsACString& aClassDescription)
BlobURL::GetClassDescription(nsACString& aClassDescription)
{
aClassDescription.SetIsVoid(true);
return NS_OK;
}
NS_IMETHODIMP
nsHostObjectURI::GetClassID(nsCID * *aClassID)
BlobURL::GetClassID(nsCID * *aClassID)
{
// Make sure to modify any subclasses as needed if this ever
// changes to not call the virtual GetClassIDNoAlloc.
@ -282,14 +283,14 @@ nsHostObjectURI::GetClassID(nsCID * *aClassID)
}
NS_IMETHODIMP
nsHostObjectURI::GetFlags(uint32_t *aFlags)
BlobURL::GetFlags(uint32_t *aFlags)
{
*aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
return NS_OK;
}
NS_IMETHODIMP
nsHostObjectURI::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
BlobURL::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{
*aClassIDNoAlloc = kHOSTOBJECTURICID;
return NS_OK;

Просмотреть файл

@ -4,8 +4,8 @@
* 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 nsHostObjectURI_h
#define nsHostObjectURI_h
#ifndef mozilla_dom_BlobURL_h
#define mozilla_dom_BlobURL_h
#include "mozilla/Attributes.h"
#include "mozilla/dom/File.h"
@ -18,23 +18,26 @@
#include "nsIIPCSerializableURI.h"
#include "nsProxyRelease.h"
namespace mozilla {
namespace dom {
/**
* These URIs refer to host objects with "blob" scheme. The underlying objects
* can be Blobs or MediaSources.
* These URIs refer to host objects with "blob" scheme. The underlying object is
* a BlobImpl.
*/
class nsHostObjectURI final
class BlobURL final
: public mozilla::net::nsSimpleURI
, public nsIURIWithPrincipal
{
private:
explicit nsHostObjectURI(nsIPrincipal* aPrincipal)
explicit BlobURL(nsIPrincipal* aPrincipal)
: mozilla::net::nsSimpleURI()
{
mPrincipal = new nsMainThreadPtrHolder<nsIPrincipal>("nsIPrincipal", aPrincipal, false);
}
// For use only from deserialization
explicit nsHostObjectURI()
explicit BlobURL()
: mozilla::net::nsSimpleURI()
{}
@ -53,11 +56,11 @@ public:
RefHandlingEnum aRefHandlingMode,
bool* aResult) override;
// Override StartClone to hand back a nsHostObjectURI
// Override StartClone to hand back a BlobURL
virtual mozilla::net::nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode,
const nsACString& newRef) override
{
nsHostObjectURI* url = new nsHostObjectURI();
BlobURL* url = new BlobURL();
SetRefOnClone(url, refHandlingMode, newRef);
return url;
}
@ -66,8 +69,8 @@ public:
nsMainThreadPtrHandle<nsIPrincipal> mPrincipal;
protected:
virtual ~nsHostObjectURI() {}
private:
virtual ~BlobURL() = default;
nsresult SetScheme(const nsACString &aProtocol) override;
bool Deserialize(const mozilla::ipc::URIParams&);
@ -76,7 +79,7 @@ protected:
public:
class Mutator final
: public nsIURIMutator
, public BaseURIMutator<nsHostObjectURI>
, public BaseURIMutator<BlobURL>
, public nsIPrincipalURIMutator
, public nsISerializable
{
@ -107,14 +110,15 @@ public:
return NS_OK;
}
explicit Mutator() { }
private:
virtual ~Mutator() { }
Mutator() = default;
friend class nsHostObjectURI;
private:
~Mutator() = default;
friend class BlobURL;
};
friend BaseURIMutator<nsHostObjectURI>;
friend BaseURIMutator<BlobURL>;
};
#define NS_HOSTOBJECTURI_CID \
@ -125,4 +129,7 @@ public:
{ 0xbbe50ef2, 0x80eb, 0x469d, \
{ 0xb7, 0x0d, 0x02, 0x85, 0x82, 0x75, 0x38, 0x9f } }
#endif /* nsHostObjectURI_h */
} // dom namespace
} // mozilla namespace
#endif /* mozilla_dom_BlobURL_h */

Просмотреть файл

@ -6,6 +6,7 @@
#include "BlobURLProtocolHandler.h"
#include "mozilla/dom/BlobURL.h"
#include "mozilla/dom/ChromeUtils.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentParent.h"
@ -21,7 +22,6 @@
#include "nsClassHashtable.h"
#include "nsContentUtils.h"
#include "nsError.h"
#include "nsHostObjectURI.h"
#include "nsIAsyncShutdown.h"
#include "nsIException.h" // for nsIStackFrame
#include "nsIMemoryReporter.h"
@ -838,7 +838,7 @@ BlobURLProtocolHandler::NewURI(const nsACString& aSpec,
}
nsCOMPtr<nsIURI> uri;
rv = NS_MutateURI(new nsHostObjectURI::Mutator())
rv = NS_MutateURI(new BlobURL::Mutator())
.SetSpec(aSpec)
.Apply(NS_MutatorMethod(&nsIPrincipalURIMutator::SetPrincipal, principal))
.Finalize(uri);

Просмотреть файл

@ -4,6 +4,7 @@
* 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 "EmptyBlobImpl.h"
#include "MutableBlobStorage.h"
#include "MemoryBlobImpl.h"
#include "mozilla/CheckedInt.h"

Просмотреть файл

@ -9,15 +9,12 @@ with Files("**"):
DIRS += ['ipc']
EXPORTS += [
'nsHostObjectURI.h',
]
EXPORTS.mozilla.dom += [
'BaseBlobImpl.h',
'Blob.h',
'BlobImpl.h',
'BlobSet.h',
'BlobURL.h',
'BlobURLProtocolHandler.h',
'File.h',
'FileBlobImpl.h',
@ -38,6 +35,7 @@ UNIFIED_SOURCES += [
'Blob.cpp',
'BlobImpl.cpp',
'BlobSet.cpp',
'BlobURL.cpp',
'BlobURLProtocolHandler.cpp',
'EmptyBlobImpl.cpp',
'File.cpp',
@ -51,7 +49,6 @@ UNIFIED_SOURCES += [
'MultipartBlobImpl.cpp',
'MutableBlobStorage.cpp',
'MutableBlobStreamListener.cpp',
'nsHostObjectURI.cpp',
'StreamBlobImpl.cpp',
'StringBlobImpl.cpp',
'TemporaryFileBlobImpl.cpp',

Просмотреть файл

@ -10,12 +10,12 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/BlobURL.h"
#include "nsComponentManagerUtils.h"
#include "nsDebug.h"
#include "nsID.h"
#include "nsJARURI.h"
#include "nsIIconURI.h"
#include "nsHostObjectURI.h"
#include "NullPrincipalURI.h"
#include "nsJSProtocolHandler.h"
#include "nsNetCID.h"
@ -109,7 +109,7 @@ DeserializeURI(const URIParams& aParams)
break;
case URIParams::THostObjectURIParams:
mutator = new nsHostObjectURI::Mutator();
mutator = new mozilla::dom::BlobURL::Mutator();
break;
default:

Просмотреть файл

@ -59,13 +59,13 @@
// view stuff
#include "nsContentCreatorFunctions.h"
#include "nsHostObjectURI.h"
#include "nsGlobalWindowCommands.h"
#include "nsIControllerCommandTable.h"
#include "nsJSProtocolHandler.h"
#include "nsIControllerContext.h"
#include "nsZipArchive.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/BlobURL.h"
#include "mozilla/dom/DOMRequest.h"
#include "mozilla/dom/LocalStorageManager.h"
#include "mozilla/dom/network/UDPSocketChild.h"
@ -196,8 +196,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(HTMLEditor)
already_AddRefed<nsIPresentationService> NS_CreatePresentationService();
// Factory Constructor
typedef nsHostObjectURI::Mutator nsHostObjectURIMutator;
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHostObjectURIMutator)
typedef mozilla::dom::BlobURL::Mutator BlobURLMutator;
NS_GENERIC_FACTORY_CONSTRUCTOR(BlobURLMutator)
NS_GENERIC_FACTORY_CONSTRUCTOR(LocalStorageManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(SessionStorageManager)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService,
@ -787,8 +787,8 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_PLUGINDOCUMENT_CID, false, nullptr, CreatePluginDocument },
{ &kNS_VIDEODOCUMENT_CID, false, nullptr, CreateVideoDocument },
{ &kNS_STYLESHEETSERVICE_CID, false, nullptr, nsStyleSheetServiceConstructor },
{ &kNS_HOSTOBJECTURI_CID, false, nullptr, nsHostObjectURIMutatorConstructor }, // do_CreateInstance returns mutator
{ &kNS_HOSTOBJECTURIMUTATOR_CID, false, nullptr, nsHostObjectURIMutatorConstructor },
{ &kNS_HOSTOBJECTURI_CID, false, nullptr, BlobURLMutatorConstructor }, // do_CreateInstance returns mutator
{ &kNS_HOSTOBJECTURIMUTATOR_CID, false, nullptr, BlobURLMutatorConstructor },
{ &kNS_DOMSESSIONSTORAGEMANAGER_CID, false, nullptr, SessionStorageManagerConstructor },
{ &kNS_DOMLOCALSTORAGEMANAGER_CID, false, nullptr, LocalStorageManagerConstructor },
{ &kNS_TEXTEDITOR_CID, false, nullptr, TextEditorConstructor },