Bug 1020172 - Part 1: Replace process id with ContentParentId type. r=khuey

This commit is contained in:
Kershaw Chang 2014-10-24 02:28:00 -04:00
parent 67c1462977
commit 8a7316ff02
17 changed files with 129 additions and 55 deletions

View File

@ -83,14 +83,14 @@ bool
ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentBridgeChild::SendPBrowserConstructor(aActor,
aContext,
aChromeFlags,
aID,
aCpID,
aIsForApp,
aIsForBrowser);
}
@ -123,13 +123,13 @@ ContentBridgeChild::DeallocPJavaScriptChild(PJavaScriptChild *child)
PBrowserChild*
ContentBridgeChild::AllocPBrowserChild(const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentChild::AllocPBrowserChild(aContext,
aChromeFlags,
aID,
aCpID,
aIsForApp,
aIsForBrowser);
}
@ -144,14 +144,14 @@ bool
ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return ContentChild::GetSingleton()->RecvPBrowserConstructor(aActor,
aContext,
aChromeFlags,
aID,
aCpID,
aIsForApp,
aIsForBrowser);
}

View File

@ -41,7 +41,7 @@ public:
virtual bool SendPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
@ -50,14 +50,14 @@ protected:
virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool DeallocPBrowserChild(PBrowserChild*) MOZ_OVERRIDE;
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;

View File

@ -89,14 +89,14 @@ PBrowserParent*
ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentBridgeParent::SendPBrowserConstructor(aActor,
aContext,
aChromeFlags,
aID,
aCpID,
aIsForApp,
aIsForBrowser);
}
@ -128,13 +128,13 @@ ContentBridgeParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
PBrowserParent*
ContentBridgeParent::AllocPBrowserParent(const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentParent::AllocPBrowserParent(aContext,
aChromeFlags,
aID,
aCpID,
aIsForApp,
aIsForBrowser);
}

View File

@ -9,6 +9,7 @@
#include "mozilla/dom/PContentBridgeParent.h"
#include "mozilla/dom/nsIContentParent.h"
#include "mozilla/dom/ipc/IdType.h"
namespace mozilla {
namespace dom {
@ -35,13 +36,13 @@ public:
SendPBrowserConstructor(PBrowserParent* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
jsipc::JavaScriptShared* GetCPOWManager() MOZ_OVERRIDE;
virtual uint64_t ChildID() MOZ_OVERRIDE
virtual ContentParentId ChildID() MOZ_OVERRIDE
{
return mChildID;
}
@ -57,7 +58,7 @@ public:
protected:
virtual ~ContentBridgeParent();
void SetChildID(uint64_t aId)
void SetChildID(ContentParentId aId)
{
mChildID = aId;
}
@ -88,7 +89,7 @@ protected:
virtual PBrowserParent*
AllocPBrowserParent(const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool DeallocPBrowserParent(PBrowserParent*) MOZ_OVERRIDE;
@ -103,7 +104,7 @@ protected:
protected: // members
nsRefPtr<ContentBridgeParent> mSelfRef;
Transport* mTransport; // owned
uint64_t mChildID;
ContentParentId mChildID;
bool mIsForApp;
bool mIsForBrowser;

View File

@ -1111,13 +1111,13 @@ ContentChild::DeallocPJavaScriptChild(PJavaScriptChild *aChild)
PBrowserChild*
ContentChild::AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentChild::AllocPBrowserChild(aContext,
aChromeFlags,
aID,
aCpID,
aIsForApp,
aIsForBrowser);
}
@ -1126,14 +1126,14 @@ bool
ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentChild::SendPBrowserConstructor(aActor,
aContext,
aChromeFlags,
aID,
aCpID,
aIsForApp,
aIsForBrowser);
}
@ -1142,7 +1142,7 @@ bool
ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
@ -1166,7 +1166,7 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
// Redo InitProcessAttributes() when the app or browser is really
// launching so the attributes will be correct.
mID = aID;
mID = aCpID;
mIsForApp = aIsForApp;
mIsForBrowser = aIsForBrowser;
InitProcessAttributes();

View File

@ -133,7 +133,7 @@ public:
virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserChild(PBrowserChild*);
@ -354,7 +354,7 @@ public:
// cache the value
nsString &GetIndexedDBPath();
uint64_t GetID() { return mID; }
ContentParentId GetID() { return mID; }
bool IsForApp() { return mIsForApp; }
bool IsForBrowser() { return mIsForBrowser; }
@ -372,14 +372,14 @@ public:
virtual bool SendPBrowserConstructor(PBrowserChild* actor,
const IPCTabContext& context,
const uint32_t& chromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual PDocAccessibleChild* AllocPDocAccessibleChild(PDocAccessibleChild*, const uint64_t&) MOZ_OVERRIDE;
@ -412,7 +412,7 @@ private:
* We expect our content parent to set this ID immediately after opening a
* channel to us.
*/
uint64_t mID;
ContentParentId mID;
AppInfo mAppInfo;

View File

@ -2780,10 +2780,10 @@ ContentParent::AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTranspo
}
bool
ContentParent::RecvGetProcessAttributes(uint64_t* aId,
ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp, bool* aIsForBrowser)
{
*aId = mChildID;
*aCpId = mChildID;
*aIsForApp = IsForApp();
*aIsForBrowser = mIsForBrowser;
@ -2833,13 +2833,13 @@ ContentParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
PBrowserParent*
ContentParent::AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aId,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentParent::AllocPBrowserParent(aContext,
aChromeFlags,
aId,
aCpId,
aIsForApp,
aIsForBrowser);
}
@ -3827,14 +3827,14 @@ PBrowserParent*
ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aId,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentParent::SendPBrowserConstructor(aActor,
aContext,
aChromeFlags,
aId,
aCpId,
aIsForApp,
aIsForBrowser);
}

View File

@ -217,7 +217,7 @@ public:
*/
void KillHard();
uint64_t ChildID() MOZ_OVERRIDE { return mChildID; }
ContentParentId ChildID() MOZ_OVERRIDE { return mChildID; }
const nsString& AppManifestURL() const { return mAppManifestURL; }
bool IsPreallocated();
@ -318,7 +318,7 @@ private:
PBrowserParent* actor,
const IPCTabContext& context,
const uint32_t& chromeFlags,
const uint64_t& aId,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
using PContentParent::SendPTestShellConstructor;
@ -409,7 +409,7 @@ private:
AllocPBackgroundParent(Transport* aTransport, ProcessId aOtherProcess)
MOZ_OVERRIDE;
virtual bool RecvGetProcessAttributes(uint64_t* aId,
virtual bool RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser) MOZ_OVERRIDE;
virtual bool RecvGetXPCOMProcessAttributes(bool* aIsOffline,
@ -422,7 +422,7 @@ private:
virtual bool DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParent*) MOZ_OVERRIDE;
virtual PBrowserParent* AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aId,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool DeallocPBrowserParent(PBrowserParent* frame) MOZ_OVERRIDE;
@ -692,7 +692,7 @@ private:
GeckoChildProcessHost* mSubprocess;
ContentParent* mOpener;
uint64_t mChildID;
ContentParentId mChildID;
int32_t mGeolocationWatchID;
nsString mAppManifestURL;

66
dom/ipc/IdType.h Normal file
View File

@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et 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_IdType_h
#define mozilla_dom_IdType_h
namespace mozilla {
namespace dom {
class ContentParent;
template<typename T>
class IdType
{
friend struct IPC::ParamTraits<IdType<T>>;
public:
IdType() : mId(0) {}
explicit IdType(uint64_t aId) : mId(aId) {}
operator uint64_t() const { return mId; }
IdType& operator=(uint64_t aId)
{
mId = aId;
return *this;
}
bool operator<(const IdType& rhs)
{
return mId < rhs.mId;
}
private:
uint64_t mId;
};
typedef IdType<ContentParent> ContentParentId;
} // namespace dom
} // namespace mozilla
namespace IPC {
template<typename T>
struct ParamTraits<mozilla::dom::IdType<T>>
{
typedef mozilla::dom::IdType<T> paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mId);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return ReadParam(aMsg, aIter, &aResult->mId);
}
};
}
#endif

View File

