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

This commit is contained in:
Kershaw Chang 2014-10-24 02:28:00 +02:00
Родитель 07c35eaef1
Коммит e94eff7080
17 изменённых файлов: 129 добавлений и 55 удалений

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

@ -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);
}

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

@ -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;

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

@ -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);
}

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

@ -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;

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

@ -1120,13 +1120,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);
}
@ -1135,14 +1135,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);
}
@ -1151,7 +1151,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)
{
@ -1175,7 +1175,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();

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

@ -137,7 +137,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*);
@ -361,7 +361,7 @@ public:
// cache the value
nsString &GetIndexedDBPath();
uint64_t GetID() { return mID; }
ContentParentId GetID() { return mID; }
bool IsForApp() { return mIsForApp; }
bool IsForBrowser() { return mIsForBrowser; }
@ -379,14 +379,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;
@ -419,7 +419,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;

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

@ -2804,10 +2804,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;
@ -2857,13 +2857,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);
}
@ -3866,14 +3866,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);
}

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

@ -222,7 +222,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();
@ -327,7 +327,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;
@ -418,7 +418,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,
@ -431,7 +431,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;
@ -701,7 +701,7 @@ private:
GeckoChildProcessHost* mSubprocess;
ContentParent* mOpener;
uint64_t mChildID;
ContentParentId mChildID;
int32_t mGeolocationWatchID;
nsString mAppManifestURL;

66
dom/ipc/IdType.h Normal 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

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

@ -70,6 +70,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
{
@ -392,7 +393,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);
@ -526,7 +527,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);

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

@ -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);

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

@ -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();

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

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

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

@ -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)
{

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

@ -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*);

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

@ -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;

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

@ -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);