LCOV - code coverage report
Current view: top level - netwerk/protocol/about - nsAboutCache.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 6 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 38 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       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/. */
       5             : 
       6             : #ifndef nsAboutCache_h__
       7             : #define nsAboutCache_h__
       8             : 
       9             : #include "nsIAboutModule.h"
      10             : #include "nsICacheStorageVisitor.h"
      11             : #include "nsICacheStorage.h"
      12             : 
      13             : #include "nsString.h"
      14             : #include "nsIOutputStream.h"
      15             : #include "nsILoadContextInfo.h"
      16             : 
      17             : #include "nsCOMPtr.h"
      18             : #include "nsTArray.h"
      19             : 
      20             : #define NS_FORWARD_SAFE_NSICHANNEL_SUBSET(_to) \
      21             :   NS_IMETHOD GetOriginalURI(nsIURI * *aOriginalURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOriginalURI(aOriginalURI); } \
      22             :   NS_IMETHOD SetOriginalURI(nsIURI *aOriginalURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOriginalURI(aOriginalURI); } \
      23             :   NS_IMETHOD GetURI(nsIURI * *aURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetURI(aURI); } \
      24             :   NS_IMETHOD GetOwner(nsISupports * *aOwner) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOwner(aOwner); } \
      25             :   NS_IMETHOD SetOwner(nsISupports *aOwner) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOwner(aOwner); } \
      26             :   NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetNotificationCallbacks(aNotificationCallbacks); } \
      27             :   NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor *aNotificationCallbacks) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetNotificationCallbacks(aNotificationCallbacks); } \
      28             :   NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSecurityInfo(aSecurityInfo); } \
      29             :   NS_IMETHOD GetContentType(nsACString & aContentType) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentType(aContentType); } \
      30             :   NS_IMETHOD SetContentType(const nsACString & aContentType) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentType(aContentType); } \
      31             :   NS_IMETHOD GetContentCharset(nsACString & aContentCharset) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentCharset(aContentCharset); } \
      32             :   NS_IMETHOD SetContentCharset(const nsACString & aContentCharset) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentCharset(aContentCharset); } \
      33             :   NS_IMETHOD GetContentLength(int64_t *aContentLength) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentLength(aContentLength); } \
      34             :   NS_IMETHOD SetContentLength(int64_t aContentLength) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentLength(aContentLength); } \
      35             :   NS_IMETHOD GetContentDisposition(uint32_t *aContentDisposition) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentDisposition(aContentDisposition); } \
      36             :   NS_IMETHOD SetContentDisposition(uint32_t aContentDisposition) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentDisposition(aContentDisposition); } \
      37             :   NS_IMETHOD GetContentDispositionFilename(nsAString & aContentDispositionFilename) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentDispositionFilename(aContentDispositionFilename); } \
      38             :   NS_IMETHOD SetContentDispositionFilename(const nsAString & aContentDispositionFilename) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentDispositionFilename(aContentDispositionFilename); } \
      39             :   NS_IMETHOD GetContentDispositionHeader(nsACString & aContentDispositionHeader) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentDispositionHeader(aContentDispositionHeader); } \
      40             :   NS_IMETHOD GetLoadInfo(nsILoadInfo * *aLoadInfo) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetLoadInfo(aLoadInfo); } \
      41             :   NS_IMETHOD SetLoadInfo(nsILoadInfo *aLoadInfo) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetLoadInfo(aLoadInfo); } \
      42             :   NS_IMETHOD GetIsDocument(bool *aIsDocument) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsDocument(aIsDocument); }; \
      43             : 
      44             : class nsAboutCache final : public nsIAboutModule
      45             : {
      46             : public:
      47             :     NS_DECL_ISUPPORTS
      48             :     NS_DECL_NSIABOUTMODULE
      49             : 
      50           0 :     nsAboutCache() {}
      51             : 
      52             :     static MOZ_MUST_USE nsresult
      53             :     Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
      54             : 
      55             :     static MOZ_MUST_USE nsresult
      56             :     GetStorage(nsACString const & storageName, nsILoadContextInfo* loadInfo,
      57             :                nsICacheStorage **storage);
      58             : 
      59             : protected:
      60           0 :     virtual ~nsAboutCache() {}
      61             : 
      62           0 :     class Channel final : public nsIChannel
      63             :                         , public nsICacheStorageVisitor
      64             :     {
      65             :         NS_DECL_ISUPPORTS
      66             :         NS_DECL_NSICACHESTORAGEVISITOR
      67           0 :         NS_FORWARD_SAFE_NSIREQUEST(mChannel)
      68           0 :         NS_FORWARD_SAFE_NSICHANNEL_SUBSET(mChannel)
      69             :         NS_IMETHOD AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) override;
      70             :         NS_IMETHOD AsyncOpen2(nsIStreamListener *aListener) override;
      71             :         NS_IMETHOD Open(nsIInputStream * *_retval) override;
      72             :         NS_IMETHOD Open2(nsIInputStream * *_retval) override;
      73             : 
      74             :     private:
      75           0 :         virtual ~Channel() {}
      76             : 
      77             :     public:
      78             :         MOZ_MUST_USE nsresult Init(nsIURI* aURI, nsILoadInfo* aLoadInfo);
      79             :         MOZ_MUST_USE nsresult ParseURI(nsIURI * uri, nsACString & storage);
      80             : 
      81             :         // Finds a next storage we wish to visit (we use this method
      82             :         // even there is a specified storage name, which is the only
      83             :         // one in the list then.)  Posts FireVisitStorage() when found.
      84             :         MOZ_MUST_USE nsresult VisitNextStorage();
      85             :         // Helper method that calls VisitStorage() for the current storage.
      86             :         // When it fails, OnCacheEntryVisitCompleted is simulated to close
      87             :         // the output stream and thus the about:cache channel.
      88             :         void FireVisitStorage();
      89             :         // Kiks the visit cycle for the given storage, names can be:
      90             :         // "disk", "memory", "appcache"
      91             :         // Note: any newly added storage type has to be manually handled here.
      92             :         MOZ_MUST_USE nsresult VisitStorage(nsACString const & storageName);
      93             : 
      94             :         // Writes content of mBuffer to mStream and truncates
      95             :         // the buffer.  It may fail when the input stream is closed by canceling
      96             :         // the input stream channel.  It can be used to stop the cache iteration
      97             :         // process.
      98             :         MOZ_MUST_USE nsresult FlushBuffer();
      99             : 
     100             :         // Whether we are showing overview status of all available
     101             :         // storages.
     102             :         bool mOverview;
     103             : 
     104             :         // Flag initially false, that indicates the entries header has
     105             :         // been added to the output HTML.
     106             :         bool mEntriesHeaderAdded;
     107             : 
     108             :         // Cancelation flag
     109             :         bool mCancel;
     110             : 
     111             :         // The context we are working with.
     112             :         nsCOMPtr<nsILoadContextInfo> mLoadInfo;
     113             :         nsCString mContextString;
     114             : 
     115             :         // The list of all storage names we want to visit
     116             :         nsTArray<nsCString> mStorageList;
     117             :         nsCString mStorageName;
     118             :         nsCOMPtr<nsICacheStorage> mStorage;
     119             : 
     120             :         // Output data buffering and streaming output
     121             :         nsCString mBuffer;
     122             :         nsCOMPtr<nsIOutputStream> mStream;
     123             : 
     124             :         // The input stream channel, the one that actually does the job
     125             :         nsCOMPtr<nsIChannel> mChannel;
     126             :     };
     127             : };
     128             : 
     129             : #define NS_ABOUT_CACHE_MODULE_CID                    \
     130             : { /* 9158c470-86e4-11d4-9be2-00e09872a416 */         \
     131             :     0x9158c470,                                      \
     132             :     0x86e4,                                          \
     133             :     0x11d4,                                          \
     134             :     {0x9b, 0xe2, 0x00, 0xe0, 0x98, 0x72, 0xa4, 0x16} \
     135             : }
     136             : 
     137             : #endif // nsAboutCache_h__

Generated by: LCOV version 1.13