mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
8316d5a0c0
This is the first basic implementation of a shared-memory key-value store for JS message managers. It has one read-write endpoint in the parent process, and separate read-only endpoints for each child-process message manager. Changes to the parent endpoint are broadcast to the children as snapshots. Each snapshot triggers a "change" event with a list of changed keys. It currently has the following limitations: - It only supports basic structured clone data. There's no support for blobs, input streams, message ports... Blob support will be added in a follow-up patch. - Changes are currently only broadcast to child endpoints when flush() is explicitly called in the parent, or when new child processes are launched. In a follow-up, this will be changed to automatically flush after changes when the event loop is idle. - All set operations clone their inputs synchronously, which means that there's no trivial way for callers to batch multiple changes to a single key without some additional effort. It might be useful to add a delayed-serialization option to the .set() call in a follow-up, for callers who are sure they know what they're doing. MozReview-Commit-ID: IM8a3UgejXU --HG-- extra : rebase_source : 66c92d538a5485349bc789028fdc3a6806bc5d5a extra : source : 2ebaf5f8c6055b11b11d7ec334d54ee941115d48
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
|
/* 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 dom_ipc_SharedMapChangeEvent_h
|
|
#define dom_ipc_SharedMapChangeEvent_h
|
|
|
|
#include "mozilla/dom/MozSharedMapBinding.h"
|
|
|
|
#include "mozilla/dom/Event.h"
|
|
#include "nsTArray.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
namespace ipc {
|
|
|
|
class SharedMapChangeEvent final : public Event
|
|
{
|
|
public:
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(SharedMapChangeEvent, Event)
|
|
|
|
JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
|
{
|
|
return MozSharedMapChangeEvent_Binding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
static already_AddRefed<SharedMapChangeEvent>
|
|
Constructor(EventTarget* aEventTarget,
|
|
const nsAString& aType,
|
|
const MozSharedMapChangeEventInit& aInit);
|
|
|
|
void GetChangedKeys(nsTArray<nsString>& aChangedKeys) const
|
|
{
|
|
aChangedKeys.AppendElements(mChangedKeys);
|
|
}
|
|
|
|
protected:
|
|
~SharedMapChangeEvent() override = default;
|
|
|
|
private:
|
|
explicit SharedMapChangeEvent(EventTarget* aEventTarget)
|
|
: Event(aEventTarget, nullptr, nullptr)
|
|
{}
|
|
|
|
nsTArray<nsString> mChangedKeys;
|
|
};
|
|
|
|
} // ipc
|
|
} // dom
|
|
} // mozilla
|
|
|
|
#endif // dom_ipc_SharedMapChangeEvent_h
|