Backed out 13 changesets (bug 1500948, bug 1509362, bug 1509591, bug 1448426, bug 1500949, bug 1487249, bug 1509930, bug 1500950, bug 1500944) for causing crashes and assertion failures on PBackgroundParent.cpp:696 CLOSED TREE

Backed out changeset c3fe435e473a (bug 1509362)
Backed out changeset 6494840edc17 (bug 1509591)
Backed out changeset 123b5d5a3637 (bug 1509591)
Backed out changeset bce195f98895 (bug 1509930)
Backed out changeset 66db13126408 (bug 1500950)
Backed out changeset 3b5fffae2d2b (bug 1500949)
Backed out changeset 71c3b3677db8 (bug 1500948)
Backed out changeset 784b3b56e2ab (bug 1500944)
Backed out changeset 0bad27401ddb (bug 1500944)
Backed out changeset e0f95dd96d54 (bug 1448426)
Backed out changeset c60fa11538db (bug 1487249)
Backed out changeset 0190d4ffa54f (bug 1487249)
Backed out changeset 3cd10aba9130 (bug 1487249)
This commit is contained in:
arthur.iakab 2018-11-28 02:57:32 +02:00
parent e36b9a7f34
commit af07f9b9d4
105 changed files with 499 additions and 2940 deletions

View File

@ -5,9 +5,26 @@ from __future__ import print_function
import os
import string
from mozbuild.util import FileAvoidWrite
from system_header_util import header_path
def find_in_path(file, searchpath):
for dir in searchpath.split(os.pathsep):
f = os.path.join(dir, file)
if os.path.exists(f):
return f
return ''
def header_path(header, compiler):
if compiler == 'gcc':
# we use include_next on gcc
return header
elif compiler == 'msvc':
return find_in_path(header, os.environ.get('INCLUDE', ''))
else:
# hope someone notices this ...
raise NotImplementedError(compiler)
# The 'unused' arg is the output file from the file_generate action. We actually
# generate all the files in header_list

View File

@ -1,86 +0,0 @@
# 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/.
import re
import textwrap
import string
from system_header_util import header_path
comment_re = re.compile(r'//[^\n]*\n|/\*.*\*/', re.S)
decl_re = re.compile(r'''^(.+)\s+ # type
(\w+)\s* # name
(?:\((.*)\))?$ # optional param tys
''', re.X | re.S)
def read_decls(filename):
"""Parse & yield C-style decls from an input file"""
with open(filename, 'r') as fd:
# Strip comments from the source text.
text = comment_re.sub('', fd.read())
# Parse individual declarations.
raw_decls = [d.strip() for d in text.split(';') if d.strip()]
for raw in raw_decls:
match = decl_re.match(raw)
if match is None:
raise "Invalid decl: %s" % raw
ty, name, params = match.groups()
if params is not None:
params = [a.strip() for a in params.split(',') if a.strip()]
yield ty, name, params
def generate(fd, consts_path, unicodes_path, template_path, compiler):
# Parse the template
with open(template_path, 'r') as template_fd:
template = string.Template(template_fd.read())
decls = ''
# Each constant should be saved to a temporary, and then re-assigned to a
# constant with the correct name, allowing the value to be determined by
# the actual definition.
for ty, name, args in read_decls(consts_path):
assert args is None, "parameters in const decl!"
decls += textwrap.dedent("""
#ifdef {name}
constexpr {ty} _tmp_{name} = {name};
#undef {name}
constexpr {ty} {name} = _tmp_{name};
#endif
""".format(ty=ty, name=name))
# Each unicode declaration defines a static inline function with the
# correct types which calls the 'A' or 'W'-suffixed versions of the
# function. Full types are required here to ensure that '0' to 'nullptr'
# coersions are preserved.
for ty, name, args in read_decls(unicodes_path):
assert args is not None, "argument list required for unicode decl"
# Parameter & argument string list
params = ', '.join('%s a%d' % (ty, i) for i, ty in enumerate(args))
args = ', '.join('a%d' % i for i in range(len(args)))
decls += textwrap.dedent("""
#ifdef {name}
#undef {name}
static inline {ty} WINAPI
{name}({params})
{{
#ifdef UNICODE
return {name}W({args});
#else
return {name}A({args});
#endif
}}
#endif
""".format(ty=ty, name=name, params=params, args=args))
path = header_path('windows.h', compiler)
# Write out the resulting file
fd.write(template.substitute(header_path=path, decls=decls))

View File

@ -63,19 +63,6 @@ if CONFIG['WRAP_STL_INCLUDES']:
stl.flags = [output_dir, stl_compiler, template_file]
stl.flags.extend(stl_headers)
# Wrap <windows.h> to make it easier to use correctly
# NOTE: If we aren't wrapping STL includes, we're building part of the browser
# which won't need this wrapper, such as L10N. Just don't try to generate the
# wrapper in that case.
if CONFIG['OS_ARCH'] == 'WINNT':
GENERATED_FILES += ['../dist/stl_wrappers/windows.h']
windows_h = GENERATED_FILES['../dist/stl_wrappers/windows.h']
windows_h.script = 'make-windows-h-wrapper.py:generate'
windows_h.inputs = ['windows-h-constant.decls.h',
'windows-h-unicode.decls.h',
'windows-h-wrapper.template.h']
windows_h.flags = [stl_compiler]
if CONFIG['WRAP_SYSTEM_INCLUDES']:
include('system-headers.mozbuild')
output_dir = '../dist/system_wrappers'

View File

@ -1,20 +0,0 @@
import os
def find_in_path(file, searchpath):
for dir in searchpath.split(os.pathsep):
f = os.path.join(dir, file)
if os.path.exists(f):
return f
return ''
def header_path(header, compiler):
if compiler == 'gcc':
# we use include_next on gcc
return header
elif compiler == 'msvc':
return find_in_path(header, os.environ.get('INCLUDE', ''))
else:
# hope someone notices this ...
raise NotImplementedError(compiler)

View File

@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 2; 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/. */
/*
* This file contains a series of C-style declarations for constants defined in
* windows.h using #define. Adding a new constant should be a simple as adding
* its name (and optionally type) to this file.
*
* This file is processed by generate-windows-h-wrapper.py to generate a wrapper
* for the header which removes the defines usually implementing these constants.
*
* Wrappers defined in this file will be declared as `constexpr` values,
* and will have their value derived from the windows.h define.
*
* NOTE: This is *NOT* a real C header, but rather an input to the avove script.
* Only basic declarations in the form found here are allowed.
*/
// XXX(nika): There are a lot of these (>30k)!
// This is just a set of ones I saw in a quick scan which looked problematic.
auto CREATE_NEW;
auto CREATE_ALWAYS;
auto OPEN_EXISTING;
auto OPEN_ALWAYS;
auto TRUNCATE_EXISTING;
auto INVALID_FILE_SIZE;
auto INVALID_SET_FILE_POINTER;
auto INVALID_FILE_ATTRIBUTES;
auto ANSI_NULL;
auto UNICODE_NULL;
auto MINCHAR;
auto MAXCHAR;
auto MINSHORT;
auto MAXSHORT;
auto MINLONG;
auto MAXLONG;
auto MAXBYTE;
auto MAXWORD;
auto MAXDWORD;
auto DELETE;
auto READ_CONTROL;
auto WRITE_DAC;
auto WRITE_OWNER;
auto SYNCHRONIZE;
auto MAXIMUM_ALLOWED;
auto GENERIC_READ;
auto GENERIC_WRITE;
auto GENERIC_EXECUTE;
auto GENERIC_ALL;

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +0,0 @@
/* -*- Mode: C++; tab-width: 2; 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_windows_h
#define mozilla_windows_h
// Include the "real" windows.h header. On clang/gcc, this can be done with the
// `include_next` feature, however MSVC requires a direct include path.
//
// Also turn off deprecation warnings, as we may be wrapping deprecated fns.
#if defined(__GNUC__) || defined(__clang__)
# pragma GCC system_header
# include_next <windows.h>
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#else
# include <${header_path}>
# pragma warning(push)
# pragma warning(disable: 4996 4995)
#endif // defined(__GNUC__) || defined(__clang__)
// Check if the header should be disabled
#if defined(MOZ_DISABLE_WINDOWS_WRAPPER)
#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "explicitly disabled"
#elif !defined(__cplusplus)
#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-C++ source file"
#elif !defined(__GNUC__) && !defined(__clang__) && !defined(_DLL)
#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-dynamic RTL"
#else
// We're allowed to wrap in the current context. Define `MOZ_WRAPPED_WINDOWS_H`
// to note that fact, and perform the wrapping.
#define MOZ_WRAPPED_WINDOWS_H
extern "C++" {
${decls}
} // extern "C++"
#endif // enabled
#if defined(__GNUC__) || defined(__clang__)
# pragma GCC diagnostic pop
#else
# pragma warning(pop)
#endif // defined(__GNUC__) || defined(__clang__)
#endif // !defined(mozilla_windows_h)

View File

@ -4,7 +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 "mozilla/dom/BrowsingContext.h"
#include "BrowsingContext.h"
#include "mozilla/dom/ChromeBrowsingContext.h"
#include "mozilla/dom/BrowsingContextBinding.h"

View File

@ -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 mozilla_dom_BrowsingContext_h
#define mozilla_dom_BrowsingContext_h
#ifndef BrowsingContext_h
#define BrowsingContext_h
#include "mozilla/LinkedList.h"
#include "mozilla/Maybe.h"
@ -124,8 +124,8 @@ public:
nsTArray<RefPtr<BrowsingContext>>& aBrowsingContexts);
nsISupports* GetParentObject() const;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(BrowsingContext)
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(BrowsingContext)
@ -158,5 +158,4 @@ private:
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_BrowsingContext_h)
#endif

View File

@ -4,8 +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 "mozilla/dom/ChromeBrowsingContext.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "ChromeBrowsingContext.h"
namespace mozilla {
namespace dom {
@ -63,49 +62,5 @@ ChromeBrowsingContext::Cast(const BrowsingContext* aContext)
return static_cast<const ChromeBrowsingContext*>(aContext);
}
void
ChromeBrowsingContext::GetWindowGlobals(nsTArray<RefPtr<WindowGlobalParent>>& aWindows)
{
aWindows.SetCapacity(mWindowGlobals.Count());
for (auto iter = mWindowGlobals.Iter(); !iter.Done(); iter.Next()) {
aWindows.AppendElement(iter.Get()->GetKey());
}
}
void
ChromeBrowsingContext::RegisterWindowGlobal(WindowGlobalParent* aGlobal)
{
MOZ_ASSERT(!mWindowGlobals.Contains(aGlobal), "Global already registered!");
mWindowGlobals.PutEntry(aGlobal);
}
void
ChromeBrowsingContext::UnregisterWindowGlobal(WindowGlobalParent* aGlobal)
{
MOZ_ASSERT(mWindowGlobals.Contains(aGlobal), "Global not registered!");
mWindowGlobals.RemoveEntry(aGlobal);
}
JSObject*
ChromeBrowsingContext::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return ChromeBrowsingContext_Binding::Wrap(aCx, this, aGivenProto);
}
void
ChromeBrowsingContext::Traverse(nsCycleCollectionTraversalCallback& cb)
{
ChromeBrowsingContext* tmp = this;
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindowGlobals);
}
void
ChromeBrowsingContext::Unlink()
{
ChromeBrowsingContext* tmp = this;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindowGlobals);
}
} // namespace dom
} // namespace mozilla

View File

@ -4,23 +4,19 @@
* 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_ChromeBrowsingContext_h
#define mozilla_dom_ChromeBrowsingContext_h
#ifndef ChromeBrowsingContext_h
#define ChromeBrowsingContext_h
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/RefPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
class nsIDocShell;
namespace mozilla {
namespace dom {
class WindowGlobalParent;
// ChromeBrowsingContext is a BrowsingContext living in the parent
// process, with whatever extra data that a BrowsingContext in the
// parent needs.
@ -38,18 +34,9 @@ public:
return mProcessId == aProcessId;
}
void GetWindowGlobals(nsTArray<RefPtr<WindowGlobalParent>>& aWindows);
// Called by WindowGlobalParent to register and unregister window globals.
void RegisterWindowGlobal(WindowGlobalParent* aGlobal);
void UnregisterWindowGlobal(WindowGlobalParent* aGlobal);
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
protected:
void Traverse(nsCycleCollectionTraversalCallback& cb);
void Unlink();
void Traverse(nsCycleCollectionTraversalCallback& cb) {}
void Unlink() {}
using Type = BrowsingContext::Type;
ChromeBrowsingContext(BrowsingContext* aParent,
@ -65,12 +52,8 @@ private:
// XXX(farre): Store a ContentParent pointer here rather than mProcessId?
// Indicates which process owns the docshell.
uint64_t mProcessId;
// All live window globals within this browsing context.
nsTHashtable<nsRefPtrHashKey<WindowGlobalParent>> mWindowGlobals;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_ChromeBrowsingContext_h)
#endif

View File

@ -424,7 +424,7 @@ SOURCES += [
'nsDOMWindowUtils.cpp',
# Conflicts with windows.h's definition of SendMessage.
'nsFrameMessageManager.cpp',
# These files have a #error "Never include unwrapped windows.h in this file!"
# These files have a #error "Never include windows.h in this file!"
'nsGlobalWindowInner.cpp',
'nsGlobalWindowOuter.cpp',
# Conflicts with windows.h's definition of LoadImage.

View File

@ -992,6 +992,7 @@ RemotePermissionRequest::RemotePermissionRequest(
nsPIDOMWindowInner* aWindow)
: mRequest(aRequest)
, mWindow(aWindow)
, mIPCOpen(false)
, mDestroyed(false)
{
mListener = new VisibilityChangeListener(mWindow);
@ -1000,8 +1001,7 @@ RemotePermissionRequest::RemotePermissionRequest(
RemotePermissionRequest::~RemotePermissionRequest()
{
MOZ_ASSERT(!mozilla::ipc::IProtocol::IPCOpen(),
"Protocol must not be open when RemotePermissionRequest is destroyed.");
MOZ_ASSERT(!mIPCOpen, "Protocol must not be open when RemotePermissionRequest is destroyed.");
}
void

View File

@ -234,19 +234,19 @@ public:
void IPDLAddRef()
{
mIPCOpen = true;
AddRef();
}
void IPDLRelease()
{
mIPCOpen = false;
Release();
}
void Destroy();
bool IPCOpen() const {
return mozilla::ipc::IProtocol::IPCOpen() && !mDestroyed;
}
bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
private:
virtual ~RemotePermissionRequest();
@ -256,6 +256,7 @@ private:
nsCOMPtr<nsIContentPermissionRequest> mRequest;
nsCOMPtr<nsPIDOMWindowInner> mWindow;
bool mIPCOpen;
bool mDestroyed;
RefPtr<VisibilityChangeListener> mListener;
};

View File

@ -271,8 +271,6 @@
#include "mozilla/DocLoadingTimelineMarker.h"
#include "mozilla/dom/WindowGlobalChild.h"
#include "nsISpeculativeConnect.h"
#include "mozilla/MediaManager.h"
@ -3097,13 +3095,6 @@ nsIDocument::SetDocumentURI(nsIURI* aURI)
if (!equalBases) {
RefreshLinkHrefs();
}
// Tell our WindowGlobalParent that the document's URI has been changed.
nsPIDOMWindowInner* inner = GetInnerWindow();
WindowGlobalChild* wgc = inner ? inner->GetWindowGlobalChild() : nullptr;
if (wgc) {
Unused << wgc->SendUpdateDocumentURI(mDocumentURI);
}
}
static void

View File

@ -100,7 +100,6 @@
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/dom/ParentSHistory.h"
#include "mozilla/dom/ChildSHistory.h"
#include "mozilla/dom/ChromeBrowsingContext.h"
#include "mozilla/dom/HTMLBodyElement.h"
@ -3175,19 +3174,6 @@ nsFrameLoader::LoadContext()
return loadContext.forget();
}
already_AddRefed<BrowsingContext>
nsFrameLoader::GetBrowsingContext()
{
RefPtr<BrowsingContext> browsingContext;
if (IsRemoteFrame() &&
(mRemoteBrowser || TryRemoteBrowser())) {
browsingContext = mRemoteBrowser->GetBrowsingContext();
} else if (GetDocShell(IgnoreErrors())) {
browsingContext = nsDocShell::Cast(mDocShell)->GetBrowsingContext();
}
return browsingContext.forget();
}
void
nsFrameLoader::InitializeBrowserAPI()
{

View File

@ -48,7 +48,6 @@ namespace mozilla {
class OriginAttributes;
namespace dom {
class BrowsingContext;
class ChromeMessageSender;
class ContentParent;
class InProcessTabChildMessageManager;
@ -122,8 +121,6 @@ public:
already_AddRefed<nsILoadContext> LoadContext();
already_AddRefed<mozilla::dom::BrowsingContext> GetBrowsingContext();
/**
* Start loading the frame. This method figures out what to load
* from the owner content in the frame loader.

View File

@ -258,8 +258,6 @@
#include "mozilla/dom/ClientSource.h"
#include "mozilla/dom/ClientState.h"
#include "mozilla/dom/WindowGlobalChild.h"
// Apple system headers seem to have a check() macro. <sigh>
#ifdef check
class nsIScriptTimeoutHandler;
@ -1350,11 +1348,6 @@ nsGlobalWindowInner::FreeInnerObjects(bool aForDocumentOpen)
}
}
if (mWindowGlobalChild && !mWindowGlobalChild->IsClosed()) {
mWindowGlobalChild->Send__delete__(mWindowGlobalChild);
}
mWindowGlobalChild = nullptr;
mIntlUtils = nullptr;
}
@ -1745,15 +1738,6 @@ nsGlobalWindowInner::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument)
// out of sync.
ClearDocumentDependentSlots(aCx);
// FIXME: Currently, devtools can crete a fallback webextension window global
// in the content process which does not have a corresponding TabChild actor.
// This means we have no actor to be our parent. (Bug 1498293)
MOZ_DIAGNOSTIC_ASSERT(!mWindowGlobalChild,
"Shouldn't have created WindowGlobalChild yet!");
if (XRE_IsParentProcess() || mTabChild) {
mWindowGlobalChild = WindowGlobalChild::Create(this);
}
#ifdef DEBUG
mLastOpenedURI = aDocument->GetDocumentURI();
#endif
@ -7832,9 +7816,8 @@ nsGlobalWindowInner::FireOnNewGlobalObject()
JS_FireOnNewGlobalObject(aes.cx(), global);
}
#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H)
#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON)
#error "Never include unwrapped windows.h in this file!"
#ifdef _WINDOWS_
#error "Never include windows.h in this file!"
#endif
already_AddRefed<Promise>

View File

@ -7734,9 +7734,8 @@ nsGlobalWindowOuter::ReportLargeAllocStatus()
message);
}
#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H)
#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON)
#error "Never include unwrapped windows.h in this file!"
#ifdef _WINDOWS_
#error "Never include windows.h in this file!"
#endif
// Helper called by methods that move/resize the window,

View File

@ -68,7 +68,6 @@ class ServiceWorker;
class ServiceWorkerDescriptor;
class Timeout;
class TimeoutManager;
class WindowGlobalChild;
class CustomElementRegistry;
enum class CallerType : uint32_t;
} // namespace dom
@ -397,11 +396,6 @@ public:
return mDoc;
}
mozilla::dom::WindowGlobalChild* GetWindowGlobalChild()
{
return mWindowGlobalChild;
}
virtual PopupControlState GetPopupControlState() const = 0;
// Determine if the window is suspended or frozen. Outer windows
@ -737,12 +731,6 @@ protected:
// also set as permissions, but it could happen that we need to access them
// synchronously in this context, and for this, we need a copy here.
nsTArray<nsCString> mStorageAccessGranted;
// The WindowGlobalChild actor for this window.
//
// This will be non-null during the full lifetime of the window, initialized
// during SetNewDocument, and cleared during FreeInnerObjects.
RefPtr<mozilla::dom::WindowGlobalChild> mWindowGlobalChild;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindowInner, NS_PIDOMWINDOWINNER_IID)

View File

@ -17,8 +17,3 @@ interface BrowsingContext {
readonly attribute BrowsingContext? opener;
};
[Exposed=Window, ChromeOnly]
interface ChromeBrowsingContext : BrowsingContext {
sequence<WindowGlobalParent> getWindowGlobals();
};

View File

@ -1,42 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
interface Principal;
interface URI;
interface nsIDocShell;
[Exposed=Window, ChromeOnly]
interface WindowGlobalParent {
readonly attribute boolean isClosed;
readonly attribute boolean isInProcess;
readonly attribute ChromeBrowsingContext browsingContext;
readonly attribute unsigned long long innerWindowId;
readonly attribute unsigned long long outerWindowId;
readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only
readonly attribute WindowGlobalChild? childActor; // in-process only
// Information about the currently loaded document.
readonly attribute Principal documentPrincipal;
readonly attribute URI? documentURI;
static WindowGlobalParent? getByInnerWindowId(unsigned long long innerWindowId);
};
[Exposed=Window, ChromeOnly]
interface WindowGlobalChild {
readonly attribute boolean isClosed;
readonly attribute boolean isInProcess;
readonly attribute BrowsingContext browsingContext;
readonly attribute unsigned long long innerWindowId;
readonly attribute unsigned long long outerWindowId;
readonly attribute WindowGlobalParent? parentActor; // in-process only
static WindowGlobalChild? getByInnerWindowId(unsigned long long innerWIndowId);
};

View File

@ -54,7 +54,6 @@ WEBIDL_FILES = [
'TelemetryStopwatch.webidl',
'WebExtensionContentScript.webidl',
'WebExtensionPolicy.webidl',
'WindowGlobalActors.webidl',
'XULFrameElement.webidl',
'XULMenuElement.webidl',
'XULScrollElement.webidl',

View File

@ -273,113 +273,104 @@ namespace dom {
// IPC sender for remote GC/CC logging.
class CycleCollectWithLogsChild final
: public PCycleCollectWithLogsChild
, public nsICycleCollectorLogSink
{
public:
NS_INLINE_DECL_REFCOUNTING(CycleCollectWithLogsChild)
NS_DECL_ISUPPORTS
class Sink final : public nsICycleCollectorLogSink
CycleCollectWithLogsChild(const FileDescriptor& aGCLog,
const FileDescriptor& aCCLog)
{
NS_DECL_ISUPPORTS
mGCLog = FileDescriptorToFILE(aGCLog, "w");
mCCLog = FileDescriptorToFILE(aCCLog, "w");
}
Sink(CycleCollectWithLogsChild* aActor,
const FileDescriptor& aGCLog,
const FileDescriptor& aCCLog)
{
mActor = aActor;
mGCLog = FileDescriptorToFILE(aGCLog, "w");
mCCLog = FileDescriptorToFILE(aCCLog, "w");
NS_IMETHOD Open(FILE** aGCLog, FILE** aCCLog) override
{
if (NS_WARN_IF(!mGCLog) || NS_WARN_IF(!mCCLog)) {
return NS_ERROR_FAILURE;
}
*aGCLog = mGCLog;
*aCCLog = mCCLog;
return NS_OK;
}
NS_IMETHOD Open(FILE** aGCLog, FILE** aCCLog) override
{
if (NS_WARN_IF(!mGCLog) || NS_WARN_IF(!mCCLog)) {
return NS_ERROR_FAILURE;
}
*aGCLog = mGCLog;
*aCCLog = mCCLog;
return NS_OK;
}
NS_IMETHOD CloseGCLog() override
{
MOZ_ASSERT(mGCLog);
fclose(mGCLog);
mGCLog = nullptr;
SendCloseGCLog();
return NS_OK;
}
NS_IMETHOD CloseGCLog() override
{
MOZ_ASSERT(mGCLog);
fclose(mGCLog);
mGCLog = nullptr;
mActor->SendCloseGCLog();
return NS_OK;
}
NS_IMETHOD CloseCCLog() override
{
MOZ_ASSERT(mCCLog);
fclose(mCCLog);
mCCLog = nullptr;
SendCloseCCLog();
return NS_OK;
}
NS_IMETHOD CloseCCLog() override
{
MOZ_ASSERT(mCCLog);
fclose(mCCLog);
mCCLog = nullptr;
mActor->SendCloseCCLog();
return NS_OK;
}
NS_IMETHOD GetFilenameIdentifier(nsAString& aIdentifier) override
{
return UnimplementedProperty();
}
NS_IMETHOD GetFilenameIdentifier(nsAString& aIdentifier) override
{
return UnimplementedProperty();
}
NS_IMETHOD SetFilenameIdentifier(const nsAString& aIdentifier) override
{
return UnimplementedProperty();
}
NS_IMETHOD SetFilenameIdentifier(const nsAString& aIdentifier) override
{
return UnimplementedProperty();
}
NS_IMETHOD GetProcessIdentifier(int32_t *aIdentifier) override
{
return UnimplementedProperty();
}
NS_IMETHOD GetProcessIdentifier(int32_t *aIdentifier) override
{
return UnimplementedProperty();
}
NS_IMETHOD SetProcessIdentifier(int32_t aIdentifier) override
{
return UnimplementedProperty();
}
NS_IMETHOD SetProcessIdentifier(int32_t aIdentifier) override
{
return UnimplementedProperty();
}
NS_IMETHOD GetGcLog(nsIFile** aPath) override
{
return UnimplementedProperty();
}
NS_IMETHOD GetGcLog(nsIFile** aPath) override
{
return UnimplementedProperty();
}
NS_IMETHOD GetCcLog(nsIFile** aPath) override
{
return UnimplementedProperty();
}
private:
~Sink()
{
if (mGCLog) {
fclose(mGCLog);
mGCLog = nullptr;
}
if (mCCLog) {
fclose(mCCLog);
mCCLog = nullptr;
}
// The XPCOM refcount drives the IPC lifecycle;
Unused << mActor->Send__delete__(mActor);
}
nsresult UnimplementedProperty()
{
MOZ_ASSERT(false, "This object is a remote GC/CC logger;"
" this property isn't meaningful.");
return NS_ERROR_UNEXPECTED;
}
RefPtr<CycleCollectWithLogsChild> mActor;
FILE* mGCLog;
FILE* mCCLog;
};
NS_IMETHOD GetCcLog(nsIFile** aPath) override
{
return UnimplementedProperty();
}
private:
~CycleCollectWithLogsChild() {}
~CycleCollectWithLogsChild() override
{
if (mGCLog) {
fclose(mGCLog);
mGCLog = nullptr;
}
if (mCCLog) {
fclose(mCCLog);
mCCLog = nullptr;
}
// The XPCOM refcount drives the IPC lifecycle; see also
// DeallocPCycleCollectWithLogsChild.
Unused << Send__delete__(this);
}
nsresult UnimplementedProperty()
{
MOZ_ASSERT(false, "This object is a remote GC/CC logger;"
" this property isn't meaningful.");
return NS_ERROR_UNEXPECTED;
}
FILE* mGCLog;
FILE* mCCLog;
};
NS_IMPL_ISUPPORTS(CycleCollectWithLogsChild::Sink, nsICycleCollectorLogSink);
NS_IMPL_ISUPPORTS(CycleCollectWithLogsChild, nsICycleCollectorLogSink);
class AlertObserver
{
@ -963,6 +954,9 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext();
RefPtr<TabChild> newChild = new TabChild(this, tabId, tabGroup,
newTabContext, aChromeFlags);
if (NS_FAILED(newChild->Init(aParent))) {
return NS_ERROR_ABORT;
}
if (aTabOpener) {
MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext);
@ -978,11 +972,6 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
tabId, TabId(0), *ipcContext, aChromeFlags,
GetID(), IsForBrowser());
// Now that |newChild| has had its IPC link established, call |Init| to set it up.
if (NS_FAILED(newChild->Init(aParent))) {
return NS_ERROR_ABORT;
}
nsCOMPtr<nsPIDOMWindowInner> parentTopInnerWindow;
if (aParent) {
nsCOMPtr<nsPIDOMWindowOuter> parentTopWindow =
@ -1332,7 +1321,9 @@ ContentChild::AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,
const FileDescriptor& aGCLog,
const FileDescriptor& aCCLog)
{
return do_AddRef(new CycleCollectWithLogsChild()).take();
auto* actor = new CycleCollectWithLogsChild(aGCLog, aCCLog);
// Return actor with refcount 0, which is safe because it has a non-XPCOM type.
return actor;
}
mozilla::ipc::IPCResult
@ -1341,23 +1332,23 @@ ContentChild::RecvPCycleCollectWithLogsConstructor(PCycleCollectWithLogsChild* a
const FileDescriptor& aGCLog,
const FileDescriptor& aCCLog)
{
// The sink's destructor is called when the last reference goes away, which
// will cause the actor to be closed down.
auto* actor = static_cast<CycleCollectWithLogsChild*>(aActor);
RefPtr<CycleCollectWithLogsChild::Sink> sink =
new CycleCollectWithLogsChild::Sink(actor, aGCLog, aCCLog);
// Invoke the dumper, which will take a reference to the sink.
// Take a reference here, where the XPCOM type is regained.
RefPtr<CycleCollectWithLogsChild> sink = static_cast<CycleCollectWithLogsChild*>(aActor);
nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
dumper->DumpGCAndCCLogsToSink(aDumpAllTraces, sink);
// The actor's destructor is called when the last reference goes away...
return IPC_OK();
}
bool
ContentChild::DeallocPCycleCollectWithLogsChild(PCycleCollectWithLogsChild* aActor)
ContentChild::DeallocPCycleCollectWithLogsChild(PCycleCollectWithLogsChild* /* aActor */)
{
RefPtr<CycleCollectWithLogsChild> actor =
dont_AddRef(static_cast<CycleCollectWithLogsChild*>(aActor));
// ...so when we get here, there's nothing for us to do.
//
// Also, we're already in ~CycleCollectWithLogsChild (q.v.) at
// this point, so we shouldn't touch the actor in any case.
return true;
}

View File

@ -1484,7 +1484,7 @@ ContentParent::ShutDownProcess(ShutDownMethod aMethod)
}
}
if (IPCOpen() && !mShutdownPending) {
if (mIPCOpen && !mShutdownPending) {
// Stop sending input events with input priority when shutting down.
SetInputPriorityEventEnabled(false);
if (SendShutdown()) {
@ -1687,6 +1687,10 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
mForceKillTimer = nullptr;
}
// Signal shutdown completion regardless of error state, so we can
// finish waiting in the xpcom-shutdown/profile-before-change observer.
mIPCOpen = false;
if (mHangMonitorActor) {
ProcessHangMonitor::RemoveProcess(mHangMonitorActor);
mHangMonitorActor = nullptr;
@ -1940,7 +1944,7 @@ ContentParent::NotifyTabDestroying(const TabId& aTabId,
void
ContentParent::StartForceKillTimer()
{
if (mForceKillTimer || !IPCOpen()) {
if (mForceKillTimer || !mIPCOpen) {
return;
}
@ -2397,6 +2401,7 @@ ContentParent::ContentParent(ContentParent* aOpener,
, mCalledKillHard(false)
, mCreatedPairedMinidumps(false)
, mShutdownPending(false)
, mIPCOpen(true)
, mIsRemoteInputEventQueueEnabled(false)
, mIsInputPriorityEventEnabled(false)
, mHangMonitorActor(nullptr)
@ -2901,7 +2906,7 @@ ContentParent::IsInputEventQueueSupported()
void
ContentParent::OnVarChanged(const GfxVarUpdate& aVar)
{
if (!IPCOpen()) {
if (!mIPCOpen) {
return;
}
Unused << SendVarUpdate(aVar);
@ -3135,7 +3140,7 @@ ContentParent::Observe(nsISupports* aSubject,
// Wait for shutdown to complete, so that we receive any shutdown
// data (e.g. telemetry) from the child before we quit.
// This loop terminate prematurely based on mForceKillTimer.
SpinEventLoopUntil([&]() { return !IPCOpen() || mCalledKillHard; });
SpinEventLoopUntil([&]() { return !mIPCOpen || mCalledKillHard; });
NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
}

View File

@ -288,7 +288,7 @@ public:
#endif
// Let managees query if it is safe to send messages.
bool IsDestroyed() const { return !IPCOpen(); }
bool IsDestroyed() const { return !mIPCOpen; }
virtual mozilla::ipc::IPCResult RecvCreateChildProcess(const IPCTabContext& aContext,
const hal::ProcessPriority& aPriority,
@ -1351,6 +1351,7 @@ private:
bool mCalledKillHard;
bool mCreatedPairedMinidumps;
bool mShutdownPending;
bool mIPCOpen;
// True if the input event queue on the main thread of the content process is
// enabled.

View File

@ -26,8 +26,6 @@ using CSSSize from "Units.h";
using mozilla::LayoutDeviceIntPoint from "Units.h";
using hal::ScreenOrientation from "mozilla/HalScreenConfiguration.h";
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
using refcounted class nsIPrincipal from "mozilla/dom/PermissionMessageUtils.h";
using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h";
namespace mozilla {
@ -185,13 +183,5 @@ struct PerformanceInfo
CategoryDispatch[] items;
};
struct WindowGlobalInit
{
nsIPrincipal principal;
BrowsingContextId browsingContextId;
uint64_t innerWindowId;
uint64_t outerWindowId;
};
} // namespace dom
} // namespace mozilla

View File

@ -18,7 +18,6 @@ include protocol PParentToChildStream;
include protocol PFileDescriptorSet;
include protocol PIPCBlobInputStream;
include protocol PPaymentRequest;
include protocol PWindowGlobal;
include DOMTypes;
include IPCBlob;
@ -87,7 +86,6 @@ using class mozilla::NativeEventData from "ipc/nsGUIEventIPC.h";
using mozilla::FontRange from "ipc/nsGUIEventIPC.h";
using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/IPCTypes.h";
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h";
namespace mozilla {
namespace dom {
@ -120,7 +118,6 @@ nested(upto inside_cpow) sync protocol PBrowser
manages PIndexedDBPermissionRequest;
manages PPluginWidget;
manages PPaymentRequest;
manages PWindowGlobal;
both:
async AsyncMessage(nsString aMessage, CpowEntry[] aCpows,
@ -147,12 +144,6 @@ parent:
async PPaymentRequest();
/**
* Construct a new WindowGlobal actor for a window global in the given
* BrowsingContext and with the given principal.
*/
async PWindowGlobal(WindowGlobalInit init);
/**
* Sends an NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW to be adopted by the
* widget's shareable window on the chrome side. Only used on Windows.
@ -588,8 +579,6 @@ parent:
sync SetPrefersReducedMotionOverrideForTest(bool aValue);
sync ResetPrefersReducedMotionOverrideForTest();
async RootBrowsingContext(BrowsingContextId aId);
child:
/**
* Notify the remote browser that it has been Show()n on this

View File

@ -1,35 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
/* 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 protocol PBrowser;
include protocol PInProcess;
include DOMTypes;
using refcounted class nsIURI from "mozilla/ipc/URIUtils.h";
namespace mozilla {
namespace dom {
/**
* A PWindowGlobal actor has a lifetime matching that of a single Window Global,
* specifically a |nsGlobalWindowInner|. These actors will form a parent/child
* link either between the chrome/content process, or will be in-process, for
* documents which are loaded in the chrome process.
*/
async protocol PWindowGlobal
{
manager PBrowser or PInProcess;
parent:
/// Update the URI of the document in this WindowGlobal.
async UpdateDocumentURI(nsIURI aUri);
async __delete__();
};
} // namespace dom
} // namespace mozilla

View File

@ -154,6 +154,9 @@ class HangMonitorChild
JSContext* mContext;
bool mShutdownDone;
// This field is only accessed on the hang thread.
bool mIPCOpen;
// Allows us to ensure we NotifyActivity only once, allowing
// either thread to do so.
Atomic<bool> mPaintWhileInterruptingJSActive;
@ -273,6 +276,9 @@ private:
// This field is read-only after construction.
bool mReportHangs;
// This field is only accessed on the hang thread.
bool mIPCOpen;
Monitor mMonitor;
// Must be accessed with mMonitor held.
@ -305,6 +311,7 @@ HangMonitorChild::HangMonitorChild(ProcessHangMonitor* aMonitor)
mPaintWhileInterruptingJS(false),
mPaintWhileInterruptingJSForce(false),
mShutdownDone(false),
mIPCOpen(true),
mPaintWhileInterruptingJSActive(false)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
@ -386,6 +393,8 @@ HangMonitorChild::ActorDestroy(ActorDestroyReason aWhy)
{
MOZ_RELEASE_ASSERT(IsOnThread());
mIPCOpen = false;
// We use a task here to ensure that IPDL is finished with this
// HangMonitorChild before it gets deleted on the main thread.
Dispatch(NewNonOwningRunnableMethod("HangMonitorChild::ShutdownOnThread",
@ -479,7 +488,7 @@ HangMonitorChild::NotifySlowScriptAsync(TabId aTabId,
const nsCString& aFileName,
const nsString& aAddonId)
{
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendHangEvidence(SlowScriptData(aTabId, aFileName, aAddonId));
}
}
@ -565,7 +574,7 @@ HangMonitorChild::NotifyPluginHangAsync(uint32_t aPluginId)
MOZ_RELEASE_ASSERT(IsOnThread());
// bounce back to parent on background thread
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendHangEvidence(PluginHangData(aPluginId,
base::GetCurrentProcId()));
}
@ -597,7 +606,7 @@ HangMonitorChild::ClearHangAsync()
MOZ_RELEASE_ASSERT(IsOnThread());
// bounce back to parent on background thread
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendClearHang();
}
}
@ -606,6 +615,7 @@ HangMonitorChild::ClearHangAsync()
HangMonitorParent::HangMonitorParent(ProcessHangMonitor* aMonitor)
: mHangMonitor(aMonitor),
mIPCOpen(true),
mMonitor("HangMonitorParent lock"),
mShutdownDone(false),
mBrowserCrashDumpHashLock("mBrowserCrashDumpIds lock"),
@ -660,9 +670,10 @@ HangMonitorParent::ShutdownOnThread()
{
MOZ_RELEASE_ASSERT(IsOnThread());
// Don't take the lock until after IPCOpen() is checked, as the actor lives on
// this thread and ActorDestroy will also take a lock.
if (IPCOpen()) {
// mIPCOpen is only written from this thread, so need need to take the lock
// here. We'd be shooting ourselves in the foot, because ActorDestroy takes
// it.
if (mIPCOpen) {
Close();
}
@ -696,7 +707,7 @@ HangMonitorParent::PaintWhileInterruptingJSOnThread(TabId aTabId,
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendPaintWhileInterruptingJS(aTabId, aForceRepaint, aEpoch);
}
}
@ -705,6 +716,7 @@ void
HangMonitorParent::ActorDestroy(ActorDestroyReason aWhy)
{
MOZ_RELEASE_ASSERT(IsOnThread());
mIPCOpen = false;
}
void
@ -847,7 +859,7 @@ HangMonitorParent::TerminateScript(bool aTerminateGlobal)
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendTerminateScript(aTerminateGlobal);
}
}
@ -857,7 +869,7 @@ HangMonitorParent::BeginStartingDebugger()
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendBeginStartingDebugger();
}
}
@ -867,7 +879,7 @@ HangMonitorParent::EndStartingDebugger()
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendEndStartingDebugger();
}
}

View File

@ -123,7 +123,6 @@
#include "mozilla/Telemetry.h"
#include "nsDocShellLoadState.h"
#include "nsWebBrowser.h"
#include "mozilla/dom/WindowGlobalChild.h"
#ifdef XP_WIN
#include "mozilla/plugins/PluginWidgetChild.h"
@ -411,6 +410,7 @@ TabChild::TabChild(nsIContentChild* aManager,
, mUniqueId(aTabId)
, mHasSiblings(false)
, mIsTransparent(false)
, mIPCOpen(false)
, mParentIsActive(false)
, mDidSetRealShowInfo(false)
, mDidLoadURLInit(false)
@ -586,11 +586,6 @@ TabChild::Init(mozIDOMWindowProxy* aParent)
loadContext->SetRemoteTabs(
mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW);
// Send our browsing context to the parent process.
RefPtr<BrowsingContext> browsingContext =
nsDocShell::Cast(docShell)->GetBrowsingContext();
SendRootBrowsingContext(BrowsingContextId(browsingContext->Id()));
// Few lines before, baseWindow->Create() will end up creating a new
// window root in nsGlobalWindow::SetDocShell.
// Then this chrome event handler, will be inherited to inner windows.
@ -626,6 +621,8 @@ TabChild::Init(mozIDOMWindowProxy* aParent)
});
mAPZEventState = new APZEventState(mPuppetWidget, std::move(callback));
mIPCOpen = true;
// Recording/replaying processes use their own compositor.
if (recordreplay::IsRecordingOrReplaying()) {
mPuppetWidget->CreateCompositor();
@ -1036,6 +1033,8 @@ TabChild::DestroyWindow()
void
TabChild::ActorDestroy(ActorDestroyReason why)
{
mIPCOpen = false;
DestroyWindow();
if (mTabChildMessageManager) {
@ -3436,21 +3435,6 @@ TabChild::DeallocPPaymentRequestChild(PPaymentRequestChild* actor)
return true;
}
PWindowGlobalChild*
TabChild::AllocPWindowGlobalChild(const WindowGlobalInit&)
{
MOZ_CRASH("We should never be manually allocating PWindowGlobalChild actors");
return nullptr;
}
bool
TabChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor)
{
// This reference was added in WindowGlobalChild::Create.
static_cast<WindowGlobalChild*>(aActor)->Release();
return true;
}
ScreenIntSize
TabChild::GetInnerSize()
{

View File

@ -588,6 +588,8 @@ public:
LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; }
LayoutDeviceIntPoint GetChromeOffset() const { return mChromeOffset; };
bool IPCOpen() const { return mIPCOpen; }
bool ParentIsActive() const
{
return mParentIsActive;
@ -703,10 +705,6 @@ public:
protected:
virtual ~TabChild();
virtual PWindowGlobalChild* AllocPWindowGlobalChild(const WindowGlobalInit& aInit) override;
virtual bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) override;
virtual mozilla::ipc::IPCResult RecvDestroy() override;
virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive) override;
@ -850,6 +848,7 @@ private:
bool mIsTransparent;
bool mIPCOpen;
bool mParentIsActive;
CSSSize mUnscaledInnerSize;
bool mDidSetRealShowInfo;

View File

@ -100,8 +100,6 @@
#include "ProcessPriorityManager.h"
#include "nsString.h"
#include "IHistory.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/dom/ChromeBrowsingContext.h"
#ifdef XP_WIN
#include "mozilla/plugins/PluginWidgetParent.h"
@ -1064,29 +1062,6 @@ TabParent::DeallocPIndexedDBPermissionRequestParent(
mozilla::dom::indexedDB::DeallocPIndexedDBPermissionRequestParent(aActor);
}
IPCResult
TabParent::RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor,
const WindowGlobalInit& aInit)
{
static_cast<WindowGlobalParent*>(aActor)->Init(aInit);
return IPC_OK();
}
PWindowGlobalParent*
TabParent::AllocPWindowGlobalParent(const WindowGlobalInit& aInit)
{
// Reference freed in DeallocPWindowGlobalParent.
return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ false)).take();
}
bool
TabParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor)
{
// Free reference from AllocPWindowGlobalParent.
static_cast<WindowGlobalParent*>(aActor)->Release();
return true;
}
void
TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY,
int32_t aButton, int32_t aClickCount,
@ -3748,15 +3723,6 @@ TabParent::RecvGetSystemFont(nsCString* aFontName)
return IPC_OK();
}
mozilla::ipc::IPCResult
TabParent::RecvRootBrowsingContext(const BrowsingContextId& aId)
{
MOZ_ASSERT(!mBrowsingContext, "May only set browsing context once!");
mBrowsingContext = ChromeBrowsingContext::Get(aId);
MOZ_ASSERT(mBrowsingContext, "Invalid ID!");
return IPC_OK();
}
NS_IMETHODIMP
FakeChannel::OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo)
{

View File

@ -67,7 +67,6 @@ class DataSourceSurface;
namespace dom {
class ChromeBrowsingContext;
class ClonedMessageData;
class nsIContentParent;
class Element;
@ -131,8 +130,6 @@ public:
nsIXULBrowserWindow* GetXULBrowserWindow();
ChromeBrowsingContext* GetBrowsingContext() { return mBrowsingContext; }
void Destroy();
void RemoveWindowListeners();
@ -330,16 +327,6 @@ public:
*/
a11y::DocAccessibleParent* GetTopLevelDocAccessible() const;
virtual PWindowGlobalParent*
AllocPWindowGlobalParent(const WindowGlobalInit& aInit) override;
virtual bool
DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) override;
virtual mozilla::ipc::IPCResult
RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor,
const WindowGlobalInit& aInit) override;
void LoadURL(nsIURI* aURI);
void InitRendering();
@ -636,8 +623,6 @@ protected:
virtual mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(const nsCString& aFirstPartyURI) override;
virtual mozilla::ipc::IPCResult RecvRootBrowsingContext(const BrowsingContextId& aId) override;
mozilla::ipc::IPCResult
RecvSetSystemFont(const nsCString& aFontName) override;
mozilla::ipc::IPCResult
@ -713,9 +698,6 @@ private:
// dispatch message manager messages during this time.
RefPtr<nsFrameLoader> mFrameLoader;
// The root browsing context loaded in this TabParent.
RefPtr<ChromeBrowsingContext> mBrowsingContext;
TabId mTabId;
// When loading a new tab or window via window.open, the child is

View File

@ -44,6 +44,12 @@ URLClassifierParent::StartClassify(nsIPrincipal* aPrincipal,
return IPC_OK();
}
void
URLClassifierParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}
/////////////////////////////////////////////////////////////////////
//URLClassifierLocalParent.
@ -73,3 +79,9 @@ URLClassifierLocalParent::StartClassify(nsIURI* aURI, const nsACString& aTables)
}
return IPC_OK();
}
void
URLClassifierLocalParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}

View File

@ -25,7 +25,7 @@ public:
const nsACString& aProvider,
const nsACString& aFullHash) override
{
if (BaseProtocol::IPCOpen()) {
if (mIPCOpen) {
ClassifierInfo info = ClassifierInfo(nsCString(aList),
nsCString(aProvider),
nsCString(aFullHash));
@ -37,13 +37,14 @@ public:
// Custom.
void ClassificationFailed()
{
if (BaseProtocol::IPCOpen()) {
if (mIPCOpen) {
Unused << BaseProtocol::Send__delete__(this, void_t(), NS_ERROR_FAILURE);
}
}
protected:
~URLClassifierParentBase() = default;
bool mIPCOpen = true;
};
//////////////////////////////////////////////////////////////
@ -59,6 +60,10 @@ public:
bool* aSuccess);
private:
~URLClassifierParent() = default;
// Override PURLClassifierParent::ActorDestroy. We seem to unable to
// override from the base template class.
void ActorDestroy(ActorDestroyReason aWhy) override;
};
//////////////////////////////////////////////////////////////
@ -73,6 +78,9 @@ public:
private:
~URLClassifierLocalParent() = default;
// Override PURLClassifierParent::ActorDestroy.
void ActorDestroy(ActorDestroyReason aWhy) override;
};
} // namespace dom

View File

@ -1,129 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
/* 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 "mozilla/dom/WindowGlobalChild.h"
#include "mozilla/ipc/InProcessChild.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/WindowGlobalActorsBinding.h"
namespace mozilla {
namespace dom {
typedef nsRefPtrHashtable<nsUint64HashKey, WindowGlobalChild> WGCByIdMap;
static StaticAutoPtr<WGCByIdMap> gWindowGlobalChildById;
WindowGlobalChild::WindowGlobalChild(nsGlobalWindowInner* aWindow,
dom::BrowsingContext* aBrowsingContext)
: mWindowGlobal(aWindow)
, mBrowsingContext(aBrowsingContext)
, mInnerWindowId(aWindow->WindowID())
, mOuterWindowId(aWindow->GetOuterWindow()->WindowID())
, mIPCClosed(true)
{
}
already_AddRefed<WindowGlobalChild>
WindowGlobalChild::Create(nsGlobalWindowInner* aWindow)
{
nsCOMPtr<nsIPrincipal> principal = aWindow->GetPrincipal();
MOZ_ASSERT(principal);
RefPtr<nsDocShell> docshell = nsDocShell::Cast(aWindow->GetDocShell());
MOZ_ASSERT(docshell);
// Initalize our WindowGlobalChild object.
RefPtr<dom::BrowsingContext> bc = docshell->GetBrowsingContext();
RefPtr<WindowGlobalChild> wgc = new WindowGlobalChild(aWindow, bc);
WindowGlobalInit init(principal,
BrowsingContextId(wgc->BrowsingContext()->Id()),
wgc->mInnerWindowId,
wgc->mOuterWindowId);
// Send the link constructor over PInProcessChild or PBrowser.
if (XRE_IsParentProcess()) {
InProcessChild* ipc = InProcessChild::Singleton();
if (!ipc) {
return nullptr;
}
// Note: ref is released in DeallocPWindowGlobalChild
ipc->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init);
} else {
RefPtr<TabChild> tabChild = TabChild::GetFrom(static_cast<mozIDOMWindow*>(aWindow));
MOZ_ASSERT(tabChild);
// Note: ref is released in DeallocPWindowGlobalChild
tabChild->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init);
}
wgc->mIPCClosed = false;
// Register this WindowGlobal in the gWindowGlobalParentsById map.
if (!gWindowGlobalChildById) {
gWindowGlobalChildById = new WGCByIdMap();
ClearOnShutdown(&gWindowGlobalChildById);
}
auto entry = gWindowGlobalChildById->LookupForAdd(wgc->mInnerWindowId);
MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowGlobalChild entry for ID!");
entry.OrInsert([&] { return wgc; });
return wgc.forget();
}
/* static */ already_AddRefed<WindowGlobalChild>
WindowGlobalChild::GetByInnerWindowId(uint64_t aInnerWindowId)
{
if (!gWindowGlobalChildById) {
return nullptr;
}
return gWindowGlobalChildById->Get(aInnerWindowId);
}
already_AddRefed<WindowGlobalParent>
WindowGlobalChild::GetParentActor()
{
if (mIPCClosed) {
return nullptr;
}
IProtocol* otherSide = InProcessChild::ParentActorFor(this);
return do_AddRef(static_cast<WindowGlobalParent*>(otherSide));
}
void
WindowGlobalChild::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCClosed = true;
gWindowGlobalChildById->Remove(mInnerWindowId);
}
WindowGlobalChild::~WindowGlobalChild()
{
MOZ_ASSERT(!gWindowGlobalChildById ||
!gWindowGlobalChildById->Contains(mInnerWindowId));
}
JSObject*
WindowGlobalChild::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return WindowGlobalChild_Binding::Wrap(aCx, this, aGivenProto);
}
nsISupports*
WindowGlobalChild::GetParentObject()
{
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WindowGlobalChild,
mWindowGlobal,
mBrowsingContext)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalChild, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalChild, Release)
} // namespace dom
} // namespace mozilla

