зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1126042 - Use different window IDs for different processes (r=smaug)
This commit is contained in:
Родитель
bad8bf235d
Коммит
f0c84ea9eb
|
@ -274,7 +274,6 @@ static int32_t gRunningTimeoutDepth = 0;
|
|||
static bool gMouseDown = false;
|
||||
static bool gDragServiceDisabled = false;
|
||||
static FILE *gDumpFile = nullptr;
|
||||
static uint64_t gNextWindowID = 0;
|
||||
static uint32_t gSerialCounter = 0;
|
||||
static uint32_t gTimeoutsRecentlySet = 0;
|
||||
static TimeStamp gLastRecordedRecentTimeouts;
|
||||
|
@ -562,6 +561,13 @@ nsTimeout::HasRefCntOne()
|
|||
return mRefCnt.get() == 1;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
extern uint64_t
|
||||
NextWindowID();
|
||||
}
|
||||
}
|
||||
|
||||
nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
|
||||
: mFrameElement(nullptr), mDocShell(nullptr), mModalStateDepth(0),
|
||||
mRunningTimeout(nullptr), mMutationBits(0), mIsDocumentLoaded(false),
|
||||
|
@ -576,7 +582,7 @@ nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
|
|||
mAudioMuted(false), mAudioVolume(1.0),
|
||||
mInnerWindow(nullptr), mOuterWindow(aOuterWindow),
|
||||
// Make sure no actual window ends up with mWindowID == 0
|
||||
mWindowID(++gNextWindowID), mHasNotifiedGlobalCreated(false),
|
||||
mWindowID(NextWindowID()), mHasNotifiedGlobalCreated(false),
|
||||
mMarkedCCGeneration(0), mSendAfterRemotePaint(false)
|
||||
{}
|
||||
|
||||
|
|
|
@ -2524,6 +2524,41 @@ ContentChild::GetBrowserOrId(TabChild* aTabChild)
|
|||
}
|
||||
}
|
||||
|
||||
// This code goes here rather than nsGlobalWindow.cpp because nsGlobalWindow.cpp
|
||||
// can't include ContentChild.h since it includes windows.h.
|
||||
|
||||
static uint64_t gNextWindowID = 0;
|
||||
|
||||
// We use only 53 bits for the window ID so that it can be converted to and from
|
||||
// a JS value without loss of precision. The upper bits of the window ID hold the
|
||||
// process ID. The lower bits identify the window.
|
||||
static const uint64_t kWindowIDTotalBits = 53;
|
||||
static const uint64_t kWindowIDProcessBits = 22;
|
||||
static const uint64_t kWindowIDWindowBits = kWindowIDTotalBits - kWindowIDProcessBits;
|
||||
|
||||
// Try to return a window ID that is unique across processes and that will never
|
||||
// be recycled.
|
||||
uint64_t
|
||||
NextWindowID()
|
||||
{
|
||||
uint64_t processID = 0;
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
processID = cc->GetID();
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(processID < (uint64_t(1) << kWindowIDProcessBits));
|
||||
uint64_t processBits = processID & ((uint64_t(1) << kWindowIDProcessBits) - 1);
|
||||
|
||||
// Make sure no actual window ends up with mWindowID == 0.
|
||||
uint64_t windowID = ++gNextWindowID;
|
||||
|
||||
MOZ_RELEASE_ASSERT(windowID < (uint64_t(1) << kWindowIDWindowBits));
|
||||
uint64_t windowBits = windowID & ((uint64_t(1) << kWindowIDWindowBits) - 1);
|
||||
|
||||
return (processBits << kWindowIDWindowBits) | windowBits;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -481,6 +481,9 @@ private:
|
|||
DISALLOW_EVIL_CONSTRUCTORS(ContentChild);
|
||||
};
|
||||
|
||||
uint64_t
|
||||
NextWindowID();
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче