/* -*- 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/. */
/* * A Notification gets a corresponding IPC actor after successful construction. * The notification object and the actor do not own each other and their * lifetimes are controlled semi-independently. * * The Notification object can be cycle collected when either: * - no one is listening for the events, or * - the backend notification is closed. * * The actor goes away when either: * - the backend notification is closed, or * - the tab is closed or bfcached. * * (It cannot just go away on cycle collection because nsIAlertsService wants to * know whether the triggered page is still open to decide whether to open a new * tab or focus on the existing tab.)
*/ class Notification : public DOMEventTargetHelper, public SupportsWeakPtr { friendclass CloseNotificationRunnable; friendclass NotificationTask; friendclass NotificationPermissionRequest; friendclass MainThreadNotificationObserver; friendclass NotificationStorageCallback; friendclass ServiceWorkerNotificationObserver; friendclass WorkerGetRunnable; friendclass WorkerNotificationObserver;
/** * Used when dispatching the ServiceWorkerEvent. * * Does not initialize the Notification's behavior. * This is because: * 1) The Notification is not shown to the user and so the behavior * parameters don't matter. * 2) The default binding requires main thread for parsing the JSON from the * string behavior.
*/ static Result<already_AddRefed<Notification>, QMResult> ConstructFromFields(
nsIGlobalObject* aGlobal, const nsAString& aID, const nsAString& aTitle, const nsAString& aDir, const nsAString& aLang, const nsAString& aBody, const nsAString& aTag, const nsAString& aIcon, const nsAString& aData, const nsAString& aServiceWorkerRegistrationScope);
// Notification implementation of // ServiceWorkerRegistration.showNotification. // // // Note that aCx may not be in the compartment of aGlobal, but aOptions will // have its JS things in the compartment of aCx. static already_AddRefed<Promise> ShowPersistentNotification(
JSContext* aCx, nsIGlobalObject* aGlobal, const nsAString& aScope, const nsAString& aTitle, const NotificationOptions& aOptions, const ServiceWorkerRegistrationDescriptor& aDescriptor, ErrorResult& aRv);
// It's null until GetData is first called
JS::Heap<JS::Value> mData;
nsString mScope;
bool mIsClosed = false;
private: virtual ~Notification();
// Creates a Notification and shows it. Returns a reference to the // Notification if result is NS_OK. The lifetime of this Notification is tied // to an underlying NotificationRef. Do not hold a non-stack raw pointer to // it. Be careful about thread safety if acquiring a strong reference. // // Note that aCx may not be in the compartment of aGlobal, but aOptions will // have its JS things in the compartment of aCx. static already_AddRefed<Notification> Create(
JSContext* aCx, nsIGlobalObject* aGlobal, const nsAString& aTitle, const NotificationOptions& aOptions, const nsAString& aScope,
ErrorResult& aRv);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.