Files
palemoon27/dom/workers/MessagePort.h
T
roytam1 6f81d7d0dc import changes from `dev' branch of rmottola/Arctic-Fox:
- namespace comment (0548ea8a8)
- Bug 1167411 - Add JSAutoStructuredCloneBuffer::abandon, r=jorendorff (6589a8900)
- Bug 911972 - MessagePort and MessageChannel in workers, r=smaug, r=bent (4c533d3ca)
- Bug 1172264 - Track the MDSM's duration as a TimeUnit and eliminate the separate concept of 'end time'. r=jww (49f8f2442)
- Bug 1172264 - Require Manual disconnection for all mirrors. r=jww (845e57496)
- Bug 1172264 - Switch MediaDecoder's mDuration represenation to a double. r=jww (dfde6482d)
- Bug 1172264 - Mirror duration from the MDSM to the MediaDecoder. r=jww (a744fd08f)
- No bug. Refactor GC type annotations, re=terrence (b6bc5723e)
- Bug 1132744 - Update set of GC types, r=sfink (935175adb)
- Bug 967031 - Rename DumpHeapComplete to DumpHeap; r=terrence (337391745)
- Bug 1169097 - Remove CountHeap; r=sfink (074fdb34c)
- Bug 1169086 - Use virtual dispatch to implement callback tracer; r=jonco, r=mccr8 (667218a33)
2021-04-03 23:50:45 +08:00

113 lines
2.5 KiB
C++

/* -*- 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_dom_workers_messageport_h_
#define mozilla_dom_workers_messageport_h_
#include "mozilla/dom/workers/Workers.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/MessagePort.h"
class nsIDOMEvent;
class nsPIDOMWindow;
namespace mozilla {
class EventChainPreVisitor;
} // namespace mozilla
BEGIN_WORKERS_NAMESPACE
class SharedWorker;
class WorkerPrivate;
class MessagePort final : public mozilla::dom::MessagePortBase
{
friend class SharedWorker;
friend class WorkerPrivate;
typedef mozilla::ErrorResult ErrorResult;
nsRefPtr<SharedWorker> mSharedWorker;
WorkerPrivate* mWorkerPrivate;
nsTArray<nsCOMPtr<nsIDOMEvent>> mQueuedEvents;
uint64_t mSerial;
bool mStarted;
public:
static bool
PrefEnabled();
virtual void
PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const Optional<Sequence<JS::Value>>& aTransferable,
ErrorResult& aRv) override;
virtual void
Start() override;
virtual void
Close() override;
uint64_t
Serial() const
{
return mSerial;
}
void
QueueEvent(nsIDOMEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MessagePort, DOMEventTargetHelper)
virtual EventHandlerNonNull*
GetOnmessage() override;
virtual void
SetOnmessage(EventHandlerNonNull* aCallback) override;
virtual bool
CloneAndDisentangle(MessagePortIdentifier& aIdentifier) override;
bool
IsClosed() const
{
return !mSharedWorker && !mWorkerPrivate;
}
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
virtual nsresult
PreHandleEvent(EventChainPreVisitor& aVisitor) override;
#ifdef DEBUG
void
AssertCorrectThread() const;
#else
void
AssertCorrectThread() const { }
#endif
private:
// This class can only be created by SharedWorker or WorkerPrivate.
MessagePort(nsPIDOMWindow* aWindow, SharedWorker* aSharedWorker,
uint64_t aSerial);
MessagePort(WorkerPrivate* aWorkerPrivate, uint64_t aSerial);
// This class is reference-counted and will be destroyed from Release().
~MessagePort();
void
CloseInternal();
};
END_WORKERS_NAMESPACE
#endif // mozilla_dom_workers_messageport_h_