View File

@ -1,85 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
/* 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_WindowGlobalChild_h
#define mozilla_dom_WindowGlobalChild_h
#include "mozilla/RefPtr.h"
#include "mozilla/dom/PWindowGlobalChild.h"
#include "nsWrapperCache.h"
class nsGlobalWindowInner;
class nsDocShell;
namespace mozilla {
namespace dom {
class BrowsingContext;
class WindowGlobalParent;
/**
* Actor for a single nsGlobalWindowInner. This actor is used to communicate
* information to the parent process asynchronously.
*/
class WindowGlobalChild : public nsWrapperCache
, public PWindowGlobalChild
{
public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalChild)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalChild)
static already_AddRefed<WindowGlobalChild>
GetByInnerWindowId(uint64_t aInnerWindowId);
static already_AddRefed<WindowGlobalChild>
GetByInnerWindowId(const GlobalObject& aGlobal, uint64_t aInnerWindowId) {
return GetByInnerWindowId(aInnerWindowId);
}
dom::BrowsingContext* BrowsingContext() { return mBrowsingContext; }
nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; }
// Has this actor been shut down
bool IsClosed() { return mIPCClosed; }
// Check if this actor is managed by PInProcess, as-in the document is loaded
// in the chrome process.
bool IsInProcess() { return XRE_IsParentProcess(); }
// The Window ID for this WindowGlobal
uint64_t InnerWindowId() { return mInnerWindowId; }
uint64_t OuterWindowId() { return mOuterWindowId; }
// Get the other side of this actor if it is an in-process actor. Returns
// |nullptr| if the actor has been torn down, or is not in-process.
already_AddRefed<WindowGlobalParent> GetParentActor();
// Create and initialize the WindowGlobalChild object.
static already_AddRefed<WindowGlobalChild>
Create(nsGlobalWindowInner* aWindow);
nsISupports* GetParentObject();
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
protected:
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
private:
WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBc);
~WindowGlobalChild();
RefPtr<nsGlobalWindowInner> mWindowGlobal;
RefPtr<dom::BrowsingContext> mBrowsingContext;
uint64_t mInnerWindowId;
uint64_t mOuterWindowId;
bool mIPCClosed;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_WindowGlobalChild_h)

View File

@ -1,162 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
/* 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 "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/ipc/InProcessParent.h"
#include "mozilla/dom/ChromeBrowsingContext.h"
#include "mozilla/dom/WindowGlobalActorsBinding.h"
using namespace mozilla::ipc;
namespace mozilla {
namespace dom {
typedef nsRefPtrHashtable<nsUint64HashKey, WindowGlobalParent> WGPByIdMap;
static StaticAutoPtr<WGPByIdMap> gWindowGlobalParentsById;
WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit,
bool aInProcess)
: mDocumentPrincipal(aInit.principal())
, mInnerWindowId(aInit.innerWindowId())
, mOuterWindowId(aInit.outerWindowId())
, mInProcess(aInProcess)
, mIPCClosed(true) // Closed until WGP::Init
{
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(), "Parent process only");
MOZ_RELEASE_ASSERT(mDocumentPrincipal, "Must have a valid principal");
// NOTE: mBrowsingContext initialized in Init()
MOZ_RELEASE_ASSERT(aInit.browsingContextId() != 0,
"Must be made in BrowsingContext");
}
void
WindowGlobalParent::Init(const WindowGlobalInit& aInit)
{
MOZ_ASSERT(Manager(), "Should have a manager!");
MOZ_ASSERT(!mFrameLoader, "Cannot Init() a WindowGlobalParent twice!");
MOZ_ASSERT(mIPCClosed, "IPC shouldn't be open yet");
mIPCClosed = false;
// Register this WindowGlobal in the gWindowGlobalParentsById map.
if (!gWindowGlobalParentsById) {
gWindowGlobalParentsById = new WGPByIdMap();
ClearOnShutdown(&gWindowGlobalParentsById);
}
auto entry = gWindowGlobalParentsById->LookupForAdd(mInnerWindowId);
MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowGlobalParent entry for ID!");
entry.OrInsert([&] { return this; });
// Determine which content process the window global is coming from.
ContentParentId processId(0);
if (!mInProcess) {
processId = static_cast<ContentParent*>(Manager()->Manager())->ChildID();
}
mBrowsingContext = ChromeBrowsingContext::Get(aInit.browsingContextId());
MOZ_ASSERT(mBrowsingContext);
// XXX(nika): This won't be the case soon, but for now this is a good
// assertion as we can't switch processes. We should relax this eventually.
MOZ_ASSERT(mBrowsingContext->IsOwnedByProcess(processId));
// Attach ourself to the browsing context.
mBrowsingContext->RegisterWindowGlobal(this);
// Determine what toplevel frame element our WindowGlobalParent is being
// embedded in.
RefPtr<Element> frameElement;
if (mInProcess) {
// In the in-process case, we can get it from the other side's
// WindowGlobalChild.
MOZ_ASSERT(Manager()->GetProtocolTypeId() == PInProcessMsgStart);
RefPtr<WindowGlobalChild> otherSide = GetChildActor();
if (otherSide && otherSide->WindowGlobal()) {
// Get the toplevel window from the other side.
RefPtr<nsDocShell> docShell = nsDocShell::Cast(otherSide->WindowGlobal()->GetDocShell());
if (docShell) {
docShell->GetTopFrameElement(getter_AddRefs(frameElement));
}
}
} else {
// In the cross-process case, we can get the frame element from our manager.
MOZ_ASSERT(Manager()->GetProtocolTypeId() == PBrowserMsgStart);
frameElement = static_cast<TabParent*>(Manager())->GetOwnerElement();
}
// Extract the nsFrameLoader from the current frame element. We may not have a
// nsFrameLoader if we are a chrome document.
nsCOMPtr<nsIFrameLoaderOwner> flOwner = do_QueryInterface(frameElement);
if (flOwner) {
mFrameLoader = flOwner->GetFrameLoader();
}
}
/* static */ already_AddRefed<WindowGlobalParent>
WindowGlobalParent::GetByInnerWindowId(uint64_t aInnerWindowId)
{
if (!gWindowGlobalParentsById) {
return nullptr;
}
return gWindowGlobalParentsById->Get(aInnerWindowId);
}
already_AddRefed<WindowGlobalChild>
WindowGlobalParent::GetChildActor()
{
if (mIPCClosed) {
return nullptr;
}
IProtocol* otherSide = InProcessParent::ChildActorFor(this);
return do_AddRef(static_cast<WindowGlobalChild*>(otherSide));
}
IPCResult
WindowGlobalParent::RecvUpdateDocumentURI(nsIURI* aURI)
{
// XXX(nika): Assert that the URI change was one which makes sense (either
// about:blank -> a real URI, or a legal push/popstate URI change?)
mDocumentURI = aURI;
return IPC_OK();
}
void
WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCClosed = true;
gWindowGlobalParentsById->Remove(mInnerWindowId);
mBrowsingContext->UnregisterWindowGlobal(this);
}
WindowGlobalParent::~WindowGlobalParent()
{
MOZ_ASSERT(!gWindowGlobalParentsById ||
!gWindowGlobalParentsById->Contains(mInnerWindowId));
}
JSObject*
WindowGlobalParent::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return WindowGlobalParent_Binding::Wrap(aCx, this, aGivenProto);
}
nsISupports*
WindowGlobalParent::GetParentObject()
{
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WindowGlobalParent,
mFrameLoader,
mBrowsingContext)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalParent, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalParent, Release)
} // namespace dom
} // namespace mozilla

View File

@ -1,110 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
/* 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_WindowGlobalParent_h
#define mozilla_dom_WindowGlobalParent_h
#include "mozilla/RefPtr.h"
#include "mozilla/dom/PWindowGlobalParent.h"
#include "nsWrapperCache.h"
class nsIPrincipal;
class nsIURI;
class nsFrameLoader;
namespace mozilla {
namespace dom {
class ChromeBrowsingContext;
class WindowGlobalChild;
/**
* A handle in the parent process to a specific nsGlobalWindowInner object.
*/
class WindowGlobalParent final : public nsWrapperCache
, public PWindowGlobalParent
{
public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalParent)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalParent)
static already_AddRefed<WindowGlobalParent>
GetByInnerWindowId(uint64_t aInnerWindowId);
static already_AddRefed<WindowGlobalParent>
GetByInnerWindowId(const GlobalObject& aGlobal, uint64_t aInnerWindowId) {
return GetByInnerWindowId(aInnerWindowId);
}
// Has this actor been shut down
bool IsClosed() { return mIPCClosed; }
// Check if this actor is managed by PInProcess, as-in the document is loaded
// in-process.
bool IsInProcess() { return mInProcess; }
// Get the other side of this actor if it is an in-process actor. Returns
// |nullptr| if the actor has been torn down, or is not in-process.
already_AddRefed<WindowGlobalChild> GetChildActor();
// The principal of this WindowGlobal. This value will not change over the
// lifetime of the WindowGlobal object, even to reflect changes in
// |document.domain|.
nsIPrincipal* DocumentPrincipal() { return mDocumentPrincipal; }
// The BrowsingContext which this WindowGlobal has been loaded into.
ChromeBrowsingContext* BrowsingContext() { return mBrowsingContext; }
// Get the root nsFrameLoader object for the tree of BrowsingContext nodes
// which this WindowGlobal is a part of. This will be the nsFrameLoader
// holding the TabParent for remote tabs, and the root content frameloader for
// non-remote tabs.
nsFrameLoader* GetRootFrameLoader() { return mFrameLoader; }
// The current URI which loaded in the document.
nsIURI* GetDocumentURI() { return mDocumentURI; }
// Window IDs for inner/outer windows.
uint64_t OuterWindowId() { return mOuterWindowId; }
uint64_t InnerWindowId() { return mInnerWindowId; }
// Create a WindowGlobalParent from over IPC. This method should not be called
// from outside of the IPC constructors.
WindowGlobalParent(const WindowGlobalInit& aInit, bool aInProcess);
// Initialize the mFrameLoader fields for a created WindowGlobalParent. Must
// be called after setting the Manager actor.
void Init(const WindowGlobalInit& aInit);
nsISupports* GetParentObject();
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
protected:
// IPC messages
mozilla::ipc::IPCResult RecvUpdateDocumentURI(nsIURI* aURI) override;
void ActorDestroy(ActorDestroyReason aWhy) override;
private:
~WindowGlobalParent();
// NOTE: This document principal doesn't reflect possible |document.domain|
// mutations which may have been made in the actual document.
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
nsCOMPtr<nsIURI> mDocumentURI;
RefPtr<nsFrameLoader> mFrameLoader;
RefPtr<ChromeBrowsingContext> mBrowsingContext;
uint64_t mInnerWindowId;
uint64_t mOuterWindowId;
bool mInProcess;
bool mIPCClosed;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_WindowGlobalParent_h)

View File

@ -50,8 +50,6 @@ EXPORTS.mozilla.dom += [
'TabParent.h',
'URLClassifierChild.h',
'URLClassifierParent.h',
'WindowGlobalChild.h',
'WindowGlobalParent.h',
]
EXPORTS.mozilla += [
@ -87,8 +85,6 @@ UNIFIED_SOURCES += [
'TabMessageUtils.cpp',
'TabParent.cpp',
'URLClassifierParent.cpp',
'WindowGlobalChild.cpp',
'WindowGlobalParent.cpp',
]
# ContentChild.cpp cannot be compiled in unified mode on linux due to Time conflict
@ -116,7 +112,6 @@ IPDL_SOURCES += [
'PURLClassifier.ipdl',
'PURLClassifierInfo.ipdlh',
'PURLClassifierLocal.ipdl',
'PWindowGlobal.ipdl',
'ServiceWorkerConfiguration.ipdlh',
]

View File

@ -27,6 +27,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPServerSocketChildBase)
NS_INTERFACE_MAP_END
TCPServerSocketChildBase::TCPServerSocketChildBase()
: mIPCOpen(false)
{
}
@ -37,7 +38,7 @@ TCPServerSocketChildBase::~TCPServerSocketChildBase()
NS_IMETHODIMP_(MozExternalRefCountType) TCPServerSocketChild::Release(void)
{
nsrefcnt refcnt = TCPServerSocketChildBase::Release();
if (refcnt == 1 && IPCOpen()) {
if (refcnt == 1 && mIPCOpen) {
PTCPServerSocketChild::SendRequestDelete();
return 1;
}
@ -59,12 +60,16 @@ TCPServerSocketChild::TCPServerSocketChild(TCPServerSocket* aServerSocket, uint1
void
TCPServerSocketChildBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
this->Release();
}
void
TCPServerSocketChildBase::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}

View File

@ -34,6 +34,7 @@ protected:
virtual ~TCPServerSocketChildBase();
RefPtr<TCPServerSocket> mServerSocket;
bool mIPCOpen;
};
class TCPServerSocketChild : public mozilla::net::PTCPServerSocketChild

View File

@ -26,12 +26,16 @@ NS_INTERFACE_MAP_END
void
TCPServerSocketParent::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
this->Release();
}
void
TCPServerSocketParent::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}
@ -40,6 +44,7 @@ TCPServerSocketParent::TCPServerSocketParent(PNeckoParent* neckoParent,
uint16_t aBacklog,
bool aUseArrayBuffers)
: mNeckoParent(neckoParent)
, mIPCOpen(false)
{
mServerSocket = new TCPServerSocket(nullptr, aLocalPort, aUseArrayBuffers, aBacklog);
mServerSocket->SetServerBridgeParent(this);

View File

@ -48,6 +48,7 @@ private:
PNeckoParent* mNeckoParent;
RefPtr<TCPServerSocket> mServerSocket;
bool mIPCOpen;
};
} // namespace dom

View File

@ -69,6 +69,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPSocketChildBase)
NS_INTERFACE_MAP_END
TCPSocketChildBase::TCPSocketChildBase()
: mIPCOpen(false)
{
mozilla::HoldJSObjects(this);
}
@ -81,7 +82,7 @@ TCPSocketChildBase::~TCPSocketChildBase()
NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
{
nsrefcnt refcnt = TCPSocketChildBase::Release();
if (refcnt == 1 && IPCOpen()) {
if (refcnt == 1 && mIPCOpen) {
PTCPSocketChild::SendRequestDelete();
return 1;
}
@ -137,6 +138,8 @@ TCPSocketChild::SendWindowlessOpenBind(nsITCPSocketCallback* aSocket,
void
TCPSocketChildBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
mSocket = nullptr;
this->Release();
}
@ -144,6 +147,8 @@ TCPSocketChildBase::ReleaseIPDLReference()
void
TCPSocketChildBase::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}

View File

@ -40,6 +40,7 @@ protected:
virtual ~TCPSocketChildBase();
nsCOMPtr<nsITCPSocketCallback> mSocket;
bool mIPCOpen;
};
class TCPSocketChild : public mozilla::net::PTCPSocketChild

View File

