dom/workers/WorkerScope.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef mozilla_dom_workerscope_h__
     7 #define mozilla_dom_workerscope_h__
     9 #include "Workers.h"
    10 #include "mozilla/DOMEventTargetHelper.h"
    12 namespace mozilla {
    13 namespace dom {
    15 class Console;
    16 class Function;
    18 } // namespace dom
    19 } // namespace mozilla
    21 BEGIN_WORKERS_NAMESPACE
    23 class WorkerPrivate;
    24 class WorkerLocation;
    25 class WorkerNavigator;
    27 class WorkerGlobalScope : public DOMEventTargetHelper,
    28                           public nsIGlobalObject
    29 {
    30   nsRefPtr<Console> mConsole;
    31   nsRefPtr<WorkerLocation> mLocation;
    32   nsRefPtr<WorkerNavigator> mNavigator;
    34 protected:
    35   WorkerPrivate* mWorkerPrivate;
    37   WorkerGlobalScope(WorkerPrivate* aWorkerPrivate);
    38   virtual ~WorkerGlobalScope();
    40 public:
    41   virtual JSObject*
    42   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    44   virtual JSObject*
    45   WrapGlobalObject(JSContext* aCx) = 0;
    47   virtual JSObject*
    48   GetGlobalJSObject(void) MOZ_OVERRIDE
    49   {
    50     return GetWrapper();
    51   }
    53   NS_DECL_ISUPPORTS_INHERITED
    54   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(WorkerGlobalScope,
    55                                                          DOMEventTargetHelper)
    57   already_AddRefed<WorkerGlobalScope>
    58   Self()
    59   {
    60     return nsRefPtr<WorkerGlobalScope>(this).forget();
    61   }
    63   already_AddRefed<Console>
    64   GetConsole();
    66   already_AddRefed<WorkerLocation>
    67   Location();
    69   already_AddRefed<WorkerNavigator>
    70   Navigator();
    72   already_AddRefed<WorkerNavigator>
    73   GetExistingNavigator() const;
    75   void
    76   Close(JSContext* aCx);
    78   OnErrorEventHandlerNonNull*
    79   GetOnerror();
    80   void
    81   SetOnerror(OnErrorEventHandlerNonNull* aHandler);
    83   void
    84   ImportScripts(JSContext* aCx, const Sequence<nsString>& aScriptURLs,
    85                 ErrorResult& aRv);
    87   int32_t
    88   SetTimeout(JSContext* aCx, Function& aHandler, const int32_t aTimeout,
    89              const Sequence<JS::Value>& aArguments, ErrorResult& aRv);
    90   int32_t
    91   SetTimeout(JSContext* /* unused */, const nsAString& aHandler,
    92              const int32_t aTimeout, const Sequence<JS::Value>& /* unused */,
    93              ErrorResult& aRv);
    94   void
    95   ClearTimeout(int32_t aHandle, ErrorResult& aRv);
    96   int32_t
    97   SetInterval(JSContext* aCx, Function& aHandler,
    98               const Optional<int32_t>& aTimeout,
    99               const Sequence<JS::Value>& aArguments, ErrorResult& aRv);
   100   int32_t
   101   SetInterval(JSContext* /* unused */, const nsAString& aHandler,
   102               const Optional<int32_t>& aTimeout,
   103               const Sequence<JS::Value>& /* unused */, ErrorResult& aRv);
   104   void
   105   ClearInterval(int32_t aHandle, ErrorResult& aRv);
   107   void
   108   Atob(const nsAString& aAtob, nsAString& aOutput, ErrorResult& aRv) const;
   109   void
   110   Btoa(const nsAString& aBtoa, nsAString& aOutput, ErrorResult& aRv) const;
   112   IMPL_EVENT_HANDLER(online)
   113   IMPL_EVENT_HANDLER(offline)
   114   IMPL_EVENT_HANDLER(close)
   116   void
   117   Dump(const Optional<nsAString>& aString) const;
   118 };
   120 class DedicatedWorkerGlobalScope MOZ_FINAL : public WorkerGlobalScope
   121 {
   122   ~DedicatedWorkerGlobalScope() { }
   124 public:
   125   DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate);
   127   static bool
   128   Visible(JSContext* aCx, JSObject* aObj);
   130   virtual JSObject*
   131   WrapGlobalObject(JSContext* aCx) MOZ_OVERRIDE;
   133   void
   134   PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
   135               const Optional<Sequence<JS::Value>>& aTransferable,
   136               ErrorResult& aRv);
   138   IMPL_EVENT_HANDLER(message)
   139 };
   141 class SharedWorkerGlobalScope MOZ_FINAL : public WorkerGlobalScope
   142 {
   143   const nsCString mName;
   145   ~SharedWorkerGlobalScope() { }
   147 public:
   148   SharedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
   149                           const nsCString& aName);
   151   static bool
   152   Visible(JSContext* aCx, JSObject* aObj);
   154   virtual JSObject*
   155   WrapGlobalObject(JSContext* aCx) MOZ_OVERRIDE;
   157   void GetName(DOMString& aName) const {
   158     aName.AsAString() = NS_ConvertUTF8toUTF16(mName);
   159   }
   161   IMPL_EVENT_HANDLER(connect)
   162 };
   164 JSObject*
   165 CreateGlobalScope(JSContext* aCx);
   167 END_WORKERS_NAMESPACE
   169 #endif /* mozilla_dom_workerscope_h__ */

mercurial