tor-browser

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

WorkerCommon.h (2146B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_workers_WorkerCommon_h
      8 #define mozilla_dom_workers_WorkerCommon_h
      9 
     10 #include "js/TypeDecls.h"
     11 #include "nsString.h"
     12 
     13 class nsPIDOMWindowInner;
     14 
     15 namespace mozilla::dom {
     16 
     17 class WorkerPrivate;
     18 
     19 // All of these are implemented in RuntimeService.cpp
     20 
     21 WorkerPrivate* GetWorkerPrivateFromContext(JSContext* aCx);
     22 
     23 WorkerPrivate* GetCurrentThreadWorkerPrivate();
     24 
     25 bool IsCurrentThreadRunningWorker();
     26 
     27 bool IsCurrentThreadRunningChromeWorker();
     28 
     29 JSContext* GetCurrentWorkerThreadJSContext();
     30 
     31 JSObject* GetCurrentThreadWorkerGlobal();
     32 
     33 JSObject* GetCurrentThreadWorkerDebuggerGlobal();
     34 
     35 void CancelWorkersForWindow(const nsPIDOMWindowInner& aWindow);
     36 
     37 void UpdateWorkersBackgroundState(const nsPIDOMWindowInner& aWindow,
     38                                  bool aIsBackground);
     39 
     40 void UpdateWorkersPeerConnections(const nsPIDOMWindowInner& aWindow,
     41                                  bool aHasPeerConnections);
     42 
     43 void FreezeWorkersForWindow(const nsPIDOMWindowInner& aWindow);
     44 
     45 void ThawWorkersForWindow(const nsPIDOMWindowInner& aWindow);
     46 
     47 void SuspendWorkersForWindow(const nsPIDOMWindowInner& aWindow);
     48 
     49 void ResumeWorkersForWindow(const nsPIDOMWindowInner& aWindow);
     50 
     51 void PropagateStorageAccessPermissionGrantedToWorkers(
     52    const nsPIDOMWindowInner& aWindow);
     53 
     54 // All of these are implemented in WorkerScope.cpp
     55 
     56 bool IsWorkerGlobal(JSObject* global);
     57 
     58 bool IsWorkerDebuggerGlobal(JSObject* global);
     59 
     60 bool IsWorkerDebuggerSandbox(JSObject* object);
     61 
     62 void UpdateWorkersPlaybackState(const nsPIDOMWindowInner& aWindow,
     63                                bool aIsPlayingAudio);
     64 
     65 inline size_t GetWorkerScriptMaxSizeInBytes() {
     66  // This is the max size that any of our worker scripts can be.
     67  return nsString::LengthStorage::kMax;
     68 }
     69 
     70 }  // namespace mozilla::dom
     71 
     72 #endif  // mozilla_dom_workers_WorkerCommon_h