Bug 1231213 - Implement ServiceWorkerOp{Args,Promise,Result}, FetchEventRespondWith{Promise,Result}, and IPCFetchEventRespondWithResult. r=asuth
☠☠ backed out by 3cf55b7f12f2 ☠ ☠
authorPerry Jiang <perry@mozilla.com>
Wed, 14 Aug 2019 16:19:42 +0000
changeset 488065 bf5d60c7a85a2444df3a3740c5daeb230a87e248
parent 488064 cd434b787ce62199119834aeafcaebd4ed53d1fc
child 488066 bacf8499ba7b2caf600a8fef352baf7df3a69d6d
push id113900
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:53:50 +0000
treeherdermozilla-inbound@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1231213
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1231213 - Implement ServiceWorkerOp{Args,Promise,Result}, FetchEventRespondWith{Promise,Result}, and IPCFetchEventRespondWithResult. r=asuth Differential Revision: https://phabricator.services.mozilla.com/D26164
dom/serviceworkers/ServiceWorkerOpArgs.ipdlh
dom/serviceworkers/ServiceWorkerOpPromise.h
dom/serviceworkers/moz.build
new file mode 100644
--- /dev/null
+++ b/dom/serviceworkers/ServiceWorkerOpArgs.ipdlh
@@ -0,0 +1,129 @@
+/* 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 ChannelInfo;
+include ClientIPCTypes;
+include DOMTypes;
+include FetchTypes;
+
+using ServiceWorkerState from "mozilla/dom/ServiceWorkerIPCUtils.h";
+
+namespace mozilla {
+namespace dom {
+
+/**
+ * ServiceWorkerOpArgs
+ */
+struct ServiceWorkerCheckScriptEvaluationOpArgs {};
+
+struct ServiceWorkerUpdateStateOpArgs {
+  ServiceWorkerState state;
+};
+
+struct ServiceWorkerTerminateWorkerOpArgs {};
+
+struct ServiceWorkerLifeCycleEventOpArgs {
+  nsString eventName;
+};
+
+// Possibly need to differentiate an empty array from the absence of an array.
+union OptionalPushData {
+  void_t;
+  uint8_t[];
+};
+
+struct ServiceWorkerPushEventOpArgs {
+  nsString messageId;
+  OptionalPushData data;
+};
+
+struct ServiceWorkerPushSubscriptionChangeEventOpArgs {};
+
+struct ServiceWorkerNotificationEventOpArgs {
+  nsString eventName;
+  nsString id;
+  nsString title;
+  nsString dir;
+  nsString lang;
+  nsString body;
+  nsString tag;
+  nsString icon;
+  nsString data;
+  nsString behavior;
+  nsString scope;
+  uint32_t disableOpenClickDelay;
+};
+
+struct ServiceWorkerMessageEventOpArgs {
+  ClientInfoAndState clientInfoAndState;
+  ClonedMessageData clonedData;
+};
+
+struct ServiceWorkerFetchEventOpArgs {
+  nsCString workerScriptSpec;
+  IPCInternalRequest internalRequest;
+  nsString clientId;
+  nsString resultingClientId;
+  bool isReload;
+  bool isNonSubresourceRequest;
+};
+
+union ServiceWorkerOpArgs {
+  ServiceWorkerCheckScriptEvaluationOpArgs;
+  ServiceWorkerUpdateStateOpArgs;
+  ServiceWorkerTerminateWorkerOpArgs;
+  ServiceWorkerLifeCycleEventOpArgs;
+  ServiceWorkerPushEventOpArgs;
+  ServiceWorkerPushSubscriptionChangeEventOpArgs;
+  ServiceWorkerNotificationEventOpArgs;
+  ServiceWorkerMessageEventOpArgs;
+  ServiceWorkerFetchEventOpArgs;
+};
+
+/**
+ * IPCFetchEventRespondWithResult
+ */
+struct FetchEventRespondWithClosure {
+  nsCString respondWithScriptSpec;
+  uint32_t respondWithLineNumber;
+  uint32_t respondWithColumnNumber;
+};
+
+struct IPCSynthesizeResponseArgs {
+  IPCInternalResponse internalResponse;
+  FetchEventRespondWithClosure closure;
+};
+
+struct ResetInterceptionArgs {};
+
+struct CancelInterceptionArgs {
+  nsresult status;
+};
+
+union IPCFetchEventRespondWithResult {
+  IPCSynthesizeResponseArgs;
+  ResetInterceptionArgs;
+  CancelInterceptionArgs;
+};
+
+/**
+ * ServiceWorkerOpResult
+ */
+struct ServiceWorkerCheckScriptEvaluationOpResult {
+  bool workerScriptExecutedSuccessfully;
+  bool fetchHandlerWasAdded;
+};
+
+struct ServiceWorkerFetchEventOpResult {
+  nsresult rv;
+};
+
+union ServiceWorkerOpResult {
+  nsresult;
+  ServiceWorkerCheckScriptEvaluationOpResult;
+  ServiceWorkerFetchEventOpResult;
+};
+
+}  // namespace dom
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/serviceworkers/ServiceWorkerOpPromise.h
@@ -0,0 +1,36 @@
+/* -*- 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_serviceworkeroppromise_h__
+#define mozilla_dom_serviceworkeroppromise_h__
+
+#include "mozilla/MozPromise.h"
+#include "mozilla/Pair.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/dom/ServiceWorkerOpArgs.h"
+
+namespace mozilla {
+namespace dom {
+
+class InternalResponse;
+
+using SynthesizeResponseArgs =
+    Pair<RefPtr<InternalResponse>, FetchEventRespondWithClosure>;
+
+using FetchEventRespondWithResult =
+    Variant<SynthesizeResponseArgs, ResetInterceptionArgs,
+            CancelInterceptionArgs>;
+
+using FetchEventRespondWithPromise =
+    MozPromise<FetchEventRespondWithResult, nsresult, true>;
+
+using ServiceWorkerOpPromise =
+    MozPromise<ServiceWorkerOpResult, nsresult, true>;
+
+}  // namespace dom
+}  // namespace mozilla
+
+#endif  // mozilla_dom_serviceworkeroppromise_h__
--- a/dom/serviceworkers/moz.build
+++ b/dom/serviceworkers/moz.build
@@ -15,16 +15,17 @@ EXPORTS.mozilla.dom += [
     'ServiceWorkerDescriptor.h',
     'ServiceWorkerEvents.h',
     'ServiceWorkerInfo.h',
     'ServiceWorkerInterceptController.h',
     'ServiceWorkerIPCUtils.h',
     'ServiceWorkerManager.h',
     'ServiceWorkerManagerChild.h',
     'ServiceWorkerManagerParent.h',
+    'ServiceWorkerOpPromise.h',
     'ServiceWorkerRegistrar.h',
     'ServiceWorkerRegistration.h',
     'ServiceWorkerRegistrationDescriptor.h',
     'ServiceWorkerRegistrationInfo.h',
     'ServiceWorkerUtils.h',
 ]
 
 UNIFIED_SOURCES += [
@@ -75,16 +76,17 @@ UNIFIED_SOURCES += [
 IPDL_SOURCES += [
     'IPCServiceWorkerDescriptor.ipdlh',
     'IPCServiceWorkerRegistrationDescriptor.ipdlh',
     'PServiceWorker.ipdl',
     'PServiceWorkerContainer.ipdl',
     'PServiceWorkerManager.ipdl',
     'PServiceWorkerRegistration.ipdl',
     'PServiceWorkerUpdater.ipdl',
+    'ServiceWorkerOpArgs.ipdlh',
     'ServiceWorkerRegistrarTypes.ipdlh',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [