dom/quota/Client.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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=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/. */
     7 #ifndef mozilla_dom_quota_client_h__
     8 #define mozilla_dom_quota_client_h__
    10 #include "mozilla/dom/quota/QuotaCommon.h"
    12 #include "PersistenceType.h"
    14 class nsIOfflineStorage;
    15 class nsIRunnable;
    17 #define IDB_DIRECTORY_NAME "idb"
    18 #define ASMJSCACHE_DIRECTORY_NAME "asmjs"
    20 BEGIN_QUOTA_NAMESPACE
    22 class OriginOrPatternString;
    23 class UsageInfo;
    25 // An abstract interface for quota manager clients.
    26 // Each storage API must provide an implementation of this interface in order
    27 // to participate in centralized quota and storage handling.
    28 class Client
    29 {
    30 public:
    31   NS_IMETHOD_(MozExternalRefCountType)
    32   AddRef() = 0;
    34   NS_IMETHOD_(MozExternalRefCountType)
    35   Release() = 0;
    37   enum Type {
    38     IDB = 0,
    39     //LS,
    40     //APPCACHE,
    41     ASMJS,
    42     TYPE_MAX
    43   };
    45   virtual Type
    46   GetType() = 0;
    48   static nsresult
    49   TypeToText(Type aType, nsAString& aText)
    50   {
    51     switch (aType) {
    52       case IDB:
    53         aText.AssignLiteral(IDB_DIRECTORY_NAME);
    54         break;
    56       case ASMJS:
    57         aText.AssignLiteral(ASMJSCACHE_DIRECTORY_NAME);
    58         break;
    60       case TYPE_MAX:
    61       default:
    62         NS_NOTREACHED("Bad id value!");
    63         return NS_ERROR_UNEXPECTED;
    64     }
    66     return NS_OK;
    67   }
    69   static nsresult
    70   TypeFromText(const nsAString& aText, Type& aType)
    71   {
    72     if (aText.EqualsLiteral(IDB_DIRECTORY_NAME)) {
    73       aType = IDB;
    74     }
    75     else if (aText.EqualsLiteral(ASMJSCACHE_DIRECTORY_NAME)) {
    76       aType = ASMJS;
    77     }
    78     else {
    79       return NS_ERROR_FAILURE;
    80     }
    82     return NS_OK;
    83   }
    85   // Methods which are called on the IO thred.
    86   virtual nsresult
    87   InitOrigin(PersistenceType aPersistenceType,
    88              const nsACString& aGroup,
    89              const nsACString& aOrigin,
    90              UsageInfo* aUsageInfo) = 0;
    92   virtual nsresult
    93   GetUsageForOrigin(PersistenceType aPersistenceType,
    94                     const nsACString& aGroup,
    95                     const nsACString& aOrigin,
    96                     UsageInfo* aUsageInfo) = 0;
    98   virtual void
    99   OnOriginClearCompleted(PersistenceType aPersistenceType,
   100                          const OriginOrPatternString& aOriginOrPattern) = 0;
   102   virtual void
   103   ReleaseIOThreadObjects() = 0;
   105   // Methods which are called on the main thred.
   106   virtual bool
   107   IsFileServiceUtilized() = 0;
   109   virtual bool
   110   IsTransactionServiceActivated() = 0;
   112   virtual void
   113   WaitForStoragesToComplete(nsTArray<nsIOfflineStorage*>& aStorages,
   114                             nsIRunnable* aCallback) = 0;
   116   virtual void
   117   AbortTransactionsForStorage(nsIOfflineStorage* aStorage) = 0;
   119   virtual bool
   120   HasTransactionsForStorage(nsIOfflineStorage* aStorage) = 0;
   122   virtual void
   123   ShutdownTransactionService() = 0;
   125 protected:
   126   virtual ~Client()
   127   { }
   128 };
   130 END_QUOTA_NAMESPACE
   132 #endif // mozilla_dom_quota_client_h__

mercurial