@ -62,6 +62,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(TCPSocketParentBase)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPSocketParentBase)
TCPSocketParentBase::TCPSocketParentBase()
: mIPCOpen(false)
{
}
@ -72,19 +73,23 @@ TCPSocketParentBase::~TCPSocketParentBase()
void
TCPSocketParentBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
this->Release();
}
void
TCPSocketParentBase::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}
NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketParent::Release(void)
{
nsrefcnt refcnt = TCPSocketParentBase::Release();
if (refcnt == 1 && IPCOpen()) {
if (refcnt == 1 && mIPCOpen) {
mozilla::Unused << PTCPSocketParent::SendRequestDelete();
return 1;
}
@ -325,7 +330,7 @@ TCPSocketParent::FireStringDataEvent(const nsACString& aData, TCPReadyState aRea
void
TCPSocketParent::SendEvent(const nsAString& aType, CallbackData aData, TCPReadyState aReadyState)
{
if (IPCOpen()) {
if (mIPCOpen) {
mozilla::Unused << PTCPSocketParent::SendCallback(nsString(aType),
aData,
static_cast<uint32_t>(aReadyState));

View File

@ -36,6 +36,7 @@ protected:
virtual ~TCPSocketParentBase();
RefPtr<TCPSocket> mSocket;
bool mIPCOpen;
};
class TCPSocketParent : public mozilla::net::PTCPSocketParent

View File

@ -23,6 +23,7 @@ namespace dom {
NS_IMPL_ISUPPORTS(UDPSocketChildBase, nsIUDPSocketChild)
UDPSocketChildBase::UDPSocketChildBase()
: mIPCOpen(false)
{
}
@ -33,6 +34,8 @@ UDPSocketChildBase::~UDPSocketChildBase()
void
UDPSocketChildBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
mSocket = nullptr;
this->Release();
}
@ -40,13 +43,15 @@ UDPSocketChildBase::ReleaseIPDLReference()
void
UDPSocketChildBase::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}
NS_IMETHODIMP_(MozExternalRefCountType) UDPSocketChild::Release(void)
{
nsrefcnt refcnt = UDPSocketChildBase::Release();
if (refcnt == 1 && IPCOpen()) {
if (refcnt == 1 && mIPCOpen) {
PUDPSocketChild::SendRequestDelete();
return 1;
}

View File

@ -29,6 +29,7 @@ protected:
UDPSocketChildBase();
virtual ~UDPSocketChildBase();
nsCOMPtr<nsIUDPSocketInternal> mSocket;
bool mIPCOpen;
};
class UDPSocketChild : public mozilla::net::PUDPSocketChild

View File

@ -30,11 +30,13 @@ NS_IMPL_ISUPPORTS(UDPSocketParent, nsIUDPSocketListener)
UDPSocketParent::UDPSocketParent(PBackgroundParent* aManager)
: mBackgroundManager(aManager)
, mIPCOpen(true)
{
}
UDPSocketParent::UDPSocketParent(PNeckoParent* aManager)
: mBackgroundManager(nullptr)
, mIPCOpen(true)
{
}
@ -508,6 +510,8 @@ UDPSocketParent::RecvRequestDelete()
void
UDPSocketParent::ActorDestroy(ActorDestroyReason why)
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
if (mSocket) {
mSocket->Close();
}
@ -520,7 +524,7 @@ NS_IMETHODIMP
UDPSocketParent::OnPacketReceived(nsIUDPSocket* aSocket, nsIUDPMessage* aMessage)
{
// receiving packet from remote host, forward the message content to child process
if (!IPCOpen()) {
if (!mIPCOpen) {
return NS_OK;
}
@ -573,7 +577,7 @@ NS_IMETHODIMP
UDPSocketParent::OnStopListening(nsIUDPSocket* aSocket, nsresult aStatus)
{
// underlying socket is dead, send state update to child process
if (IPCOpen()) {
if (mIPCOpen) {
mozilla::Unused << SendCallbackClosed();
}
return NS_OK;
@ -582,7 +586,7 @@ UDPSocketParent::OnStopListening(nsIUDPSocket* aSocket, nsresult aStatus)
void
UDPSocketParent::FireInternalError(uint32_t aLineNo)
{
if (!IPCOpen()) {
if (!mIPCOpen) {
return;
}

View File

@ -70,6 +70,7 @@ private:
PBackgroundParent* mBackgroundManager;
bool mIPCOpen;
nsCOMPtr<nsIUDPSocket> mSocket;
nsCOMPtr<nsISocketFilter> mFilter;
nsCOMPtr<nsIPrincipal> mPrincipal;

View File

@ -129,18 +129,23 @@ private:
void
StorageDBChild::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempting to retain multiple IPDL references");
mIPCOpen = true;
AddRef();
}
void
StorageDBChild::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempting to release non-existent IPDL reference");
mIPCOpen = false;
Release();
}
StorageDBChild::StorageDBChild(LocalStorageManager* aManager)
: mManager(aManager)
, mStatus(NS_OK)
, mIPCOpen(false)
{
}
@ -243,7 +248,7 @@ StorageDBChild::Shutdown()
void
StorageDBChild::AsyncPreload(LocalStorageCacheBridge* aCache, bool aPriority)
{
if (IPCOpen()) {
if (mIPCOpen) {
// Adding ref to cache for the time of preload. This ensures a reference to
// to the cache and that all keys will load into this cache object.
mLoadingCaches.PutEntry(aCache);
@ -258,7 +263,7 @@ StorageDBChild::AsyncPreload(LocalStorageCacheBridge* aCache, bool aPriority)
void
StorageDBChild::AsyncGetUsage(StorageUsageBridge* aUsage)
{
if (IPCOpen()) {
if (mIPCOpen) {
SendAsyncGetUsage(aUsage->OriginScope());
}
}
@ -271,7 +276,7 @@ StorageDBChild::SyncPreload(LocalStorageCacheBridge* aCache, bool aForceSync)
return;
}
if (!IPCOpen()) {
if (!mIPCOpen) {
aCache->LoadDone(NS_ERROR_UNEXPECTED);
return;
}
@ -297,7 +302,7 @@ StorageDBChild::AsyncAddItem(LocalStorageCacheBridge* aCache,
const nsAString& aKey,
const nsAString& aValue)
{
if (NS_FAILED(mStatus) || !IPCOpen()) {
if (NS_FAILED(mStatus) || !mIPCOpen) {
return mStatus;
}
@ -312,7 +317,7 @@ StorageDBChild::AsyncUpdateItem(LocalStorageCacheBridge* aCache,
const nsAString& aKey,
const nsAString& aValue)
{
if (NS_FAILED(mStatus) || !IPCOpen()) {
if (NS_FAILED(mStatus) || !mIPCOpen) {
return mStatus;
}
@ -326,7 +331,7 @@ nsresult
StorageDBChild::AsyncRemoveItem(LocalStorageCacheBridge* aCache,
const nsAString& aKey)
{
if (NS_FAILED(mStatus) || !IPCOpen()) {
if (NS_FAILED(mStatus) || !mIPCOpen) {
return mStatus;
}
@ -338,7 +343,7 @@ StorageDBChild::AsyncRemoveItem(LocalStorageCacheBridge* aCache,
nsresult
StorageDBChild::AsyncClear(LocalStorageCacheBridge* aCache)
{
if (NS_FAILED(mStatus) || !IPCOpen()) {
if (NS_FAILED(mStatus) || !mIPCOpen) {
return mStatus;
}
@ -602,12 +607,16 @@ NS_IMPL_RELEASE(StorageDBParent)
void
StorageDBParent::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempting to retain multiple IPDL references");
mIPCOpen = true;
AddRef();
}
void
StorageDBParent::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempting to release non-existent IPDL reference");
mIPCOpen = false;
Release();
}
@ -617,6 +626,7 @@ namespace {
StorageDBParent::StorageDBParent(const nsString& aProfilePath)
: mProfilePath(aProfilePath)
, mIPCOpen(false)
{
AssertIsOnBackgroundThread();
@ -834,7 +844,7 @@ StorageDBParent::RecvAsyncAddItem(const nsCString& aOriginSuffix,
storageThread->AsyncAddItem(NewCache(aOriginSuffix, aOriginNoSuffix),
aKey,
aValue);
if (NS_FAILED(rv) && IPCOpen()) {
if (NS_FAILED(rv) && mIPCOpen) {
mozilla::Unused << SendError(rv);
}
@ -856,7 +866,7 @@ StorageDBParent::RecvAsyncUpdateItem(const nsCString& aOriginSuffix,
storageThread->AsyncUpdateItem(NewCache(aOriginSuffix, aOriginNoSuffix),
aKey,
aValue);
if (NS_FAILED(rv) && IPCOpen()) {
if (NS_FAILED(rv) && mIPCOpen) {
mozilla::Unused << SendError(rv);
}
@ -876,7 +886,7 @@ StorageDBParent::RecvAsyncRemoveItem(const nsCString& aOriginSuffix,
nsresult rv =
storageThread->AsyncRemoveItem(NewCache(aOriginSuffix, aOriginNoSuffix),
aKey);
if (NS_FAILED(rv) && IPCOpen()) {
if (NS_FAILED(rv) && mIPCOpen) {
mozilla::Unused << SendError(rv);
}
@ -894,7 +904,7 @@ StorageDBParent::RecvAsyncClear(const nsCString& aOriginSuffix,
nsresult rv =
storageThread->AsyncClear(NewCache(aOriginSuffix, aOriginNoSuffix));
if (NS_FAILED(rv) && IPCOpen()) {
if (NS_FAILED(rv) && mIPCOpen) {
mozilla::Unused << SendError(rv);
}
@ -970,7 +980,7 @@ StorageDBParent::Observe(const nsCString& aTopic,
const nsString& aOriginAttributesPattern,
const nsCString& aOriginScope)
{
if (IPCOpen()) {
if (mIPCOpen) {
mozilla::Unused <<
SendObserve(aTopic, aOriginAttributesPattern, aOriginScope);
}

View File

@ -178,6 +178,8 @@ private:
// Status of the remote database
nsresult mStatus;
bool mIPCOpen;
};
class LocalStorageCacheParent final
@ -237,6 +239,8 @@ public:
void AddIPDLReference();
void ReleaseIPDLReference();
bool IPCOpen() { return mIPCOpen; }
public:
// Fake cache class receiving async callbacks from DB thread, sending
// them back to appropriate cache object on the child process.
@ -363,6 +367,9 @@ private:
ThreadSafeAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
// True when IPC channel is open and Send*() methods are OK to use.
bool mIPCOpen;
};
PBackgroundLocalStorageCacheParent*

View File

@ -33,12 +33,6 @@ interface FrameLoader {
*/
readonly attribute LoadContext loadContext;
/**
* Get the root BrowsingContext within the frame.
* This may be null immediately after creating a remote frame.
*/
readonly attribute BrowsingContext? browsingContext;
/**
* Get the ParentSHistory for the nsFrameLoader. May return null if this
* frameloader is not for a toplevel frame.

View File

@ -34,7 +34,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('cocoa', 'uikit'):
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True
EXPORTS.cairo += [
'cairo-win32.h',
]

View File

@ -106,6 +106,7 @@ public:
, mTextureData(nullptr)
, mDestroyed(false)
, mMainThreadOnly(false)
, mIPCOpen(false)
, mOwnsTextureData(false)
, mOwnerCalledDestroy(false)
{}
@ -116,12 +117,28 @@ public:
void ActorDestroy(ActorDestroyReason why) override;
bool IPCOpen() const { return mIPCOpen; }
void Lock() const { if (mCompositableForwarder && mCompositableForwarder->GetTextureForwarder()->UsesImageBridge()) { mLock.Enter(); } }
void Unlock() const { if (mCompositableForwarder && mCompositableForwarder->GetTextureForwarder()->UsesImageBridge()) { mLock.Leave(); } }
private:
// AddIPDLReference and ReleaseIPDLReference are only to be called by CreateIPDLActor
// and DestroyIPDLActor, respectively. We intentionally make them private to prevent misuse.
// The purpose of these methods is to be aware of when the IPC system around this
// actor goes down: mIPCOpen is then set to false.
void AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
Release();
}
/// The normal way to destroy the actor.
///
/// This will asynchronously send a Destroy message to the parent actor, whom
@ -200,6 +217,7 @@ private:
TextureData* mTextureData;
Atomic<bool> mDestroyed;
bool mMainThreadOnly;
bool mIPCOpen;
bool mOwnsTextureData;
bool mOwnerCalledDestroy;
@ -237,6 +255,8 @@ void
TextureChild::ActorDestroy(ActorDestroyReason why)
{
AUTO_PROFILER_LABEL("TextureChild::ActorDestroy", GRAPHICS);
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
if (mTextureData) {
DestroyTextureData(mTextureData, GetAllocator(), mOwnsTextureData, mMainThreadOnly);
@ -724,15 +744,16 @@ TextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
PTextureChild*
TextureClient::CreateIPDLActor()
{
RefPtr<TextureChild> c = new TextureChild();
return c.forget().take();
TextureChild* c = new TextureChild();
c->AddIPDLReference();
return c;
}
// static
bool
TextureClient::DestroyIPDLActor(PTextureChild* actor)
{
RefPtr<TextureChild> tc = dont_AddRef(static_cast<TextureChild*>(actor));
static_cast<TextureChild*>(actor)->ReleaseIPDLReference();
return true;
}

View File

@ -33,9 +33,7 @@ public:
*/
void Destroy();
bool IPCOpen() const {
return mozilla::ipc::IProtocol::IPCOpen() && !mDestroyed;
}
bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
bool IsDestroyed() const { return mDestroyed; }
void SetForwarder(ShadowLayerForwarder* aForwarder)
@ -52,6 +50,7 @@ public:
protected:
explicit LayerTransactionChild(const LayersId& aId)
: mForwarder(nullptr)
, mIPCOpen(false)
, mDestroyed(false)
, mId(aId)
{}
@ -60,14 +59,19 @@ protected:
void ActorDestroy(ActorDestroyReason why) override;
void AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == true);
mIPCOpen = false;
Release();
}
friend class CompositorBridgeChild;
ShadowLayerForwarder* mForwarder;
bool mIPCOpen;
bool mDestroyed;
LayersId mId;
};

View File

@ -58,6 +58,7 @@ LayerTransactionParent::LayerTransactionParent(HostLayerManager* aManager,
, mVsyncRate(aVsyncRate)
, mPendingTransaction{0}
, mDestroyed(false)
, mIPCOpen(false)
, mUpdateHitTestingTree(false)
{
MOZ_ASSERT(mId.IsValid());
@ -883,7 +884,7 @@ LayerTransactionParent::AllocShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem)
{
if (!IPCOpen() || mDestroyed) {
if (!mIPCOpen || mDestroyed) {
return false;
}
return PLayerTransactionParent::AllocShmem(aSize, aType, aShmem);
@ -894,7 +895,7 @@ LayerTransactionParent::AllocUnsafeShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem)
{
if (!IPCOpen() || mDestroyed) {
if (!mIPCOpen || mDestroyed) {
return false;
}
@ -904,7 +905,7 @@ LayerTransactionParent::AllocUnsafeShmem(size_t aSize,
void
LayerTransactionParent::DeallocShmem(ipc::Shmem& aShmem)
{
if (!IPCOpen() || mDestroyed) {
if (!mIPCOpen || mDestroyed) {
return;
}
PLayerTransactionParent::DeallocShmem(aShmem);

View File

@ -57,8 +57,6 @@ public:
LayersId GetId() const { return mId; }
Layer* GetRoot() const { return mRoot; }
bool IPCOpen() const override { return mozilla::ipc::IProtocol::IPCOpen(); }
LayersObserverEpoch GetChildEpoch() const { return mChildEpoch; }
bool ShouldParentObserveEpoch();
@ -156,9 +154,13 @@ protected:
bool Attach(Layer* aLayer, CompositableHost* aCompositable, bool aIsAsyncVideo);
void AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == true);
mIPCOpen = false;
Release();
}
friend class CompositorBridgeParent;
@ -215,6 +217,7 @@ private:
// transactions posted by the child.
bool mDestroyed;
bool mIPCOpen;
// This is set during RecvUpdate to track whether we'll need to update
// APZ's hit test regions.

View File

@ -29,6 +29,7 @@ WebRenderBridgeChild::WebRenderBridgeChild(const wr::PipelineId& aPipelineId)
, mResourceId(0)
, mPipelineId(aPipelineId)
, mManager(nullptr)
, mIPCOpen(false)
, mDestroyed(false)
, mFontKeysDeleted(0)
, mFontInstanceKeysDeleted(0)

View File

@ -113,9 +113,7 @@ public:
* to be sent from the parent side.
*/
void Destroy(bool aIsSync);
bool IPCOpen() const {
return mozilla::ipc::IProtocol::IPCOpen() && !mDestroyed;
}
bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
bool IsDestroyed() const { return mDestroyed; }
uint32_t GetNextResourceId() { return ++mResourceId; }
@ -215,9 +213,13 @@ private:
mozilla::ipc::IPCResult RecvWrReleasedImages(nsTArray<wr::ExternalImageKeyPair>&& aPairs) override;
void AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == true);
mIPCOpen = false;
Release();
}
@ -233,6 +235,7 @@ private:
wr::PipelineId mPipelineId;
WebRenderLayerManager* mManager;
bool mIPCOpen;
bool mDestroyed;
uint32_t mFontKeysDeleted;

View File

@ -261,7 +261,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption)
UINT32 ucs = L' ';
UINT16 glyph;
HRESULT hr = mFontFace->GetGlyphIndices(&ucs, 1, &glyph);
HRESULT hr = mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph);
if (FAILED(hr)) {
mMetrics->spaceWidth = 0;
} else {
@ -291,7 +291,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption)
if (mMetrics->aveCharWidth < 1) {
ucs = L'x';
if (SUCCEEDED(mFontFace->GetGlyphIndices(&ucs, 1, &glyph))) {
if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) {
mMetrics->aveCharWidth = MeasureGlyphWidth(glyph);
}
if (mMetrics->aveCharWidth < 1) {
@ -301,7 +301,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption)
}
ucs = L'0';
if (SUCCEEDED(mFontFace->GetGlyphIndices(&ucs, 1, &glyph))) {
if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) {
mMetrics->zeroOrAveCharWidth = MeasureGlyphWidth(glyph);
}
if (mMetrics->zeroOrAveCharWidth < 1) {

View File

@ -20,6 +20,7 @@ namespace gfx {
VRLayerChild::VRLayerChild()
: mCanvasElement(nullptr)
, mIPCOpen(false)
, mLastSubmittedFrameId(0)
{
MOZ_COUNT_CTOR(VRLayerChild);
@ -111,7 +112,7 @@ VRLayerChild::SubmitFrame(const VRDisplayInfo& aDisplayInfo)
bool
VRLayerChild::IsIPCOpen()
{
return IPCOpen();
return mIPCOpen;
}
void
@ -121,6 +122,12 @@ VRLayerChild::ClearSurfaces()
mLastFrameTexture = nullptr;
}
void
VRLayerChild::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}
// static
PVRLayerChild*
VRLayerChild::CreateIPDLActor()
@ -140,10 +147,13 @@ VRLayerChild::DestroyIPDLActor(PVRLayerChild* actor)
void
VRLayerChild::AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void
VRLayerChild::ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
Release();
}

View File

@ -44,8 +44,10 @@ private:
VRLayerChild();
virtual ~VRLayerChild();
void ClearSurfaces();
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
RefPtr<dom::HTMLCanvasElement> mCanvasElement;
bool mIPCOpen;
// AddIPDLReference and ReleaseIPDLReference are only to be called by CreateIPDLActor
// and DestroyIPDLActor, respectively. We intentionally make them private to prevent misuse.

View File

@ -15,7 +15,8 @@ using namespace layers;
namespace gfx {
VRLayerParent::VRLayerParent(uint32_t aVRDisplayID, const uint32_t aGroup)
: mVRDisplayID(aVRDisplayID)
: mIPCOpen(true)
, mVRDisplayID(aVRDisplayID)
, mGroup(aGroup)
{
}
@ -32,6 +33,12 @@ VRLayerParent::RecvDestroy()
return IPC_OK();
}
void
VRLayerParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}
void
VRLayerParent::Destroy()
{
@ -46,7 +53,7 @@ VRLayerParent::Destroy()
mVRDisplayID = 0;
}
if (IPCOpen()) {
if (mIPCOpen) {
Unused << PVRLayerParent::Send__delete__(this);
}
}

View File

@ -29,9 +29,13 @@ public:
uint32_t GetDisplayID() const { return mVRDisplayID; }
uint32_t GetGroup() const { return mGroup; }
protected:
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual ~VRLayerParent();
void Destroy();
bool mIPCOpen;
uint32_t mVRDisplayID;
gfx::Rect mLeftEyeRect;
gfx::Rect mRightEyeRect;

View File

@ -8,9 +8,6 @@ FINAL_LIBRARY = 'xul'
DEFINES['VR_API_PUBLIC'] = True
# Windows.h wrappers conflict with internal methods in openvr
DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True
if CONFIG['OS_ARCH'] == 'WINNT':
if CONFIG['HAVE_64BIT_BUILD']:
DEFINES['WIN64'] = True

View File

@ -1,31 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=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 "mozilla/ipc/InProcessChild.h"
#include "mozilla/dom/WindowGlobalChild.h"
using namespace mozilla::dom;
namespace mozilla {
namespace ipc {
PWindowGlobalChild*
InProcessChild::AllocPWindowGlobalChild(const WindowGlobalInit& aInit)
{
MOZ_ASSERT_UNREACHABLE("PWindowGlobalChild should not be created manually");
return nullptr;
}
bool
InProcessChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor)
{
// Free IPC-held reference
static_cast<WindowGlobalChild*>(aActor)->Release();
return true;
}
} // namespace ipc
} // namespace mozilla

View File

@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=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_ipc_InProcessChild_h
#define mozilla_ipc_InProcessChild_h
#include "mozilla/ipc/PInProcessChild.h"
#include "mozilla/StaticPtr.h"
namespace mozilla {
namespace dom {
class PWindowGlobalParent;
class PWindowGlobalChild;
} // namespace dom
namespace ipc {
class InProcessParent;
/**
* The `InProcessChild` class represents the child half of a main-thread to
* main-thread actor.
*
* The `PInProcess` actor should be used as an alternate manager to `PContent`
* for async actors which want to communicate uniformly between Content->Chrome
* and Chrome->Chrome situations.
*/
class InProcessChild : public PInProcessChild
{
public:
friend class InProcessParent;
NS_INLINE_DECL_REFCOUNTING(InProcessChild)
// Get the singleton instance of this actor.
static InProcessChild* Singleton();
// Get the parent side of the in-process child actor |aActor|. If |aActor| is
// not an in-process actor, or is not connected, this method will return
// |nullptr|.
static IProtocol* ParentActorFor(IProtocol* aActor);
protected:
virtual mozilla::dom::PWindowGlobalChild*
AllocPWindowGlobalChild(const WindowGlobalInit& aInit) override;
virtual bool
DeallocPWindowGlobalChild(mozilla::dom::PWindowGlobalChild* aActor) override;
private:
// NOTE: PInProcess lifecycle management is declared as staic methods and
// state on InProcessParent, and implemented in InProcessImpl.cpp.
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual void DeallocPInProcessChild() override;
~InProcessChild() = default;
static StaticRefPtr<InProcessChild> sSingleton;
};
} // namespace ipc
} // namespace mozilla
#endif // defined(mozilla_ipc_InProcessChild_h)

View File

@ -1,212 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=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 "mozilla/ipc/InProcessParent.h"
#include "mozilla/ipc/InProcessChild.h"
#include "nsIObserverService.h"
#include "mozilla/Services.h"
// This file contains the implementation of core InProcess lifecycle management
// facilities.
namespace mozilla {
namespace ipc {
StaticRefPtr<InProcessParent> InProcessParent::sSingleton;
StaticRefPtr<InProcessChild> InProcessChild::sSingleton;
bool InProcessParent::sShutdown = false;
//////////////////////////////////////////
// InProcess actor lifecycle management //
//////////////////////////////////////////
/* static */ InProcessChild*
InProcessChild::Singleton() {
MOZ_ASSERT(NS_IsMainThread());
if (!sSingleton) {
InProcessParent::Startup();
}
return sSingleton;
}
/* static */ InProcessParent*
InProcessParent::Singleton() {
MOZ_ASSERT(NS_IsMainThread());
if (!sSingleton) {
InProcessParent::Startup();
}
return sSingleton;
}
/* static */ void
InProcessParent::Startup()
{
MOZ_ASSERT(NS_IsMainThread());
if (sShutdown) {
NS_WARNING("Could not get in-process actor while shutting down!");
return;
}
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (!obs) {
sShutdown = true;
NS_WARNING("Failed to get nsIObserverService for in-process actor");
return;
}
RefPtr<InProcessParent> parent = new InProcessParent();
RefPtr<InProcessChild> child = new InProcessChild();
// Observe the shutdown event to close & clean up after ourselves.
nsresult rv = obs->AddObserver(parent, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
// Link the two actors
if (!child->OpenOnSameThread(parent->GetIPCChannel(), ChildSide)) {
MOZ_CRASH("Failed to open InProcessChild!");
}
parent->SetOtherProcessId(base::GetCurrentProcId());
// Create references held by the IPC layer which will be freed in
// DeallocPInProcess{Parent,Child}.
parent.get()->AddRef();
child.get()->AddRef();
// Stash global references to fetch the other side of the reference.
InProcessParent::sSingleton = parent.forget();
InProcessChild::sSingleton = child.forget();
}
/* static */ void
InProcessParent::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread());
if (!sSingleton || sShutdown) {
return;
}
sShutdown = true;
RefPtr<InProcessParent> parent = sSingleton;
InProcessParent::sSingleton = nullptr;
InProcessChild::sSingleton = nullptr;
// Calling `Close` on the actor will cause the `Dealloc` methods to be called,
// freeing the remaining references.
parent->Close();
}
NS_IMETHODIMP
InProcessParent::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
{
MOZ_ASSERT(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID));
InProcessParent::Shutdown();
return NS_OK;
}
void
InProcessParent::ActorDestroy(ActorDestroyReason aWhy)
{
InProcessParent::Shutdown();
}
void
InProcessChild::ActorDestroy(ActorDestroyReason aWhy)
{
InProcessParent::Shutdown();
}
void
InProcessParent::DeallocPInProcessParent()
{
MOZ_ASSERT(!InProcessParent::sSingleton);
Release(); // Release the reference taken in InProcessParent::Startup.
}
void
InProcessChild::DeallocPInProcessChild()
{
MOZ_ASSERT(!InProcessChild::sSingleton);
Release(); // Release the reference taken in InProcessParent::Startup.
}
////////////////////////////////
// In-Process Actor Utilities //
////////////////////////////////
// Helper method for implementing ParentActorFor and ChildActorFor.
static IProtocol*
GetOtherInProcessActor(IProtocol* aActor)
{
MOZ_ASSERT(aActor->GetSide() != UnknownSide, "bad unknown side");
// Discover the manager of aActor which is PInProcess.
IProtocol* current = aActor;
while (current) {
if (current->GetProtocolTypeId() == PInProcessMsgStart) {
break; // Found the correct actor.
}
current = current->Manager();
}
if (!current) {
return nullptr; // Not a PInProcess actor, return |nullptr|
}
MOZ_ASSERT(current->GetSide() == aActor->GetSide(), "side changed?");
MOZ_ASSERT_IF(aActor->GetSide() == ParentSide,
current == InProcessParent::Singleton());
MOZ_ASSERT_IF(aActor->GetSide() == ChildSide,
current == InProcessChild::Singleton());
// Check whether this is InProcessParent or InProcessChild, and get the other
// side's toplevel actor.
IProtocol* otherRoot = nullptr;
if (aActor->GetSide() == ParentSide) {
otherRoot = InProcessChild::Singleton();
} else {
otherRoot = InProcessParent::Singleton();
}
if (NS_WARN_IF(!otherRoot)) {
return nullptr;
}
// Look up the actor on the other side, and return it.
IProtocol* otherActor = otherRoot->Lookup(aActor->Id());
if (otherActor) {
MOZ_ASSERT(otherActor->GetSide() != UnknownSide, "bad unknown side");
MOZ_ASSERT(otherActor->GetSide() != aActor->GetSide(), "Wrong side!");
MOZ_ASSERT(otherActor->GetProtocolTypeId() == aActor->GetProtocolTypeId(),
"Wrong type of protocol!");
}
return otherActor;
}
/* static */ IProtocol*
InProcessParent::ChildActorFor(IProtocol* aActor)
{
MOZ_ASSERT(aActor && aActor->GetSide() == ParentSide);
return GetOtherInProcessActor(aActor);
}
/* static */ IProtocol*
InProcessChild::ParentActorFor(IProtocol* aActor)
{
MOZ_ASSERT(aActor && aActor->GetSide() == ChildSide);
return GetOtherInProcessActor(aActor);
}
} // namespace ipc
} // namespace mozilla

View File

@ -1,41 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=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 "mozilla/ipc/InProcessParent.h"
#include "mozilla/dom/WindowGlobalParent.h"
using namespace mozilla::dom;
namespace mozilla {
namespace ipc {
NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver)
IPCResult
InProcessParent::RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor,
const WindowGlobalInit& aInit)
{
static_cast<WindowGlobalParent*>(aActor)->Init(aInit);
return IPC_OK();
}
PWindowGlobalParent*
InProcessParent::AllocPWindowGlobalParent(const WindowGlobalInit& aInit)
{
// Reference freed in DeallocPWindowGlobalParent.
return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ true)).take();
}
bool
InProcessParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor)
{
// Free IPC-held reference.
static_cast<WindowGlobalParent*>(aActor)->Release();
return true;
}
} // namespace ipc
} // namespace mozilla

View File

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=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_ipc_InProcessParent_h
#define mozilla_ipc_InProcessParent_h
#include "mozilla/ipc/PInProcessParent.h"
#include "mozilla/StaticPtr.h"
namespace mozilla {
namespace dom {
class PWindowGlobalParent;
class PWindowGlobalChild;
} // namespace dom
namespace ipc {
class InProcessChild;
/**
* The `InProcessParent` class represents the parent half of a main-thread to
* main-thread actor.
*
* The `PInProcess` actor should be used as an alternate manager to `PContent`
* for async actors which want to communicate uniformly between Content->Chrome
* and Chrome->Chrome situations.
*/
class InProcessParent : public nsIObserver
, public PInProcessParent
{
public:
friend class InProcessChild;
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
// Get the singleton instance of this actor.
static InProcessParent* Singleton();
// Get the child side of the in-process child actor |aActor|. If |aActor| is
// not an in-process actor, or is not connected, this method will return
// |nullptr|.
static IProtocol* ChildActorFor(IProtocol* aActor);
protected:
virtual mozilla::dom::PWindowGlobalParent*
AllocPWindowGlobalParent(const WindowGlobalInit& aInit) override;
virtual bool
DeallocPWindowGlobalParent(mozilla::dom::PWindowGlobalParent* aActor) override;
virtual IPCResult
RecvPWindowGlobalConstructor(mozilla::dom::PWindowGlobalParent* aActor,
const WindowGlobalInit& aInit) override;
private:
// Lifecycle management is implemented in InProcessImpl.cpp
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual void DeallocPInProcessParent() override;
~InProcessParent() = default;
static void Startup();
static void Shutdown();
static StaticRefPtr<InProcessParent> sSingleton;
static bool sShutdown;
};
} // namespace ipc
} // namespace mozilla
#endif // defined(mozilla_ipc_InProcessParent_h)

View File

@ -634,8 +634,7 @@ MessageChannel::MessageChannel(const char* aName,
mPeerPidSet(false),
mPeerPid(-1),
mIsPostponingSends(false),
mBuildIDsConfirmedMatch(false),
mIsSameThreadChannel(false)
mBuildIDsConfirmedMatch(false)
{
MOZ_COUNT_CTOR(ipc::MessageChannel);
@ -967,35 +966,6 @@ MessageChannel::CommonThreadOpenInit(MessageChannel *aTargetChan, Side aSide)
mSide = aSide;
}
bool
MessageChannel::OpenOnSameThread(MessageChannel* aTargetChan,
mozilla::ipc::Side aSide)
{
CommonThreadOpenInit(aTargetChan, aSide);
Side oppSide = UnknownSide;
switch (aSide) {
case ChildSide: oppSide = ParentSide; break;
case ParentSide: oppSide = ChildSide; break;
case UnknownSide: break;
}
mIsSameThreadChannel = true;
// XXX(nika): Avoid setting up a monitor for same thread channels? We
// shouldn't need it.
mMonitor = new RefCountedMonitor();
mChannelState = ChannelOpening;
aTargetChan->CommonThreadOpenInit(this, oppSide);
aTargetChan->mIsSameThreadChannel = true;
aTargetChan->mMonitor = mMonitor;
mChannelState = ChannelConnected;
aTargetChan->mChannelState = ChannelConnected;
return true;
}
bool
MessageChannel::Echo(Message* aMsg)
{
@ -1505,8 +1475,6 @@ MessageChannel::Send(Message* aMsg, Message* aReply)
// Sanity checks.
AssertWorkerThread();
mMonitor->AssertNotCurrentThreadOwns();
MOZ_RELEASE_ASSERT(!mIsSameThreadChannel,
"sync send over same-thread channel will deadlock!");
#ifdef OS_WIN
SyncStackFrame frame(this, false);
@ -1712,8 +1680,6 @@ MessageChannel::Call(Message* aMsg, Message* aReply)
UniquePtr<Message> msg(aMsg);
AssertWorkerThread();
mMonitor->AssertNotCurrentThreadOwns();
MOZ_RELEASE_ASSERT(!mIsSameThreadChannel,
"intr call send over same-thread channel will deadlock!");
#ifdef OS_WIN
SyncStackFrame frame(this, true);
@ -2490,9 +2456,6 @@ MessageChannel::WaitForSyncNotify(bool /* aHandleWindowsMessages */)
}
#endif
MOZ_RELEASE_ASSERT(!mIsSameThreadChannel,
"Wait on same-thread channel will deadlock!");
TimeDuration timeout = (kNoTimeout == mTimeoutMs) ?
TimeDuration::Forever() :
TimeDuration::FromMilliseconds(mTimeoutMs);
@ -2805,10 +2768,6 @@ MessageChannel::SynchronouslyClose()
AssertWorkerThread();
mMonitor->AssertCurrentThreadOwns();
mLink->SendClose();
MOZ_RELEASE_ASSERT(!mIsSameThreadChannel || ChannelClosed == mChannelState,
"same-thread channel failed to synchronously close?");
while (ChannelClosed != mChannelState)
mMonitor->Wait();
}

View File

@ -180,15 +180,6 @@ private:
// in MessageChannel.cpp.
bool Open(MessageChannel *aTargetChan, nsIEventTarget *aEventTarget, Side aSide);
// "Open" a connection to an actor on the current thread.
//
// Returns true if the transport layer was successfully connected,
// i.e., mChannelState == ChannelConnected.
//
// Same-thread channels may not perform synchronous or blocking message
// sends, to avoid deadlocks.
bool OpenOnSameThread(MessageChannel* aTargetChan, Side aSide);
// Close the underlying transport channel.
void Close();
@ -573,20 +564,11 @@ private:
"not on worker thread!");
}
// The "link" thread is either the I/O thread (ProcessLink), the other
// actor's work thread (ThreadLink), or the worker thread (same-thread
// channels).
// The "link" thread is either the I/O thread (ProcessLink) or the
// other actor's work thread (ThreadLink). In either case, it is
// NOT our worker thread.
void AssertLinkThread() const
{
if (mIsSameThreadChannel) {
// If we're a same-thread channel, we have to be on our worker
// thread.
AssertWorkerThread();
return;
}
// If we aren't a same-thread channel, our "link" thread is _not_ our
// worker thread!
MOZ_ASSERT(mWorkerThread, "Channel hasn't been opened yet");
MOZ_RELEASE_ASSERT(mWorkerThread != GetCurrentVirtualThread(),
"on worker thread but should not be!");
@ -879,10 +861,6 @@ private:
std::vector<UniquePtr<Message>> mPostponedSends;
bool mBuildIDsConfirmedMatch;
// If this is true, both ends of this message channel have event targets
// on the same thread.
bool mIsSameThreadChannel;
};
void

View File

@ -1,35 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
/* 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 protocol PWindowGlobal;
include DOMTypes;
namespace mozilla {
namespace ipc {
/**
* PInProcess is intended for use as an alternative actor manager to PContent
* for async actors which want to be used uniformly in both Content->Chrome and
* Chrome->Chrome circumstances.
*
* `mozilla::ipc::InProcess{Parent, Child}::Singleton()` should be used to get
* an instance of this actor.
*/
async protocol PInProcess
{
manages PWindowGlobal;
parent:
/**
* Construct a new WindowGlobal actor for a window global in the given
* BrowsingContext and with the given principal.
*/
async PWindowGlobal(WindowGlobalInit init);
};
} // namespace ipc
} // namespace mozilla

View File

@ -596,9 +596,6 @@ IProtocol::SetManagerAndRegister(IProtocol* aManager)
aManager->Register(this);
mState->SetIPCChannel(aManager->GetIPCChannel());
// Note that our actor has been opened.
ActorOpenedInternal();
}
void
@ -611,9 +608,6 @@ IProtocol::SetManagerAndRegister(IProtocol* aManager, int32_t aId)
aManager->RegisterID(this, aId);
mState->SetIPCChannel(aManager->GetIPCChannel());
// Note that our actor has been opened.
ActorOpenedInternal();
}
void
@ -757,7 +751,6 @@ IToplevelProtocol::Open(mozilla::ipc::Transport* aTransport,
mozilla::ipc::Side aSide)
{
SetOtherProcessId(aOtherPid);
ActorOpenedInternal();
return GetIPCChannel()->Open(aTransport, aThread, aSide);
}
@ -767,7 +760,6 @@ IToplevelProtocol::Open(MessageChannel* aChannel,
mozilla::ipc::Side aSide)
{
SetOtherProcessId(base::GetCurrentProcId());
ActorOpenedInternal();
return GetIPCChannel()->Open(aChannel, aMessageLoop->SerialEventTarget(), aSide);
}
@ -777,7 +769,6 @@ IToplevelProtocol::Open(MessageChannel* aChannel,
mozilla::ipc::Side aSide)
{
SetOtherProcessId(base::GetCurrentProcId());
ActorOpenedInternal();
return GetIPCChannel()->Open(aChannel, aEventTarget, aSide);
}
@ -786,18 +777,9 @@ IToplevelProtocol::OpenWithAsyncPid(mozilla::ipc::Transport* aTransport,
MessageLoop* aThread,
mozilla::ipc::Side aSide)
{
ActorOpenedInternal();
return GetIPCChannel()->Open(aTransport, aThread, aSide);
}
bool
IToplevelProtocol::OpenOnSameThread(MessageChannel* aChannel, Side aSide)
{
SetOtherProcessId(base::GetCurrentProcId());
ActorOpenedInternal();
return GetIPCChannel()->OpenOnSameThread(aChannel, aSide);
}
void
IToplevelProtocol::Close()
{
@ -827,9 +809,6 @@ IToplevelProtocol::ToplevelState::Register(IProtocol* aRouted)
mActorMap.AddWithID(aRouted, id);
aRouted->SetId(id);
// Inform our actor that it has been opened.
aRouted->ActorOpenedInternal();
// Inherit our event target from our manager.
if (IProtocol* manager = aRouted->Manager()) {
MutexAutoLock lock(mEventTargetMutex);
@ -847,10 +826,6 @@ IToplevelProtocol::ToplevelState::RegisterID(IProtocol* aRouted,
{
mActorMap.AddWithID(aRouted, aId);
aRouted->SetId(aId);
// Inform our actor that it has been opened.
aRouted->ActorOpenedInternal();
return aId;
}
@ -1065,7 +1040,6 @@ IToplevelProtocol::ToplevelState::SetEventTargetForActor(IProtocol* aActor,
// Register the actor early. When it's registered again, it will keep the same
// ID.
int32_t id = Register(aActor);
// XXX(nika): Register already calls SetId?
aActor->SetId(id);
MutexAutoLock lock(mEventTargetMutex);

View File

@ -322,15 +322,6 @@ public:
virtual int32_t GetProtocolTypeId() = 0;
// Returns |true| if the IPC channel is currently open, and |false|
// otherwise.
bool IPCOpen() const { return mIPCOpen; }
// This virtual method is called on actors as they are being destroyed from
// IPC's point of view. After ActorDestroy is called, IPC will free its
// reference to the actor.
virtual void ActorDestroy(ActorDestroyReason aWhy) {}
int32_t Id() const { return mId; }
IProtocol* Manager() const { return mManager; }
@ -359,7 +350,6 @@ protected:
IProtocol(Side aSide, UniquePtr<ProtocolState> aState)
: mId(0)
, mSide(aSide)
, mIPCOpen(false)
, mManager(nullptr)
, mState(std::move(aState))
{}
@ -378,28 +368,12 @@ protected:
void SetManagerAndRegister(IProtocol* aManager);
void SetManagerAndRegister(IProtocol* aManager, int32_t aId);
// This method marks the channel as closed. Actors have this called when
// |DestroySubtree| is called due to the underlying channel being closed, or
// the actor's __delete__ method being called.
void ActorDestroyInternal(ActorDestroyReason aWhy) {
mIPCOpen = false;
ActorDestroy(aWhy);
}
// This method marks the channel as opened. Managed actors have this set
// when they are registered with their manager, and toplevel actors set this
// when opening the underlying MessageChannel.
void ActorOpenedInternal() {
mIPCOpen = true;
}
static const int32_t kNullActorId = 0;
static const int32_t kFreedActorId = 1;
private:
int32_t mId;
Side mSide;
bool mIPCOpen;
IProtocol* mManager;
UniquePtr<ProtocolState> mState;
};
@ -540,15 +514,6 @@ public:
MessageLoop* aThread = nullptr,
mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide);
// Open a toplevel actor such that both ends of the actor's channel are on
// the same thread. This method should be called on the thread to perform
// the link.
//
// WARNING: Attempting to send a sync or intr message on the same thread
// will crash.
bool OpenOnSameThread(MessageChannel* aChannel,
mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide);
void Close();
void SetReplyTimeoutMs(int32_t aTimeoutMs);

View File

@ -27,8 +27,6 @@ EXPORTS.mozilla.ipc += [
'FileDescriptorSetParent.h',
'FileDescriptorUtils.h',
'GeckoChildProcessHost.h',
'InProcessChild.h',
'InProcessParent.h',
'InputStreamUtils.h',
'IOThreadChild.h',
'IPCStreamAlloc.h',
@ -149,9 +147,6 @@ UNIFIED_SOURCES += [
'CrashReporterMetadataShmem.cpp',
'FileDescriptor.cpp',
'FileDescriptorUtils.cpp',
'InProcessChild.cpp',
'InProcessImpl.cpp',
'InProcessParent.cpp',
'InputStreamUtils.cpp',
'IPCMessageUtils.cpp',
'IPCStreamChild.cpp',
@ -213,7 +208,6 @@ IPDL_SOURCES = [
'PBackgroundTest.ipdl',
'PChildToParentStream.ipdl',
'PFileDescriptorSet.ipdl',
'PInProcess.ipdl',
'PParentToChildStream.ipdl',
'ProtocolTypes.ipdlh',
'URIParams.ipdlh',

View File

@ -487,8 +487,8 @@ def errfnSentinel(rvalue=ExprLiteral.FALSE):
return inner
def _destroyInternalMethod():
return ExprVar('ActorDestroyInternal')
def _destroyMethod():
return ExprVar('ActorDestroy')
def errfnUnreachable(msg):
@ -3269,6 +3269,21 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
params=[Decl(actortype, 'aActor')],
ret=Type.BOOL, methodspec=MethodSpec.PURE)))
# ActorDestroy() method; default is no-op
if self.side == 'parent':
methodspec = MethodSpec.PURE
else:
methodspec = MethodSpec.VIRTUAL
self.cls.addstmts([
Whitespace.NL,
MethodDefn(MethodDecl(
_destroyMethod().name,
params=[Decl(_DestroyReason.Type(), 'aWhy')],
ret=Type.VOID, methodspec=methodspec)),
Whitespace.NL
])
if ptype.isToplevel():
# void ProcessingError(code); default to no-op
processingerror = MethodDefn(
@ -3649,7 +3664,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
destroysubtree.addstmts([Whitespace('// Finally, destroy "us".\n',
indent=1),
StmtExpr(ExprCall(_destroyInternalMethod(),
StmtExpr(ExprCall(_destroyMethod(),
args=[whyvar]))
])
@ -3895,35 +3910,13 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
msgvar, stmts = self.makeMessage(md, errfnSendCtor)
sendok, sendstmts = self.sendAsync(md, msgvar)
warnif = StmtIf(ExprNot(sendok))
warnif.addifstmt(_printWarningMessage('Error sending constructor'))
method.addstmts(
# Build our constructor message & verify it.
stmts
+ self.genVerifyMessage(md.decl.type.verify, md.params,
errfnSendCtor, ExprVar('msg__'))
# Assert that we haven't been shut down yet.
+ [_abortIfFalse(ExprCall(ExprVar('IPCOpen')),
"Cannot send constructor after ActorDestroy")]
# Notify the other side about the newly created actor.
#
# If the MessageChannel is closing, and we haven't been told yet,
# this send may fail. This error is ignored to treat it like a
# message being lost due to the other side shutting down before
# processing it.
#
# NOTE: We don't free the actor here, as our caller may be
# depending on it being alive after calling SendConstructor.
+ sendstmts
# Warn if the message failed to send, and return our newly created
# actor.
+ [warnif,
StmtReturn(actor.var())])
+ self.failCtorIf(md, ExprNot(sendok))
+ [StmtReturn(actor.var())])
lbl = CaseLabel(md.pqReplyId())
case = StmtBlock()

View File

@ -68,6 +68,7 @@ CookieServiceChild::CookieServiceChild()
, mThirdPartySession(false)
, mThirdPartyNonsecureSession(false)
, mLeaveSecureAlone(true)
, mIPCOpen(false)
{
NS_ASSERTION(IsNeckoChild(), "not a child process");
@ -85,6 +86,8 @@ CookieServiceChild::CookieServiceChild()
// Create a child PCookieService actor.
gNeckoChild->SendPCookieServiceConstructor(this);
mIPCOpen = true;
mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
NS_ASSERTION(mTLDService, "couldn't get TLDService");
@ -153,10 +156,16 @@ CookieServiceChild::~CookieServiceChild()
gCookieService = nullptr;
}
void
CookieServiceChild::ActorDestroy(ActorDestroyReason why)
{
mIPCOpen = false;
}
void
CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel)
{
if (!IPCOpen()) {
if (!mIPCOpen) {
return;
}
@ -643,7 +652,7 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
}
// Asynchronously call the parent.
if (IPCOpen()) {
if (mIPCOpen) {
SendSetCookieString(hostURIParams, channelURIParams,
isForeign, isTrackingResource,
firstPartyStorageAccessGranted, cookieString,

View File

@ -116,6 +116,8 @@ protected:
mozilla::ipc::IPCResult RecvAddCookie(const CookieStruct &aCookie,
const OriginAttributes &aAttrs) override;
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
CookiesMap mCookiesMap;
nsCOMPtr<nsITimer> mCookieTimer;
nsCOMPtr<mozIThirdPartyUtil> mThirdPartyUtil;
@ -124,6 +126,7 @@ protected:
bool mThirdPartySession;
bool mThirdPartyNonsecureSession;
bool mLeaveSecureAlone;
bool mIPCOpen;
};
} // namespace net

View File

@ -215,7 +215,7 @@ public:
NS_IMETHOD Run() override
{
if (mDnsRequest->IPCOpen()) {
if (mDnsRequest->mIPCOpen) {
// Send request to Parent process.
mDnsRequest->SendCancelDNSRequest(mDnsRequest->mHost,
mDnsRequest->mType,
@ -247,6 +247,7 @@ DNSRequestChild::DNSRequestChild(const nsACString &aHost,
, mType(aType)
, mOriginAttributes(aOriginAttributes)
, mFlags(aFlags)
, mIPCOpen(false)
{
}
@ -277,6 +278,7 @@ DNSRequestChild::StartRequest()
// Send request to Parent process.
gNeckoChild->SendPDNSRequestConstructor(this, mHost, mOriginAttributes,
mFlags);
mIPCOpen = true;
// IPDL holds a reference until IPDL channel gets destroyed
AddIPDLReference();
@ -300,6 +302,7 @@ DNSRequestChild::CallOnLookupByTypeComplete()
mozilla::ipc::IPCResult
DNSRequestChild::RecvLookupCompleted(const DNSRequestResponse& reply)
{
mIPCOpen = false;
MOZ_ASSERT(mListener);
switch (reply.type()) {
@ -368,6 +371,12 @@ DNSRequestChild::ReleaseIPDLReference()
Release();
}
void
DNSRequestChild::ActorDestroy(ActorDestroyReason why)
{
mIPCOpen = false;
}
//-----------------------------------------------------------------------------
// DNSRequestChild::nsISupports
//-----------------------------------------------------------------------------
@ -382,7 +391,7 @@ NS_IMPL_ISUPPORTS(DNSRequestChild,
NS_IMETHODIMP
DNSRequestChild::Cancel(nsresult reason)
{
if(IPCOpen()) {
if(mIPCOpen) {
// We can only do IPDL on the main thread
nsCOMPtr<nsIRunnable> runnable = new CancelDNSRequestEvent(this, reason);
SystemGroup::Dispatch(TaskCategory::Other, runnable.forget());

View File

@ -47,6 +47,7 @@ protected:
virtual ~DNSRequestChild() {}
virtual mozilla::ipc::IPCResult RecvLookupCompleted(const DNSRequestResponse& reply) override;
virtual void ActorDestroy(ActorDestroyReason why) override;
nsCOMPtr<nsIDNSListener> mListener;
nsCOMPtr<nsIEventTarget> mTarget;
@ -62,6 +63,7 @@ protected:
uint16_t mType;
const OriginAttributes mOriginAttributes;
uint16_t mFlags;
bool mIPCOpen;
};
} // namespace net

View File

@ -17,6 +17,7 @@ NS_IMPL_ISUPPORTS_INHERITED(DataChannelChild, nsDataChannel, nsIChildChannel)
DataChannelChild::DataChannelChild(nsIURI* aURI)
: nsDataChannel(aURI)
, mIPCOpen(false)
{
}
@ -54,7 +55,7 @@ DataChannelChild::CompleteRedirectSetup(nsIStreamListener *aListener,
return rv;
}
if (IPCOpen()) {
if (mIPCOpen) {
Unused << Send__delete__(this);
}
return NS_OK;
@ -64,11 +65,14 @@ void
DataChannelChild::AddIPDLReference()
{
AddRef();
mIPCOpen = true;
}
void
DataChannelChild::ActorDestroy(ActorDestroyReason why)
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
Release();
}

View File

@ -33,6 +33,8 @@ private:
~DataChannelChild() = default;
void AddIPDLReference();
bool mIPCOpen;
};
} // namespace net

View File

@ -17,6 +17,7 @@ NS_IMPL_ISUPPORTS_INHERITED(FileChannelChild, nsFileChannel, nsIChildChannel)
FileChannelChild::FileChannelChild(nsIURI *uri)
: nsFileChannel(uri)
, mIPCOpen(false)
{
}
@ -54,7 +55,7 @@ FileChannelChild::CompleteRedirectSetup(nsIStreamListener *listener,
return rv;
}
if (IPCOpen()) {
if (mIPCOpen) {
Unused << Send__delete__(this);
}
@ -65,11 +66,14 @@ void
FileChannelChild::AddIPDLReference()
{
AddRef();
mIPCOpen = true;
}
void
FileChannelChild::ActorDestroy(ActorDestroyReason why)
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
Release();
}

View File

@ -33,6 +33,8 @@ private:
~FileChannelChild() = default;;
void AddIPDLReference();
bool mIPCOpen;
};
} // namespace net

View File

@ -34,7 +34,8 @@ namespace mozilla {
namespace net {
FTPChannelChild::FTPChannelChild(nsIURI* uri)
: mUnknownDecoderInvolved(false)
: mIPCOpen(false)
, mUnknownDecoderInvolved(false)
, mCanceled(false)
, mSuspendCount(0)
, mIsPending(false)
@ -64,12 +65,16 @@ FTPChannelChild::~FTPChannelChild()
void
FTPChannelChild::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempt to retain more than one IPDL reference");
mIPCOpen = true;
AddRef();
}
void
FTPChannelChild::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempt to release nonexistent IPDL reference");
mIPCOpen = false;
Release();
}
@ -682,9 +687,8 @@ FTPChannelChild::DoFailedAsyncOpen(const nsresult& statusCode)
mListener = nullptr;
mListenerContext = nullptr;
if (IPCOpen()) {
if (mIPCOpen)
Send__delete__(this);
}
}
class FTPFlushedForDiversionEvent : public NeckoTargetChannelEvent<FTPChannelChild>
@ -759,9 +763,8 @@ FTPChannelChild::RecvDeleteSelf()
void
FTPChannelChild::DoDeleteSelf()
{
if (IPCOpen()) {
if (mIPCOpen)
Send__delete__(this);
}
}
NS_IMETHODIMP
@ -773,16 +776,15 @@ FTPChannelChild::Cancel(nsresult status)
mCanceled = true;
mStatus = status;
if (IPCOpen()) {
if (mIPCOpen)
SendCancel(status);
}
return NS_OK;
}
NS_IMETHODIMP
FTPChannelChild::Suspend()
{
NS_ENSURE_TRUE(IPCOpen(), NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_NOT_AVAILABLE);
LOG(("FTPChannelChild::Suspend [this=%p]\n", this));
@ -801,7 +803,7 @@ FTPChannelChild::Suspend()
NS_IMETHODIMP
FTPChannelChild::Resume()
{
NS_ENSURE_TRUE(IPCOpen(), NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_NOT_AVAILABLE);
LOG(("FTPChannelChild::Resume [this=%p]\n", this));
@ -903,7 +905,7 @@ FTPChannelChild::DivertToParent(ChannelDiverterChild **aChild)
// We must fail DivertToParent() if there's no parent end of the channel (and
// won't be!) due to early failure.
if (NS_FAILED(mStatus) && !IPCOpen()) {
if (NS_FAILED(mStatus) && !mIPCOpen) {
return mStatus;
}

View File

@ -133,6 +133,7 @@ protected:
private:
nsCOMPtr<nsIInputStream> mUploadStream;
bool mIPCOpen;
RefPtr<ChannelEventQueue> mEventQ;
// If nsUnknownDecoder is involved we queue onDataAvailable (and possibly

View File

@ -14,7 +14,7 @@ NS_IMETHODIMP_(MozExternalRefCountType) AltDataOutputStreamChild::Release()
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "AltDataOutputStreamChild");
if (mRefCnt == 1 && IPCOpen()) {
if (mRefCnt == 1 && mIPCOpen) {
// The only reference left is the IPDL one. After the parent replies back
// with a DeleteSelf message, the child will call Send__delete__(this),
// decrementing the ref count and triggering the destructor.
@ -36,7 +36,8 @@ NS_INTERFACE_MAP_BEGIN(AltDataOutputStreamChild)
NS_INTERFACE_MAP_END
AltDataOutputStreamChild::AltDataOutputStreamChild()
: mError(NS_OK)
: mIPCOpen(false)
, mError(NS_OK)
{
MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
}
@ -44,12 +45,16 @@ AltDataOutputStreamChild::AltDataOutputStreamChild()
void
AltDataOutputStreamChild::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempt to retain more than one IPDL reference");
mIPCOpen = true;
AddRef();
}
void
AltDataOutputStreamChild::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempt to release nonexistent IPDL reference");
mIPCOpen = false;
Release();
}
@ -61,7 +66,8 @@ AltDataOutputStreamChild::WriteDataInChunks(const nsDependentCSubstring& data)
for (uint32_t i = 0; i < data.Length();
i = next, next = std::min(data.Length(), next + kChunkSize)) {
nsCString chunk(Substring(data, i, kChunkSize));
if (IPCOpen() && !SendWriteData(chunk)) {
if (mIPCOpen && !SendWriteData(chunk)) {
mIPCOpen = false;
return false;
}
}
@ -71,7 +77,7 @@ AltDataOutputStreamChild::WriteDataInChunks(const nsDependentCSubstring& data)
NS_IMETHODIMP
AltDataOutputStreamChild::Close()
{
if (!IPCOpen()) {
if (!mIPCOpen) {
return NS_ERROR_NOT_AVAILABLE;
}
if (NS_FAILED(mError)) {
@ -84,7 +90,7 @@ AltDataOutputStreamChild::Close()
NS_IMETHODIMP
AltDataOutputStreamChild::Flush()
{
if (!IPCOpen()) {
if (!mIPCOpen) {
return NS_ERROR_NOT_AVAILABLE;
}
if (NS_FAILED(mError)) {
@ -98,7 +104,7 @@ AltDataOutputStreamChild::Flush()
NS_IMETHODIMP
AltDataOutputStreamChild::Write(const char * aBuf, uint32_t aCount, uint32_t *_retval)
{
if (!IPCOpen()) {
if (!mIPCOpen) {
return NS_ERROR_NOT_AVAILABLE;
}
if (NS_FAILED(mError)) {

View File

@ -34,6 +34,7 @@ private:
// Sends data to the parent process in 256k chunks.
bool WriteDataInChunks(const nsDependentCSubstring& data);
bool mIPCOpen;
// If there was an error opening the output stream or writing to it on the
// parent side, this will be set to the error code. We check it before we
// write so we can report an error to the consumer.

View File

@ -16,6 +16,7 @@ NS_IMPL_ISUPPORTS0(AltDataOutputStreamParent)
AltDataOutputStreamParent::AltDataOutputStreamParent(nsIOutputStream* aStream)
: mOutputStream(aStream)
, mStatus(NS_OK)
, mIPCOpen(true)
{
MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
}
@ -29,7 +30,7 @@ mozilla::ipc::IPCResult
AltDataOutputStreamParent::RecvWriteData(const nsCString& data)
{
if (NS_FAILED(mStatus)) {
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendError(mStatus);
}
return IPC_OK();
@ -39,7 +40,7 @@ AltDataOutputStreamParent::RecvWriteData(const nsCString& data)
if (mOutputStream) {
rv = mOutputStream->Write(data.BeginReading(), data.Length(), &n);
MOZ_ASSERT(n == data.Length() || NS_FAILED(rv));
if (NS_FAILED(rv) && IPCOpen()) {
if (NS_FAILED(rv) && mIPCOpen) {
Unused << SendError(rv);
}
}
@ -50,7 +51,7 @@ mozilla::ipc::IPCResult
AltDataOutputStreamParent::RecvClose()
{
if (NS_FAILED(mStatus)) {
if (IPCOpen()) {
if (mIPCOpen) {
Unused << SendError(mStatus);
}
return IPC_OK();
@ -58,7 +59,7 @@ AltDataOutputStreamParent::RecvClose()
nsresult rv;
if (mOutputStream) {
rv = mOutputStream->Close();
if (NS_FAILED(rv) && IPCOpen()) {
if (NS_FAILED(rv) && mIPCOpen) {
Unused << SendError(rv);
}
mOutputStream = nullptr;
@ -66,9 +67,16 @@ AltDataOutputStreamParent::RecvClose()
return IPC_OK();
}
void
AltDataOutputStreamParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}
mozilla::ipc::IPCResult
AltDataOutputStreamParent::RecvDeleteSelf()
{
mIPCOpen = false;
Unused << SendDeleteSelf();
return IPC_OK();
}

View File

@ -33,6 +33,7 @@ public:
// Called when AltDataOutputStreamChild::Close() is
// Closes and nulls the output stream.
virtual mozilla::ipc::IPCResult RecvClose() override;
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
// Sets an error that will be reported to the content process.
void SetError(nsresult status) { mStatus = status; }
@ -44,6 +45,7 @@ private:
// In case any error occurs mStatus will be != NS_OK, and this status code will
// be sent to the content process asynchronously.
nsresult mStatus;
bool mIPCOpen;
};
} // namespace net

View File

@ -2441,11 +2441,10 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult result)
ChildLoadInfoForwarderArgs loadInfoForwarder;
LoadInfoToChildLoadInfoForwarder(newChannelLoadInfo, &loadInfoForwarder);
if (mIPCOpen) {
if (mIPCOpen)
SendRedirect2Verify(result, *headerTuples, loadInfoForwarder, loadFlags,
referrerPolicy, referrerURI, redirectURI,
corsPreflightArgs, chooseAppcache);
}
return NS_OK;
}

View File

@ -29,6 +29,7 @@ WebSocketChannelParent::WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvi
uint32_t aSerial)
: mAuthProvider(aAuthProvider)
, mLoadContext(aLoadContext)
, mIPCOpen(true)
, mSerial(aSerial)
{
// Websocket channels can't have a private browsing override
@ -45,7 +46,7 @@ WebSocketChannelParent::RecvDeleteSelf()
mChannel = nullptr;
mAuthProvider = nullptr;
IProtocol* mgr = Manager();
if (IPCOpen() && !Send__delete__(this)) {
if (mIPCOpen && !Send__delete__(this)) {
return IPC_FAIL_NO_REASON(mgr);
}
return IPC_OK();
@ -221,7 +222,7 @@ WebSocketChannelParent::OnStart(nsISupports *aContext)
channel->GetEffectiveURL(effectiveURL);
encrypted = channel->IsEncrypted();
}
if (!IPCOpen() || !SendOnStart(protocol, extensions, effectiveURL, encrypted)) {
if (!mIPCOpen || !SendOnStart(protocol, extensions, effectiveURL, encrypted)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -231,7 +232,7 @@ NS_IMETHODIMP
WebSocketChannelParent::OnStop(nsISupports *aContext, nsresult aStatusCode)
{
LOG(("WebSocketChannelParent::OnStop() %p\n", this));
if (!IPCOpen() || !SendOnStop(aStatusCode)) {
if (!mIPCOpen || !SendOnStop(aStatusCode)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -241,7 +242,7 @@ NS_IMETHODIMP
WebSocketChannelParent::OnMessageAvailable(nsISupports *aContext, const nsACString& aMsg)
{
LOG(("WebSocketChannelParent::OnMessageAvailable() %p\n", this));
if (!IPCOpen() || !SendOnMessageAvailable(nsCString(aMsg))) {
if (!mIPCOpen || !SendOnMessageAvailable(nsCString(aMsg))) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -251,7 +252,7 @@ NS_IMETHODIMP
WebSocketChannelParent::OnBinaryMessageAvailable(nsISupports *aContext, const nsACString& aMsg)
{
LOG(("WebSocketChannelParent::OnBinaryMessageAvailable() %p\n", this));
if (!IPCOpen() || !SendOnBinaryMessageAvailable(nsCString(aMsg))) {
if (!mIPCOpen || !SendOnBinaryMessageAvailable(nsCString(aMsg))) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -261,7 +262,7 @@ NS_IMETHODIMP
WebSocketChannelParent::OnAcknowledge(nsISupports *aContext, uint32_t aSize)
{
LOG(("WebSocketChannelParent::OnAcknowledge() %p\n", this));
if (!IPCOpen() || !SendOnAcknowledge(aSize)) {
if (!mIPCOpen || !SendOnAcknowledge(aSize)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -272,7 +273,7 @@ WebSocketChannelParent::OnServerClose(nsISupports *aContext,
uint16_t code, const nsACString & reason)
{
LOG(("WebSocketChannelParent::OnServerClose() %p\n", this));
if (!IPCOpen() || !SendOnServerClose(code, nsCString(reason))) {
if (!mIPCOpen || !SendOnServerClose(code, nsCString(reason))) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -289,6 +290,8 @@ WebSocketChannelParent::ActorDestroy(ActorDestroyReason why)
Unused << mChannel->Close(nsIWebSocketChannel::CLOSE_GOING_AWAY,
NS_LITERAL_CSTRING("Child was killed"));
}
mIPCOpen = false;
}
//-----------------------------------------------------------------------------

View File

@ -61,6 +61,7 @@ class WebSocketChannelParent : public PWebSocketParent,
nsCOMPtr<nsIAuthPromptProvider> mAuthProvider;
nsCOMPtr<nsIWebSocketChannel> mChannel;
nsCOMPtr<nsILoadContext> mLoadContext;
bool mIPCOpen;
uint32_t mSerial;
};

View File

@ -47,6 +47,7 @@ WyciwygChannelChild::WyciwygChannelChild(nsIEventTarget *aNeckoTarget)
, mContentLength(-1)
, mCharsetSource(kCharsetUninitialized)
, mState(WCC_NEW)
, mIPCOpen(false)
, mSentAppData(false)
{
LOG(("Creating WyciwygChannelChild @%p\n", this));
@ -73,12 +74,16 @@ WyciwygChannelChild::~WyciwygChannelChild()
void
WyciwygChannelChild::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempt to retain more than one IPDL reference");
mIPCOpen = true;
AddRef();
}
void
WyciwygChannelChild::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempt to release nonexistent IPDL reference");
mIPCOpen = false;
Release();
}
@ -323,9 +328,8 @@ WyciwygChannelChild::OnStopRequest(const nsresult& statusCode)
mProgressSink = nullptr;
}
if (IPCOpen()) {
if (mIPCOpen)
PWyciwygChannelChild::Send__delete__(this);
}
}
class WyciwygCancelEvent : public NeckoTargetChannelEvent<WyciwygChannelChild>
@ -369,9 +373,8 @@ void WyciwygChannelChild::CancelEarly(const nsresult& statusCode)
mListener = nullptr;
mListenerContext = nullptr;
if (IPCOpen()) {
if (mIPCOpen)
PWyciwygChannelChild::Send__delete__(this);
}
}
//-----------------------------------------------------------------------------
@ -406,9 +409,8 @@ WyciwygChannelChild::Cancel(nsresult aStatus)
mCanceled = true;
mStatus = aStatus;
if (IPCOpen()) {
if (mIPCOpen)
SendCancel(aStatus);
}
return NS_OK;
}
@ -751,9 +753,8 @@ WyciwygChannelChild::CloseCacheEntry(nsresult reason)
SendCloseCacheEntry(reason);
mState = WCC_ONCLOSED;
if (IPCOpen()) {
if (mIPCOpen)
PWyciwygChannelChild::Send__delete__(this);
}
return NS_OK;
}

View File

@ -104,6 +104,7 @@ private:
// FIXME: replace with IPDL states (bug 536319)
enum WyciwygChannelChildState mState;
bool mIPCOpen;
bool mSentAppData;
RefPtr<ChannelEventQueue> mEventQ;

Some files were not shown because too many files have changed in this diff Show More