tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ServiceWorkerShutdownState.h (1757B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef DOM_SERVICEWORKERS_SERVICEWORKERSHUTDOWNSTATE_H_
      8 #define DOM_SERVICEWORKERS_SERVICEWORKERSHUTDOWNSTATE_H_
      9 
     10 #include "ipc/EnumSerializer.h"
     11 #include "mozilla/dom/ServiceWorkerOpArgs.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 class ServiceWorkerShutdownState {
     16 public:
     17  // Represents the "location" of the shutdown message or completion of
     18  // shutdown.
     19  enum class Progress {
     20    ParentProcessMainThread,
     21    ParentProcessIpdlBackgroundThread,
     22    ContentProcessWorkerLauncherThread,
     23    ContentProcessMainThread,
     24    ShutdownCompleted,
     25    EndGuard_,
     26  };
     27 
     28  ServiceWorkerShutdownState();
     29 
     30  ~ServiceWorkerShutdownState();
     31 
     32  const char* GetProgressString() const;
     33 
     34  void SetProgress(Progress aProgress);
     35 
     36 private:
     37  Progress mProgress;
     38 };
     39 
     40 // Asynchronously reports that shutdown has progressed to the calling thread
     41 // if aArgs is for shutdown. If aShutdownCompleted is true, aArgs must be for
     42 // shutdown.
     43 void MaybeReportServiceWorkerShutdownProgress(const ServiceWorkerOpArgs& aArgs,
     44                                              bool aShutdownCompleted = false);
     45 
     46 }  // namespace mozilla::dom
     47 
     48 namespace IPC {
     49 
     50 using Progress = mozilla::dom::ServiceWorkerShutdownState::Progress;
     51 
     52 template <>
     53 struct ParamTraits<Progress>
     54    : public ContiguousEnumSerializer<
     55          Progress, Progress::ParentProcessMainThread, Progress::EndGuard_> {};
     56 
     57 }  // namespace IPC
     58 
     59 #endif  // DOM_SERVICEWORKERS_SERVICEWORKERSHUTDOWNSTATE_H_