dom/power/WakeLock.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++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     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 file,
     4  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef mozilla_dom_power_WakeLock_h
     7 #define mozilla_dom_power_WakeLock_h
     9 #include "nsCOMPtr.h"
    10 #include "nsIDOMEventListener.h"
    11 #include "nsIObserver.h"
    12 #include "nsString.h"
    13 #include "nsWeakReference.h"
    14 #include "nsWrapperCache.h"
    15 #include "mozilla/ErrorResult.h"
    17 class nsIDOMWindow;
    19 namespace mozilla {
    20 namespace dom {
    22 class ContentParent;
    24 class WakeLock MOZ_FINAL
    25   : public nsIDOMEventListener
    26   , public nsWrapperCache
    27   , public nsIObserver
    28   , public nsSupportsWeakReference
    29 {
    30 public:
    31   NS_DECL_NSIDOMEVENTLISTENER
    32   NS_DECL_NSIOBSERVER
    34   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    35   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WakeLock, nsIDOMEventListener)
    37   // Note: WakeLock lives for the lifetime of the document in order to avoid
    38   // exposing GC behavior to pages. This means that
    39   // |var foo = navigator.requestWakeLock('cpu'); foo = null;|
    40   // doesn't unlock the 'cpu' resource.
    42   WakeLock();
    43   virtual ~WakeLock();
    45   // Initialize this wake lock on behalf of the given window.  Null windows are
    46   // allowed; a lock without an associated window is always considered
    47   // invisible.
    48   nsresult Init(const nsAString &aTopic, nsIDOMWindow* aWindow);
    50   // Initialize this wake lock on behalf of the given process.  If the process
    51   // dies, the lock is released.  A wake lock initialized via this method is
    52   // always considered visible.
    53   nsresult Init(const nsAString &aTopic, ContentParent* aContentParent);
    55   // WebIDL methods
    57   nsISupports* GetParentObject() const;
    59   virtual JSObject*
    60   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    62   void GetTopic(nsAString& aTopic);
    64   void Unlock(ErrorResult& aRv);
    66 private:
    67   void     DoUnlock();
    68   void     DoLock();
    69   void     AttachEventListener();
    70   void     DetachEventListener();
    72   bool      mLocked;
    73   bool      mHidden;
    75   // The ID of the ContentParent on behalf of whom we acquired this lock, or
    76   // CONTENT_PROCESS_UNKNOWN_ID if this lock was acquired on behalf of the
    77   // current process.
    78   uint64_t  mContentParentID;
    79   nsString  mTopic;
    81   // window that this was created for.  Weak reference.
    82   nsWeakPtr mWindow;
    83 };
    85 } // namespace dom
    86 } // namespace mozilla
    88 #endif // mozilla_dom_power_WakeLock_h

mercurial