LCOV - code coverage report
Current view: top level - dom/quota - Client.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 29 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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_quota_client_h__
       8             : #define mozilla_dom_quota_client_h__
       9             : 
      10             : #include "mozilla/dom/quota/QuotaCommon.h"
      11             : 
      12             : #include "mozilla/dom/ipc/IdType.h"
      13             : 
      14             : #include "PersistenceType.h"
      15             : 
      16             : class nsIFile;
      17             : class nsIRunnable;
      18             : 
      19             : #define IDB_DIRECTORY_NAME "idb"
      20             : #define ASMJSCACHE_DIRECTORY_NAME "asmjs"
      21             : #define DOMCACHE_DIRECTORY_NAME "cache"
      22             : 
      23             : BEGIN_QUOTA_NAMESPACE
      24             : 
      25             : class QuotaManager;
      26             : class UsageInfo;
      27             : 
      28             : // An abstract interface for quota manager clients.
      29             : // Each storage API must provide an implementation of this interface in order
      30             : // to participate in centralized quota and storage handling.
      31           0 : class Client
      32             : {
      33             : public:
      34             :   typedef mozilla::Atomic<bool> AtomicBool;
      35             : 
      36             :   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
      37             : 
      38             :   enum Type {
      39             :     IDB = 0,
      40             :     //LS,
      41             :     //APPCACHE,
      42             :     ASMJS,
      43             :     DOMCACHE,
      44             :     TYPE_MAX
      45             :   };
      46             : 
      47             :   virtual Type
      48             :   GetType() = 0;
      49             : 
      50             :   static nsresult
      51           0 :   TypeToText(Type aType, nsAString& aText)
      52             :   {
      53           0 :     switch (aType) {
      54             :       case IDB:
      55           0 :         aText.AssignLiteral(IDB_DIRECTORY_NAME);
      56           0 :         break;
      57             : 
      58             :       case ASMJS:
      59           0 :         aText.AssignLiteral(ASMJSCACHE_DIRECTORY_NAME);
      60           0 :         break;
      61             : 
      62             :       case DOMCACHE:
      63           0 :         aText.AssignLiteral(DOMCACHE_DIRECTORY_NAME);
      64           0 :         break;
      65             : 
      66             :       case TYPE_MAX:
      67             :       default:
      68           0 :         NS_NOTREACHED("Bad id value!");
      69           0 :         return NS_ERROR_UNEXPECTED;
      70             :     }
      71             : 
      72           0 :     return NS_OK;
      73             :   }
      74             : 
      75             :   static nsresult
      76           0 :   TypeFromText(const nsAString& aText, Type& aType)
      77             :   {
      78           0 :     if (aText.EqualsLiteral(IDB_DIRECTORY_NAME)) {
      79           0 :       aType = IDB;
      80             :     }
      81           0 :     else if (aText.EqualsLiteral(ASMJSCACHE_DIRECTORY_NAME)) {
      82           0 :       aType = ASMJS;
      83             :     }
      84           0 :     else if (aText.EqualsLiteral(DOMCACHE_DIRECTORY_NAME)) {
      85           0 :       aType = DOMCACHE;
      86             :     }
      87             :     else {
      88           0 :       return NS_ERROR_FAILURE;
      89             :     }
      90             : 
      91           0 :     return NS_OK;
      92             :   }
      93             : 
      94             :   // Methods which are called on the IO thred.
      95             :   virtual nsresult
      96           0 :   UpgradeStorageFrom1_0To2_0(nsIFile* aDirectory)
      97             :   {
      98           0 :     return NS_OK;
      99             :   }
     100             : 
     101             :   virtual nsresult
     102             :   InitOrigin(PersistenceType aPersistenceType,
     103             :              const nsACString& aGroup,
     104             :              const nsACString& aOrigin,
     105             :              const AtomicBool& aCanceled,
     106             :              UsageInfo* aUsageInfo) = 0;
     107             : 
     108             :   virtual nsresult
     109             :   GetUsageForOrigin(PersistenceType aPersistenceType,
     110             :                     const nsACString& aGroup,
     111             :                     const nsACString& aOrigin,
     112             :                     const AtomicBool& aCanceled,
     113             :                     UsageInfo* aUsageInfo) = 0;
     114             : 
     115             :   virtual void
     116             :   OnOriginClearCompleted(PersistenceType aPersistenceType,
     117             :                          const nsACString& aOrigin) = 0;
     118             : 
     119             :   virtual void
     120             :   ReleaseIOThreadObjects() = 0;
     121             : 
     122             :   // Methods which are called on the background thred.
     123             :   virtual void
     124             :   AbortOperations(const nsACString& aOrigin) = 0;
     125             : 
     126             :   virtual void
     127             :   AbortOperationsForProcess(ContentParentId aContentParentId) = 0;
     128             : 
     129             :   virtual void
     130             :   StartIdleMaintenance() = 0;
     131             : 
     132             :   virtual void
     133             :   StopIdleMaintenance() = 0;
     134             : 
     135             :   virtual void
     136             :   ShutdownWorkThreads() = 0;
     137             : 
     138             :   // Methods which are called on the main thread.
     139             :   virtual void
     140           0 :   DidInitialize(QuotaManager* aQuotaManager)
     141           0 :   { }
     142             : 
     143             :   virtual void
     144           0 :   WillShutdown()
     145           0 :   { }
     146             : 
     147             : protected:
     148           0 :   virtual ~Client()
     149           0 :   { }
     150             : };
     151             : 
     152             : END_QUOTA_NAMESPACE
     153             : 
     154             : #endif // mozilla_dom_quota_client_h__

Generated by: LCOV version 1.13