mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Backed out changeset f7e0ffc1debd (bug 879475) for B2G reftest crashes
This commit is contained in:
parent
6a8a945c35
commit
0c7bfa6f11
@ -2301,7 +2301,7 @@ nsFrameLoader::DoSendAsyncMessage(JSContext* aCx,
|
||||
TabParent* tabParent = mRemoteBrowser;
|
||||
if (tabParent) {
|
||||
ClonedMessageData data;
|
||||
nsIContentParent* cp = tabParent->Manager();
|
||||
ContentParent* cp = tabParent->Manager();
|
||||
if (!BuildClonedMessageDataForParent(cp, aData, data)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ private:
|
||||
|
||||
// The ContentParent associated with mRemoteBrowser. This was added as a
|
||||
// strong ref in bug 545237, and we're not sure if we can get rid of it.
|
||||
nsRefPtr<mozilla::dom::nsIContentParent> mContentParent;
|
||||
nsRefPtr<mozilla::dom::ContentParent> mContentParent;
|
||||
RenderFrameParent* mCurrentRemoteFrame;
|
||||
TabParent* mRemoteBrowser;
|
||||
uint64_t mChildID;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "AppProcessChecker.h"
|
||||
#include "ContentChild.h"
|
||||
#include "ContentParent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCxPusher.h"
|
||||
#include "nsError.h"
|
||||
@ -30,8 +31,6 @@
|
||||
#include "nsIDOMFile.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/nsIContentParent.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/dom/StructuredCloneUtils.h"
|
||||
#include "mozilla/dom/PBlobChild.h"
|
||||
#include "mozilla/dom/PBlobParent.h"
|
||||
@ -39,7 +38,6 @@
|
||||
#include "JavaScriptParent.h"
|
||||
#include "mozilla/dom/DOMStringList.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef ANDROID
|
||||
@ -146,7 +144,7 @@ struct BlobTraits<Parent>
|
||||
{
|
||||
typedef mozilla::dom::BlobParent BlobType;
|
||||
typedef mozilla::dom::PBlobParent ProtocolType;
|
||||
typedef mozilla::dom::nsIContentParent ConcreteContentManagerType;
|
||||
typedef mozilla::dom::ContentParent ConcreteContentManagerType;
|
||||
};
|
||||
|
||||
template <>
|
||||
@ -221,7 +219,7 @@ BuildClonedMessageData(typename BlobTraits<Flavor>::ConcreteContentManagerType*
|
||||
}
|
||||
|
||||
bool
|
||||
MessageManagerCallback::BuildClonedMessageDataForParent(nsIContentParent* aParent,
|
||||
MessageManagerCallback::BuildClonedMessageDataForParent(ContentParent* aParent,
|
||||
const StructuredCloneData& aData,
|
||||
ClonedMessageData& aClonedData)
|
||||
{
|
||||
@ -1882,7 +1880,7 @@ NS_NewParentProcessMessageManager(nsIMessageBroadcaster** aResult)
|
||||
|
||||
|
||||
nsFrameMessageManager*
|
||||
nsFrameMessageManager::NewProcessMessageManager(mozilla::dom::nsIContentParent* aProcess)
|
||||
nsFrameMessageManager::NewProcessMessageManager(mozilla::dom::ContentParent* aProcess)
|
||||
{
|
||||
if (!nsFrameMessageManager::sParentProcessManager) {
|
||||
nsCOMPtr<nsIMessageBroadcaster> dummy =
|
||||
|
@ -32,7 +32,7 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class nsIContentParent;
|
||||
class ContentParent;
|
||||
class ContentChild;
|
||||
class ClonedMessageData;
|
||||
class MessageManagerReporter;
|
||||
@ -99,7 +99,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool BuildClonedMessageDataForParent(nsIContentParent* aParent,
|
||||
bool BuildClonedMessageDataForParent(ContentParent* aParent,
|
||||
const StructuredCloneData& aData,
|
||||
ClonedMessageData& aClonedData);
|
||||
bool BuildClonedMessageDataForChild(ContentChild* aChild,
|
||||
@ -217,7 +217,7 @@ public:
|
||||
NS_DECL_NSIPROCESSCHECKER
|
||||
|
||||
static nsFrameMessageManager*
|
||||
NewProcessMessageManager(mozilla::dom::nsIContentParent* aProcess);
|
||||
NewProcessMessageManager(mozilla::dom::ContentParent* aProcess);
|
||||
|
||||
nsresult ReceiveMessage(nsISupports* aTarget, const nsAString& aMessage,
|
||||
bool aIsSync, const StructuredCloneData* aCloneData,
|
||||
|
@ -312,14 +312,12 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices)
|
||||
if (mPermissionRequests[i].type().EqualsLiteral("audio-capture")) {
|
||||
GonkPermissionService::GetInstance()->addGrantInfo(
|
||||
"android.permission.RECORD_AUDIO",
|
||||
static_cast<TabParent*>(
|
||||
mParent->Manager())->Manager()->AsContentParent()->Pid());
|
||||
static_cast<TabParent*>(mParent->Manager())->Manager()->Pid());
|
||||
}
|
||||
if (mPermissionRequests[i].type().EqualsLiteral("video-capture")) {
|
||||
GonkPermissionService::GetInstance()->addGrantInfo(
|
||||
"android.permission.CAMERA",
|
||||
static_cast<TabParent*>(
|
||||
mParent->Manager())->Manager()->AsContentParent()->Pid());
|
||||
static_cast<TabParent*>(mParent->Manager())->Manager()->Pid());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/dom/nsIContentParent.h"
|
||||
#include "mozilla/dom/PBlobStreamChild.h"
|
||||
#include "mozilla/dom/PBlobStreamParent.h"
|
||||
#include "mozilla/dom/PFileDescriptorSetParent.h"
|
||||
@ -1764,7 +1763,7 @@ RemoteBlob::GetPBlob()
|
||||
* BlobParent
|
||||
******************************************************************************/
|
||||
|
||||
BlobParent::BlobParent(nsIContentParent* aManager, nsIDOMBlob* aBlob)
|
||||
BlobParent::BlobParent(ContentParent* aManager, nsIDOMBlob* aBlob)
|
||||
: mBlob(aBlob)
|
||||
, mRemoteBlob(nullptr)
|
||||
, mStrongManager(aManager)
|
||||
@ -1781,7 +1780,7 @@ BlobParent::BlobParent(nsIContentParent* aManager, nsIDOMBlob* aBlob)
|
||||
mBlobIsFile = !!file;
|
||||
}
|
||||
|
||||
BlobParent::BlobParent(nsIContentParent* aManager,
|
||||
BlobParent::BlobParent(ContentParent* aManager,
|
||||
const ParentBlobConstructorParams& aParams)
|
||||
: mBlob(nullptr)
|
||||
, mRemoteBlob(nullptr)
|
||||
@ -1814,7 +1813,7 @@ BlobParent::~BlobParent()
|
||||
}
|
||||
|
||||
BlobParent*
|
||||
BlobParent::Create(nsIContentParent* aManager,
|
||||
BlobParent::Create(ContentParent* aManager,
|
||||
const ParentBlobConstructorParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -1921,12 +1920,6 @@ BlobParent::SetMysteryBlobInfo(const nsString& aContentType, uint64_t aLength)
|
||||
return SendResolveMystery(params);
|
||||
}
|
||||
|
||||
nsIContentParent*
|
||||
BlobParent::Manager()
|
||||
{
|
||||
return mStrongManager;
|
||||
}
|
||||
|
||||
already_AddRefed<BlobParent::RemoteBlob>
|
||||
BlobParent::CreateRemoteBlob(const ParentBlobConstructorParams& aParams)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ContentChild;
|
||||
class nsIContentParent;
|
||||
class ContentParent;
|
||||
class PBlobStreamChild;
|
||||
class PBlobStreamParent;
|
||||
|
||||
@ -103,7 +103,7 @@ private:
|
||||
class BlobParent MOZ_FINAL
|
||||
: public PBlobParent
|
||||
{
|
||||
friend class nsIContentParent;
|
||||
friend class ContentParent;
|
||||
|
||||
class OpenStreamRunnable;
|
||||
friend class OpenStreamRunnable;
|
||||
@ -113,7 +113,7 @@ class BlobParent MOZ_FINAL
|
||||
|
||||
nsIDOMBlob* mBlob;
|
||||
RemoteBlob* mRemoteBlob;
|
||||
nsRefPtr<nsIContentParent> mStrongManager;
|
||||
nsRefPtr<ContentParent> mStrongManager;
|
||||
|
||||
// nsIInputStreams backed by files must ensure that the files are actually
|
||||
// opened and closed on a background thread before we can send their file
|
||||
@ -130,7 +130,7 @@ class BlobParent MOZ_FINAL
|
||||
public:
|
||||
// This create function is called on the sending side.
|
||||
static BlobParent*
|
||||
Create(nsIContentParent* aManager, nsIDOMBlob* aBlob)
|
||||
Create(ContentParent* aManager, nsIDOMBlob* aBlob)
|
||||
{
|
||||
return new BlobParent(aManager, aBlob);
|
||||
}
|
||||
@ -150,21 +150,19 @@ public:
|
||||
bool
|
||||
SetMysteryBlobInfo(const nsString& aContentType, uint64_t aLength);
|
||||
|
||||
nsIContentParent* Manager();
|
||||
|
||||
private:
|
||||
// This constructor is called on the sending side.
|
||||
BlobParent(nsIContentParent* aManager, nsIDOMBlob* aBlob);
|
||||
BlobParent(ContentParent* aManager, nsIDOMBlob* aBlob);
|
||||
|
||||
// This constructor is called on the receiving side.
|
||||
BlobParent(nsIContentParent* aManager,
|
||||
BlobParent(ContentParent* aManager,
|
||||
const ParentBlobConstructorParams& aParams);
|
||||
|
||||
~BlobParent();
|
||||
|
||||
// This create function is called on the receiving side by ContentParent.
|
||||
static BlobParent*
|
||||
Create(nsIContentParent* aManager, const ParentBlobConstructorParams& aParams);
|
||||
Create(ContentParent* aManager, const ParentBlobConstructorParams& aParams);
|
||||
|
||||
static already_AddRefed<RemoteBlob>
|
||||
CreateRemoteBlob(const ParentBlobConstructorParams& aParams);
|
||||
|
@ -480,8 +480,7 @@ ContentParentsMemoryReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
||||
nsPrintfCString path("queued-ipc-messages/content-parent"
|
||||
"(%s, pid=%d, %s, 0x%p, refcnt=%d)",
|
||||
NS_ConvertUTF16toUTF8(friendlyName).get(),
|
||||
cp->Pid(), channelStr,
|
||||
static_cast<nsIContentParent*>(cp), refcnt);
|
||||
cp->Pid(), channelStr, cp, refcnt);
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(desc,
|
||||
"The number of unset IPC messages held in this ContentParent's "
|
||||
@ -1523,8 +1522,7 @@ ContentParent::ContentParent(mozIApplication* aApp,
|
||||
bool aIsForPreallocated,
|
||||
ProcessPriority aInitialPriority /* = PROCESS_PRIORITY_FOREGROUND */,
|
||||
bool aIsNuwaProcess /* = false */)
|
||||
: nsIContentParent()
|
||||
, mIsForBrowser(aIsForBrowser)
|
||||
: mIsForBrowser(aIsForBrowser)
|
||||
, mIsNuwaProcess(aIsNuwaProcess)
|
||||
{
|
||||
InitializeMembers(); // Perform common initialization.
|
||||
@ -1735,6 +1733,8 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
||||
chromeRegistry->SendRegisteredChrome(this);
|
||||
}
|
||||
|
||||
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
|
||||
|
||||
if (gAppData) {
|
||||
nsCString version(gAppData->version);
|
||||
nsCString buildID(gAppData->buildID);
|
||||
@ -2193,7 +2193,6 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(ContentParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(ContentParent)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ContentParent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContentParent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionCallback)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
|
||||
@ -2398,13 +2397,27 @@ mozilla::jsipc::PJavaScriptParent *
|
||||
ContentParent::AllocPJavaScriptParent()
|
||||
{
|
||||
MOZ_ASSERT(!ManagedPJavaScriptParent().Length());
|
||||
return nsIContentParent::AllocPJavaScriptParent();
|
||||
|
||||
nsCOMPtr<nsIJSRuntimeService> svc = do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
|
||||
NS_ENSURE_TRUE(svc, nullptr);
|
||||
|
||||
JSRuntime *rt;
|
||||
svc->GetRuntime(&rt);
|
||||
NS_ENSURE_TRUE(svc, nullptr);
|
||||
|
||||
mozilla::jsipc::JavaScriptParent *parent = new mozilla::jsipc::JavaScriptParent(rt);
|
||||
if (!parent->init()) {
|
||||
delete parent;
|
||||
return nullptr;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
|
||||
{
|
||||
return nsIContentParent::DeallocPJavaScriptParent(parent);
|
||||
static_cast<mozilla::jsipc::JavaScriptParent *>(parent)->decref();
|
||||
return true;
|
||||
}
|
||||
|
||||
PBrowserParent*
|
||||
@ -2414,17 +2427,55 @@ ContentParent::AllocPBrowserParent(const IPCTabContext& aContext,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return nsIContentParent::AllocPBrowserParent(aContext,
|
||||
aChromeFlags,
|
||||
aId,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
unused << aChromeFlags;
|
||||
|
||||
const IPCTabAppBrowserContext& appBrowser = aContext.appBrowserContext();
|
||||
|
||||
// We don't trust the IPCTabContext we receive from the child, so we'll bail
|
||||
// if we receive an IPCTabContext that's not a PopupIPCTabContext.
|
||||
// (PopupIPCTabContext lets the child process prove that it has access to
|
||||
// the app it's trying to open.)
|
||||
if (appBrowser.type() != IPCTabAppBrowserContext::TPopupIPCTabContext) {
|
||||
NS_ERROR("Unexpected IPCTabContext type. Aborting AllocPBrowserParent.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const PopupIPCTabContext& popupContext = appBrowser.get_PopupIPCTabContext();
|
||||
TabParent* opener = static_cast<TabParent*>(popupContext.openerParent());
|
||||
if (!opener) {
|
||||
NS_ERROR("Got null opener from child; aborting AllocPBrowserParent.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Popup windows of isBrowser frames must be isBrowser if the parent
|
||||
// isBrowser. Allocating a !isBrowser frame with same app ID would allow
|
||||
// the content to access data it's not supposed to.
|
||||
if (!popupContext.isBrowserElement() && opener->IsBrowserElement()) {
|
||||
NS_ERROR("Child trying to escalate privileges! Aborting AllocPBrowserParent.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MaybeInvalidTabContext tc(aContext);
|
||||
if (!tc.IsValid()) {
|
||||
NS_ERROR(nsPrintfCString("Child passed us an invalid TabContext. (%s) "
|
||||
"Aborting AllocPBrowserParent.",
|
||||
tc.GetInvalidReason()).get());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TabParent* parent = new TabParent(this, tc.GetTabContext(), aChromeFlags);
|
||||
|
||||
// We release this ref in DeallocPBrowserParent()
|
||||
NS_ADDREF(parent);
|
||||
return parent;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::DeallocPBrowserParent(PBrowserParent* frame)
|
||||
{
|
||||
return nsIContentParent::DeallocPBrowserParent(frame);
|
||||
TabParent* parent = static_cast<TabParent*>(frame);
|
||||
NS_RELEASE(parent);
|
||||
return true;
|
||||
}
|
||||
|
||||
PDeviceStorageRequestParent*
|
||||
@ -2467,7 +2518,7 @@ ContentParent::DeallocPFileSystemRequestParent(PFileSystemRequestParent* doomed)
|
||||
PBlobParent*
|
||||
ContentParent::AllocPBlobParent(const BlobConstructorParams& aParams)
|
||||
{
|
||||
return nsIContentParent::AllocPBlobParent(aParams);
|
||||
return BlobParent::Create(this, aParams);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2477,6 +2528,81 @@ ContentParent::DeallocPBlobParent(PBlobParent* aActor)
|
||||
return true;
|
||||
}
|
||||
|
||||
BlobParent*
|
||||
ContentParent::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aBlob);
|
||||
|
||||
// If the blob represents a remote blob for this ContentParent then we can
|
||||
// simply pass its actor back here.
|
||||
if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlob)) {
|
||||
if (BlobParent* actor = static_cast<BlobParent*>(
|
||||
static_cast<PBlobParent*>(remoteBlob->GetPBlob()))) {
|
||||
if (static_cast<ContentParent*>(actor->Manager()) == this) {
|
||||
return actor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All blobs shared between processes must be immutable.
|
||||
nsCOMPtr<nsIMutable> mutableBlob = do_QueryInterface(aBlob);
|
||||
if (!mutableBlob || NS_FAILED(mutableBlob->SetMutable(false))) {
|
||||
NS_WARNING("Failed to make blob immutable!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// XXX This is only safe so long as all blob implementations in our tree
|
||||
// inherit nsDOMFileBase. If that ever changes then this will need to grow
|
||||
// a real interface or something.
|
||||
const auto* blob = static_cast<nsDOMFileBase*>(aBlob);
|
||||
|
||||
ChildBlobConstructorParams params;
|
||||
|
||||
if (blob->IsSizeUnknown() || blob->IsDateUnknown()) {
|
||||
// We don't want to call GetSize or GetLastModifiedDate
|
||||
// yet since that may stat a file on the main thread
|
||||
// here. Instead we'll learn the size lazily from the
|
||||
// other process.
|
||||
params = MysteryBlobConstructorParams();
|
||||
}
|
||||
else {
|
||||
nsString contentType;
|
||||
nsresult rv = aBlob->GetType(contentType);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
uint64_t length;
|
||||
rv = aBlob->GetSize(&length);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMFile> file = do_QueryInterface(aBlob);
|
||||
if (file) {
|
||||
FileBlobConstructorParams fileParams;
|
||||
|
||||
rv = file->GetMozLastModifiedDate(&fileParams.modDate());
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
rv = file->GetName(fileParams.name());
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
fileParams.contentType() = contentType;
|
||||
fileParams.length() = length;
|
||||
|
||||
params = fileParams;
|
||||
} else {
|
||||
NormalBlobConstructorParams blobParams;
|
||||
blobParams.contentType() = contentType;
|
||||
blobParams.length() = length;
|
||||
params = blobParams;
|
||||
}
|
||||
}
|
||||
|
||||
BlobParent* actor = BlobParent::Create(this, aBlob);
|
||||
NS_ENSURE_TRUE(actor, nullptr);
|
||||
|
||||
return SendPBlobConstructor(actor, params) ? actor : nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::KillHard()
|
||||
{
|
||||
@ -3054,8 +3180,21 @@ ContentParent::RecvSyncMessage(const nsString& aMsg,
|
||||
const IPC::Principal& aPrincipal,
|
||||
InfallibleTArray<nsString>* aRetvals)
|
||||
{
|
||||
return nsIContentParent::RecvSyncMessage(aMsg, aData, aCpows, aPrincipal,
|
||||
aRetvals);
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
principal && !AssertAppPrincipal(this, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
||||
if (ppm) {
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(GetCPOWManager(), aCpows);
|
||||
|
||||
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
||||
aMsg, true, &cloneData, &cpows, aPrincipal, aRetvals);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3065,8 +3204,20 @@ ContentParent::AnswerRpcMessage(const nsString& aMsg,
|
||||
const IPC::Principal& aPrincipal,
|
||||
InfallibleTArray<nsString>* aRetvals)
|
||||
{
|
||||
return nsIContentParent::AnswerRpcMessage(aMsg, aData, aCpows, aPrincipal,
|
||||
aRetvals);
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
principal && !AssertAppPrincipal(this, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
||||
if (ppm) {
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(GetCPOWManager(), aCpows);
|
||||
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
||||
aMsg, true, &cloneData, &cpows, aPrincipal, aRetvals);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3075,7 +3226,20 @@ ContentParent::RecvAsyncMessage(const nsString& aMsg,
|
||||
const InfallibleTArray<CpowEntry>& aCpows,
|
||||
const IPC::Principal& aPrincipal)
|
||||
{
|
||||
return nsIContentParent::RecvAsyncMessage(aMsg, aData, aCpows, aPrincipal);
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
principal && !AssertAppPrincipal(this, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
||||
if (ppm) {
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(GetCPOWManager(), aCpows);
|
||||
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
||||
aMsg, false, &cloneData, &cpows, aPrincipal, nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3283,13 +3447,6 @@ ContentParent::CheckAppHasStatus(unsigned short aStatus)
|
||||
return AssertAppHasStatus(this, aStatus);
|
||||
}
|
||||
|
||||
PBlobParent*
|
||||
ContentParent::SendPBlobConstructor(PBlobParent* aActor,
|
||||
const BlobConstructorParams& aParams)
|
||||
{
|
||||
return PContentParent::SendPBlobConstructor(aActor, aParams);
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvSystemMessageHandled()
|
||||
{
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define mozilla_dom_ContentParent_h
|
||||
|
||||
#include "mozilla/dom/PContentParent.h"
|
||||
#include "mozilla/dom/nsIContentParent.h"
|
||||
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
||||
#include "mozilla/dom/ipc/Blob.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
@ -64,9 +63,9 @@ class TabContext;
|
||||
class PFileDescriptorSetParent;
|
||||
|
||||
class ContentParent : public PContentParent
|
||||
, public nsIContentParent
|
||||
, public nsIObserver
|
||||
, public nsIDOMGeoPositionCallback
|
||||
, public mozilla::dom::ipc::MessageManagerCallback
|
||||
, public mozilla::LinkedListElement<ContentParent>
|
||||
{
|
||||
typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost;
|
||||
@ -76,7 +75,6 @@ class ContentParent : public PContentParent
|
||||
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
|
||||
|
||||
public:
|
||||
virtual bool IsContentParent() MOZ_OVERRIDE { return true; }
|
||||
/**
|
||||
* Start up the content-process machinery. This might include
|
||||
* scheduling pre-launch tasks.
|
||||
@ -176,6 +174,8 @@ public:
|
||||
return mSendDataStoreInfos;
|
||||
}
|
||||
|
||||
BlobParent* GetOrCreateActorForBlob(nsIDOMBlob* aBlob);
|
||||
|
||||
/**
|
||||
* Kill our subprocess and make sure it dies. Should only be used
|
||||
* in emergency situations since it bypasses the normal shutdown
|
||||
@ -183,7 +183,7 @@ public:
|
||||
*/
|
||||
void KillHard();
|
||||
|
||||
uint64_t ChildID() MOZ_OVERRIDE { return mChildID; }
|
||||
uint64_t ChildID() { return mChildID; }
|
||||
const nsString& AppManifestURL() const { return mAppManifestURL; }
|
||||
|
||||
bool IsPreallocated();
|
||||
@ -241,10 +241,6 @@ public:
|
||||
nsICycleCollectorLogSink* aSink,
|
||||
nsIDumpGCAndCCLogsCallback* aCallback);
|
||||
|
||||
virtual PBlobParent* SendPBlobConstructor(
|
||||
PBlobParent* aActor,
|
||||
const BlobConstructorParams& aParams) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
void OnChannelConnected(int32_t pid) MOZ_OVERRIDE;
|
||||
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
@ -608,6 +604,8 @@ private:
|
||||
*/
|
||||
nsString mAppName;
|
||||
|
||||
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
||||
|
||||
// After we initiate shutdown, we also start a timer to ensure
|
||||
// that even content processes that are 100% blocked (say from
|
||||
// SIGSTOP), are still killed eventually. This task enforces that
|
||||
|
@ -502,9 +502,9 @@ ProcessPriorityManagerImpl::ObserveContentParentCreated(
|
||||
{
|
||||
// Do nothing; it's sufficient to get the PPPM. But assign to nsRefPtr so we
|
||||
// don't leak the already_AddRefed object.
|
||||
nsCOMPtr<nsIContentParent> cp = do_QueryInterface(aContentParent);
|
||||
nsCOMPtr<nsIObserver> cp = do_QueryInterface(aContentParent);
|
||||
nsRefPtr<ParticularProcessPriorityManager> pppm =
|
||||
GetParticularProcessPriorityManager(cp->AsContentParent());
|
||||
GetParticularProcessPriorityManager(static_cast<ContentParent*>(cp.get()));
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
@ -816,7 +816,6 @@ ParticularProcessPriorityManager::OnRemoteBrowserFrameShown(nsISupports* aSubjec
|
||||
fl->GetTabParent(getter_AddRefs(tp));
|
||||
NS_ENSURE_TRUE_VOID(tp);
|
||||
|
||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||
if (static_cast<TabParent*>(tp.get())->Manager() != mContentParent) {
|
||||
return;
|
||||
}
|
||||
@ -830,7 +829,6 @@ ParticularProcessPriorityManager::OnTabParentDestroyed(nsISupports* aSubject)
|
||||
nsCOMPtr<nsITabParent> tp = do_QueryInterface(aSubject);
|
||||
NS_ENSURE_TRUE_VOID(tp);
|
||||
|
||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||
if (static_cast<TabParent*>(tp.get())->Manager() != mContentParent) {
|
||||
return;
|
||||
}
|
||||
@ -850,7 +848,6 @@ ParticularProcessPriorityManager::OnFrameloaderVisibleChanged(nsISupports* aSubj
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||
if (static_cast<TabParent*>(tp.get())->Manager() != mContentParent) {
|
||||
return;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ NS_IMPL_ISUPPORTS(TabParent,
|
||||
nsISecureBrowserUI,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
TabParent::TabParent(nsIContentParent* aManager, const TabContext& aContext, uint32_t aChromeFlags)
|
||||
TabParent::TabParent(ContentParent* aManager, const TabContext& aContext, uint32_t aChromeFlags)
|
||||
: TabContext(aContext)
|
||||
, mFrameElement(nullptr)
|
||||
, mIMESelectionAnchor(0)
|
||||
@ -230,7 +230,6 @@ TabParent::TabParent(nsIContentParent* aManager, const TabContext& aContext, uin
|
||||
, mAppPackageFileDescriptorSent(false)
|
||||
, mChromeFlags(aChromeFlags)
|
||||
{
|
||||
MOZ_ASSERT(aManager);
|
||||
}
|
||||
|
||||
TabParent::~TabParent()
|
||||
@ -300,18 +299,14 @@ TabParent::Destroy()
|
||||
}
|
||||
mIsDestroyed = true;
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
Manager()->AsContentParent()->NotifyTabDestroying(this);
|
||||
}
|
||||
Manager()->NotifyTabDestroying(this);
|
||||
mMarkedDestroying = true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::Recv__delete__()
|
||||
{
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
Manager()->AsContentParent()->NotifyTabDestroyed(this, mMarkedDestroying);
|
||||
}
|
||||
Manager()->NotifyTabDestroyed(this, mMarkedDestroying);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -977,16 +972,15 @@ TabParent::RecvSyncMessage(const nsString& aMessage,
|
||||
const IPC::Principal& aPrincipal,
|
||||
InfallibleTArray<nsString>* aJSONRetVal)
|
||||
{
|
||||
// FIXME Permission check for TabParent in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
ContentParent* parent = Manager()->AsContentParent();
|
||||
ContentParent* parent = static_cast<ContentParent*>(Manager());
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
parent && principal && !AssertAppPrincipal(parent, principal)) {
|
||||
principal && !AssertAppPrincipal(parent, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
|
||||
CpowIdHolder cpows(parent->GetCPOWManager(), aCpows);
|
||||
return ReceiveMessage(aMessage, true, &cloneData, &cpows, aPrincipal, aJSONRetVal);
|
||||
}
|
||||
|
||||
@ -997,16 +991,15 @@ TabParent::AnswerRpcMessage(const nsString& aMessage,
|
||||
const IPC::Principal& aPrincipal,
|
||||
InfallibleTArray<nsString>* aJSONRetVal)
|
||||
{
|
||||
// FIXME Permission check for TabParent in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
ContentParent* parent = Manager()->AsContentParent();
|
||||
ContentParent* parent = static_cast<ContentParent*>(Manager());
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
parent && principal && !AssertAppPrincipal(parent, principal)) {
|
||||
principal && !AssertAppPrincipal(parent, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
|
||||
CpowIdHolder cpows(parent->GetCPOWManager(), aCpows);
|
||||
return ReceiveMessage(aMessage, true, &cloneData, &cpows, aPrincipal, aJSONRetVal);
|
||||
}
|
||||
|
||||
@ -1016,16 +1009,15 @@ TabParent::RecvAsyncMessage(const nsString& aMessage,
|
||||
const InfallibleTArray<CpowEntry>& aCpows,
|
||||
const IPC::Principal& aPrincipal)
|
||||
{
|
||||
// FIXME Permission check for TabParent in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
ContentParent* parent = Manager()->AsContentParent();
|
||||
ContentParent* parent = static_cast<ContentParent*>(Manager());
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
parent && principal && !AssertAppPrincipal(parent, principal)) {
|
||||
principal && !AssertAppPrincipal(parent, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
|
||||
CpowIdHolder cpows(parent->GetCPOWManager(), aCpows);
|
||||
return ReceiveMessage(aMessage, false, &cloneData, &cpows, aPrincipal, nullptr);
|
||||
}
|
||||
|
||||
@ -1710,11 +1702,11 @@ TabParent::RecvPIndexedDBConstructor(PIndexedDBParent* aActor,
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_ASSERTION(Manager(), "Null manager?!");
|
||||
ContentParent* contentParent = Manager();
|
||||
NS_ASSERTION(contentParent, "Null manager?!");
|
||||
|
||||
nsRefPtr<IDBFactory> factory;
|
||||
rv = IDBFactory::Create(window, aGroup, aASCIIOrigin,
|
||||
Manager()->AsContentParent(),
|
||||
rv = IDBFactory::Create(window, aGroup, aASCIIOrigin, contentParent,
|
||||
getter_AddRefs(factory));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
|
@ -43,7 +43,7 @@ class RenderFrameParent;
|
||||
namespace dom {
|
||||
|
||||
class ClonedMessageData;
|
||||
class nsIContentParent;
|
||||
class ContentParent;
|
||||
class Element;
|
||||
struct StructuredCloneData;
|
||||
|
||||
@ -61,7 +61,7 @@ public:
|
||||
// nsITabParent
|
||||
NS_DECL_NSITABPARENT
|
||||
|
||||
TabParent(nsIContentParent* aManager, const TabContext& aContext, uint32_t aChromeFlags);
|
||||
TabParent(ContentParent* aManager, const TabContext& aContext, uint32_t aChromeFlags);
|
||||
virtual ~TabParent();
|
||||
Element* GetOwnerElement() const { return mFrameElement; }
|
||||
void SetOwnerElement(Element* aElement);
|
||||
@ -291,7 +291,7 @@ public:
|
||||
static TabParent* GetFrom(nsFrameLoader* aFrameLoader);
|
||||
static TabParent* GetFrom(nsIContent* aContent);
|
||||
|
||||
nsIContentParent* Manager() { return mManager; }
|
||||
ContentParent* Manager() { return mManager; }
|
||||
|
||||
/**
|
||||
* Let managees query if Destroy() is already called so they don't send out
|
||||
@ -368,7 +368,7 @@ private:
|
||||
already_AddRefed<nsFrameLoader> GetFrameLoader() const;
|
||||
already_AddRefed<nsIWidget> GetWidget() const;
|
||||
layout::RenderFrameParent* GetRenderFrame();
|
||||
nsRefPtr<nsIContentParent> mManager;
|
||||
nsRefPtr<ContentParent> mManager;
|
||||
void TryCacheDPIAndScale();
|
||||
|
||||
CSSPoint AdjustTapToChildWidget(const CSSPoint& aPoint);
|
||||
|
@ -25,7 +25,6 @@ EXPORTS.mozilla.dom += [
|
||||
'FileDescriptorSetChild.h',
|
||||
'FileDescriptorSetParent.h',
|
||||
'FilePickerParent.h',
|
||||
'nsIContentParent.h',
|
||||
'PermissionMessageUtils.h',
|
||||
'StructuredCloneUtils.h',
|
||||
'TabChild.h',
|
||||
@ -49,7 +48,6 @@ UNIFIED_SOURCES += [
|
||||
'FileDescriptorSetChild.cpp',
|
||||
'FileDescriptorSetParent.cpp',
|
||||
'FilePickerParent.cpp',
|
||||
'nsIContentParent.cpp',
|
||||
'PermissionMessageUtils.cpp',
|
||||
'PreallocatedProcessManager.cpp',
|
||||
'ProcessPriorityManager.cpp',
|
||||
|
@ -1,294 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=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 "nsIContentParent.h"
|
||||
|
||||
#include "mozilla/AppProcessChecker.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/PTabContext.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/dom/StructuredCloneUtils.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/dom/ipc/nsIRemoteBlob.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "JavaScriptParent.h"
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
using namespace mozilla::jsipc;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
nsIContentParent::nsIContentParent()
|
||||
{
|
||||
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
|
||||
}
|
||||
|
||||
ContentParent*
|
||||
nsIContentParent::AsContentParent()
|
||||
{
|
||||
MOZ_ASSERT(IsContentParent());
|
||||
return static_cast<ContentParent*>(this);
|
||||
}
|
||||
|
||||
PJavaScriptParent*
|
||||
nsIContentParent::AllocPJavaScriptParent()
|
||||
{
|
||||
nsCOMPtr<nsIJSRuntimeService> svc =
|
||||
do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
|
||||
NS_ENSURE_TRUE(svc, nullptr);
|
||||
|
||||
JSRuntime *rt;
|
||||
svc->GetRuntime(&rt);
|
||||
NS_ENSURE_TRUE(svc, nullptr);
|
||||
|
||||
nsAutoPtr<JavaScriptParent> parent(new JavaScriptParent(rt));
|
||||
if (!parent->init()) {
|
||||
return nullptr;
|
||||
}
|
||||
return parent.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
nsIContentParent::DeallocPJavaScriptParent(PJavaScriptParent* aParent)
|
||||
{
|
||||
static_cast<JavaScriptParent*>(aParent)->decref();
|
||||
return true;
|
||||
}
|
||||
|
||||
PBrowserParent*
|
||||
nsIContentParent::AllocPBrowserParent(const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const uint64_t& aId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
unused << aChromeFlags;
|
||||
unused << aId;
|
||||
unused << aIsForApp;
|
||||
unused << aIsForBrowser;
|
||||
|
||||
const IPCTabAppBrowserContext& appBrowser = aContext.appBrowserContext();
|
||||
|
||||
// We don't trust the IPCTabContext we receive from the child, so we'll bail
|
||||
// if we receive an IPCTabContext that's not a PopupIPCTabContext.
|
||||
// (PopupIPCTabContext lets the child process prove that it has access to
|
||||
// the app it's trying to open.)
|
||||
if (appBrowser.type() != IPCTabAppBrowserContext::TPopupIPCTabContext) {
|
||||
NS_ERROR("Unexpected IPCTabContext type. Aborting AllocPBrowserParent.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const PopupIPCTabContext& popupContext = appBrowser.get_PopupIPCTabContext();
|
||||
TabParent* opener = static_cast<TabParent*>(popupContext.openerParent());
|
||||
if (!opener) {
|
||||
NS_ERROR("Got null opener from child; aborting AllocPBrowserParent.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Popup windows of isBrowser frames must be isBrowser if the parent
|
||||
// isBrowser. Allocating a !isBrowser frame with same app ID would allow
|
||||
// the content to access data it's not supposed to.
|
||||
if (!popupContext.isBrowserElement() && opener->IsBrowserElement()) {
|
||||
NS_ERROR("Child trying to escalate privileges! Aborting AllocPBrowserParent.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MaybeInvalidTabContext tc(aContext);
|
||||
if (!tc.IsValid()) {
|
||||
NS_ERROR(nsPrintfCString("Child passed us an invalid TabContext. (%s) "
|
||||
"Aborting AllocPBrowserParent.",
|
||||
tc.GetInvalidReason()).get());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TabParent* parent = new TabParent(this, tc.GetTabContext(), aChromeFlags);
|
||||
|
||||
// We release this ref in DeallocPBrowserParent()
|
||||
NS_ADDREF(parent);
|
||||
return parent;
|
||||
}
|
||||
|
||||
bool
|
||||
nsIContentParent::DeallocPBrowserParent(PBrowserParent* aFrame)
|
||||
{
|
||||
TabParent* parent = static_cast<TabParent*>(aFrame);
|
||||
NS_RELEASE(parent);
|
||||
return true;
|
||||
}
|
||||
|
||||
PBlobParent*
|
||||
nsIContentParent::AllocPBlobParent(const BlobConstructorParams& aParams)
|
||||
{
|
||||
return BlobParent::Create(this, aParams);
|
||||
}
|
||||
|
||||
bool
|
||||
nsIContentParent::DeallocPBlobParent(PBlobParent* aActor)
|
||||
{
|
||||
delete aActor;
|
||||
return true;
|
||||
}
|
||||
|
||||
BlobParent*
|
||||
nsIContentParent::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aBlob);
|
||||
|
||||
// If the blob represents a remote blob for this ContentParent then we can
|
||||
// simply pass its actor back here.
|
||||
if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlob)) {
|
||||
if (BlobParent* actor = static_cast<BlobParent*>(
|
||||
static_cast<PBlobParent*>(remoteBlob->GetPBlob()))) {
|
||||
MOZ_ASSERT(actor);
|
||||
|
||||
if (actor->Manager() == this) {
|
||||
return actor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All blobs shared between processes must be immutable.
|
||||
nsCOMPtr<nsIMutable> mutableBlob = do_QueryInterface(aBlob);
|
||||
if (!mutableBlob || NS_FAILED(mutableBlob->SetMutable(false))) {
|
||||
NS_WARNING("Failed to make blob immutable!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// XXX This is only safe so long as all blob implementations in our tree
|
||||
// inherit nsDOMFileBase. If that ever changes then this will need to grow
|
||||
// a real interface or something.
|
||||
const auto* blob = static_cast<nsDOMFileBase*>(aBlob);
|
||||
|
||||
ChildBlobConstructorParams params;
|
||||
|
||||
if (blob->IsSizeUnknown() || blob->IsDateUnknown()) {
|
||||
// We don't want to call GetSize or GetLastModifiedDate
|
||||
// yet since that may stat a file on the main thread
|
||||
// here. Instead we'll learn the size lazily from the
|
||||
// other process.
|
||||
params = MysteryBlobConstructorParams();
|
||||
}
|
||||
else {
|
||||
nsString contentType;
|
||||
nsresult rv = aBlob->GetType(contentType);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
uint64_t length;
|
||||
rv = aBlob->GetSize(&length);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMFile> file = do_QueryInterface(aBlob);
|
||||
if (file) {
|
||||
FileBlobConstructorParams fileParams;
|
||||
|
||||
rv = file->GetMozLastModifiedDate(&fileParams.modDate());
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
rv = file->GetName(fileParams.name());
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
fileParams.contentType() = contentType;
|
||||
fileParams.length() = length;
|
||||
|
||||
params = fileParams;
|
||||
} else {
|
||||
NormalBlobConstructorParams blobParams;
|
||||
blobParams.contentType() = contentType;
|
||||
blobParams.length() = length;
|
||||
params = blobParams;
|
||||
}
|
||||
}
|
||||
|
||||
BlobParent* actor = BlobParent::Create(this, aBlob);
|
||||
NS_ENSURE_TRUE(actor, nullptr);
|
||||
|
||||
return SendPBlobConstructor(actor, params) ? actor : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
nsIContentParent::RecvSyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
const InfallibleTArray<CpowEntry>& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
InfallibleTArray<nsString>* aRetvals)
|
||||
{
|
||||
// FIXME Permission check in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
ContentParent* parent = AsContentParent();
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
parent && principal && !AssertAppPrincipal(parent, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
||||
if (ppm) {
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(GetCPOWManager(), aCpows);
|
||||
|
||||
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
||||
aMsg, true, &cloneData, &cpows, aPrincipal, aRetvals);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
nsIContentParent::AnswerRpcMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
const InfallibleTArray<CpowEntry>& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
InfallibleTArray<nsString>* aRetvals)
|
||||
{
|
||||
// FIXME Permission check in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
ContentParent* parent = AsContentParent();
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
parent && principal && !AssertAppPrincipal(parent, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
||||
if (ppm) {
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(GetCPOWManager(), aCpows);
|
||||
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
||||
aMsg, true, &cloneData, &cpows, aPrincipal, aRetvals);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
nsIContentParent::RecvAsyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
const InfallibleTArray<CpowEntry>& aCpows,
|
||||
const IPC::Principal& aPrincipal)
|
||||
{
|
||||
// FIXME Permission check in Content process
|
||||
nsIPrincipal* principal = aPrincipal;
|
||||
ContentParent* parent = AsContentParent();
|
||||
if (!Preferences::GetBool("dom.testing.ignore_ipc_principal", false) &&
|
||||
parent && principal && !AssertAppPrincipal(parent, principal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
||||
if (ppm) {
|
||||
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
|
||||
CpowIdHolder cpows(GetCPOWManager(), aCpows);
|
||||
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
||||
aMsg, false, &cloneData, &cpows, aPrincipal, nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,95 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=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_nsIContentParent_h
|
||||
#define mozilla_dom_nsIContentParent_h
|
||||
|
||||
#include "mozilla/dom/ipc/Blob.h"
|
||||
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_ICONTENTPARENT_IID \
|
||||
{ 0xeeec9ebf, 0x8ecf, 0x4e38, \
|
||||
{ 0x81, 0xda, 0xb7, 0x34, 0x13, 0x7e, 0xac, 0xf3 } }
|
||||
|
||||
class nsFrameMessageManager;
|
||||
|
||||
namespace IPC {
|
||||
class Principal;
|
||||
} // namespace IPC
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace jsipc {
|
||||
class PJavaScriptParent;
|
||||
class JavaScriptParent;
|
||||
class CpowEntry;
|
||||
} // namespace jsipc
|
||||
|
||||
namespace dom {
|
||||
struct IPCTabContext;
|
||||
class ContentParent;
|
||||
|
||||
class nsIContentParent : public nsISupports
|
||||
, public mozilla::dom::ipc::MessageManagerCallback
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTPARENT_IID)
|
||||
|
||||
nsIContentParent();
|
||||
BlobParent* GetOrCreateActorForBlob(nsIDOMBlob* aBlob);
|
||||
|
||||
virtual uint64_t ChildID() = 0;
|
||||
|
||||
virtual PBlobParent* SendPBlobConstructor(
|
||||
PBlobParent* actor,
|
||||
const BlobConstructorParams& params) NS_WARN_UNUSED_RESULT = 0;
|
||||
|
||||
virtual jsipc::JavaScriptParent *GetCPOWManager() = 0;
|
||||
|
||||
virtual bool IsContentParent() { return false; }
|
||||
ContentParent* AsContentParent();
|
||||
|
||||
protected: // IPDL methods
|
||||
virtual mozilla::jsipc::PJavaScriptParent* AllocPJavaScriptParent();
|
||||
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*);
|
||||
|
||||
virtual PBrowserParent* AllocPBrowserParent(const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const uint64_t& aId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser);
|
||||
virtual bool DeallocPBrowserParent(PBrowserParent* frame);
|
||||
|
||||
virtual PBlobParent* AllocPBlobParent(const BlobConstructorParams& aParams);
|
||||
virtual bool DeallocPBlobParent(PBlobParent*);
|
||||
|
||||
virtual bool RecvSyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
const InfallibleTArray<jsipc::CpowEntry>& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
InfallibleTArray<nsString>* aRetvals);
|
||||
virtual bool AnswerRpcMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
const InfallibleTArray<jsipc::CpowEntry>& aCpows,
|
||||
const IPC::Principal& aPrincipal,
|
||||
InfallibleTArray<nsString>* aRetvals);
|
||||
virtual bool RecvAsyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
const InfallibleTArray<jsipc::CpowEntry>& aCpows,
|
||||
const IPC::Principal& aPrincipal);
|
||||
|
||||
protected: // members
|
||||
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentParent, NS_ICONTENTPARENT_IID)
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_nsIContentParent_h */
|
Loading…
Reference in New Issue
Block a user