@ -67,6 +67,7 @@ using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
using mozilla::dom::quota::PersistenceType from "mozilla/dom/quota/PersistenceType.h";
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
using gfxIntSize from "nsSize.h";
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
union ChromeRegistryItem
{
@ -386,7 +387,7 @@ both:
//
// Keep the last 3 attributes in sync with GetProcessAttributes!
async PBrowser(IPCTabContext context, uint32_t chromeFlags,
uint64_t id, bool isForApp, bool isForBrowser);
ContentParentId cpId, bool isForApp, bool isForBrowser);
async PBlob(BlobConstructorParams params);
@ -520,7 +521,7 @@ parent:
* Keep the return values in sync with PBrowser()!
*/
sync GetProcessAttributes()
returns (uint64_t id, bool isForApp, bool isForBrowser);
returns (ContentParentId cpId, bool isForApp, bool isForBrowser);
sync GetXPCOMProcessAttributes()
returns (bool isOffline, nsString[] dictionaries,
ClipboardCapabilities clipboardCaps);

View File

@ -14,6 +14,7 @@ include JavaScriptTypes;
include PTabContext;
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
namespace mozilla {
namespace dom {
@ -42,7 +43,7 @@ both:
// Both the parent and the child can construct the PBrowser.
// See the comment in PContent::PBrowser().
async PBrowser(IPCTabContext context, uint32_t chromeFlags,
uint64_t id, bool isForApp, bool isForBrowser);
ContentParentId cpId, bool isForApp, bool isForBrowser);
async PBlob(BlobConstructorParams params);

View File

@ -472,14 +472,15 @@ ProcessPriorityManagerImpl::GetParticularProcessPriorityManager(
ContentParent* aContentParent)
{
nsRefPtr<ParticularProcessPriorityManager> pppm;
mParticularManagers.Get(aContentParent->ChildID(), &pppm);
uint64_t cpId = aContentParent->ChildID();
mParticularManagers.Get(cpId, &pppm);
if (!pppm) {
pppm = new ParticularProcessPriorityManager(aContentParent);
pppm->Init();
mParticularManagers.Put(aContentParent->ChildID(), pppm);
mParticularManagers.Put(cpId, pppm);
FireTestOnlyObserverNotification("process-created",
nsPrintfCString("%lld", aContentParent->ChildID()));
nsPrintfCString("%lld", cpId));
}
return pppm.forget();

View File

@ -11,6 +11,7 @@ EXPORTS += [
EXPORTS.mozilla.dom.ipc += [
'BlobChild.h',
'BlobParent.h',
'IdType.h',
'nsIRemoteBlob.h',
]

View File

@ -52,7 +52,7 @@ nsIContentChild::DeallocPJavaScriptChild(PJavaScriptChild* aChild)
PBrowserChild*
nsIContentChild::AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{

View File

@ -7,6 +7,8 @@
#ifndef mozilla_dom_nsIContentChild_h
#define mozilla_dom_nsIContentChild_h
#include "mozilla/dom/ipc/IdType.h"
#include "nsISupports.h"
#include "nsTArrayForwardDeclare.h"
#include "mozilla/dom/CPOWManagerGetter.h"
@ -54,7 +56,7 @@ public:
SendPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) = 0;
protected:
@ -63,7 +65,7 @@ protected:
virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserChild(PBrowserChild*);

View File

@ -107,12 +107,11 @@ nsIContentParent::CanOpenBrowser(const IPCTabContext& aContext)
PBrowserParent*
nsIContentParent::AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aId,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
unused << aChromeFlags;
unused << aId;
unused << aCpId;
unused << aIsForApp;
unused << aIsForBrowser;

View File

@ -7,6 +7,8 @@
#ifndef mozilla_dom_nsIContentParent_h
#define mozilla_dom_nsIContentParent_h
#include "mozilla/dom/ipc/IdType.h"
#include "nsFrameMessageManager.h"
#include "nsISupports.h"
#include "mozilla/dom/CPOWManagerGetter.h"
@ -49,7 +51,7 @@ public:
BlobParent* GetOrCreateActorForBlob(File* aBlob);
virtual uint64_t ChildID() = 0;
virtual ContentParentId ChildID() = 0;
virtual bool IsForApp() = 0;
virtual bool IsForBrowser() = 0;
@ -61,7 +63,7 @@ public:
PBrowserParent* actor,
const IPCTabContext& context,
const uint32_t& chromeFlags,
const uint64_t& aId,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser) NS_WARN_UNUSED_RESULT = 0;
@ -77,7 +79,7 @@ protected: // IPDL methods
virtual PBrowserParent* AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aId,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserParent(PBrowserParent* frame);