LCOV - code coverage report
Current view: top level - dom/cache - TypeUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 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
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_cache_TypesUtils_h
       8             : #define mozilla_dom_cache_TypesUtils_h
       9             : 
      10             : #include "mozilla/Attributes.h"
      11             : #include "mozilla/dom/BindingUtils.h"
      12             : #include "mozilla/dom/InternalHeaders.h"
      13             : #include "nsError.h"
      14             : 
      15             : class nsIGlobalObject;
      16             : class nsIAsyncInputStream;
      17             : class nsIInputStream;
      18             : 
      19             : namespace mozilla {
      20             : 
      21             : namespace ipc {
      22             : class PBackgroundChild;
      23             : class AutoIPCStream;
      24             : }
      25             : 
      26             : namespace dom {
      27             : 
      28             : struct CacheQueryOptions;
      29             : class InternalRequest;
      30             : class InternalResponse;
      31             : class OwningRequestOrUSVString;
      32             : class Request;
      33             : class RequestOrUSVString;
      34             : class Response;
      35             : 
      36             : namespace cache {
      37             : 
      38             : class CacheQueryParams;
      39             : class CacheReadStream;
      40             : class CacheReadStreamOrVoid;
      41             : class CacheRequest;
      42             : class CacheResponse;
      43             : class HeadersEntry;
      44             : 
      45           0 : class TypeUtils
      46             : {
      47             : public:
      48             :   enum BodyAction
      49             :   {
      50             :     IgnoreBody,
      51             :     ReadBody
      52             :   };
      53             : 
      54             :   enum SchemeAction
      55             :   {
      56             :     IgnoreInvalidScheme,
      57             :     TypeErrorOnInvalidScheme
      58             :   };
      59             : 
      60           0 :   ~TypeUtils() { }
      61             :   virtual nsIGlobalObject* GetGlobalObject() const = 0;
      62             : #ifdef DEBUG
      63             :   virtual void AssertOwningThread() const = 0;
      64             : #else
      65             :   inline void AssertOwningThread() const { }
      66             : #endif
      67             : 
      68             :   // This is mainly declared to support serializing body streams.  Some
      69             :   // TypeUtils implementations do not expect to be used for this kind of
      70             :   // serialization.  These classes will MOZ_CRASH() if you try to call
      71             :   // GetIPCManager().
      72             :   virtual mozilla::ipc::PBackgroundChild*
      73             :   GetIPCManager() = 0;
      74             : 
      75             :   already_AddRefed<InternalRequest>
      76             :   ToInternalRequest(const RequestOrUSVString& aIn, BodyAction aBodyAction,
      77             :                     ErrorResult& aRv);
      78             : 
      79             :   already_AddRefed<InternalRequest>
      80             :   ToInternalRequest(const OwningRequestOrUSVString& aIn, BodyAction aBodyAction,
      81             :                     ErrorResult& aRv);
      82             : 
      83             :   void
      84             :   ToCacheRequest(CacheRequest& aOut, InternalRequest* aIn,
      85             :                  BodyAction aBodyAction, SchemeAction aSchemeAction,
      86             :                  nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList,
      87             :                  ErrorResult& aRv);
      88             : 
      89             :   void
      90             :   ToCacheResponseWithoutBody(CacheResponse& aOut, InternalResponse& aIn,
      91             :                              ErrorResult& aRv);
      92             : 
      93             :   void
      94             :   ToCacheResponse(CacheResponse& aOut, Response& aIn,
      95             :                   nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList,
      96             :                   ErrorResult& aRv);
      97             : 
      98             :   void
      99             :   ToCacheQueryParams(CacheQueryParams& aOut, const CacheQueryOptions& aIn);
     100             : 
     101             :   already_AddRefed<Response>
     102             :   ToResponse(const CacheResponse& aIn);
     103             : 
     104             :   already_AddRefed<InternalRequest>
     105             :   ToInternalRequest(const CacheRequest& aIn);
     106             : 
     107             :   already_AddRefed<Request>
     108             :   ToRequest(const CacheRequest& aIn);
     109             : 
     110             :   // static methods
     111             :   static already_AddRefed<InternalHeaders>
     112             :   ToInternalHeaders(const nsTArray<HeadersEntry>& aHeadersEntryList,
     113             :                     HeadersGuardEnum aGuard = HeadersGuardEnum::None);
     114             : 
     115             :   // Utility method for parsing a URL and doing associated operations.  A mix
     116             :   // of things are done in this one method to avoid duplicated parsing:
     117             :   //
     118             :   //  1) The aUrl argument is modified to strip the fragment
     119             :   //  2) If aSchemaValidOut is set, then a boolean value is set indicating
     120             :   //     if the aUrl's scheme is valid or not for storing in the cache.
     121             :   //  3) If aUrlWithoutQueryOut is set, then a url string is provided without
     122             :   //     the search section.
     123             :   //  4) If aUrlQueryOut is set then its populated with the search section
     124             :   //     of the URL.  Note, this parameter must be set if aUrlWithoutQueryOut
     125             :   //     is set.  They must either both be nullptr or set to valid string
     126             :   //     pointers.
     127             :   //
     128             :   // Any errors are thrown on ErrorResult.
     129             :   static void
     130             :   ProcessURL(nsACString& aUrl, bool* aSchemeValidOut,
     131             :              nsACString* aUrlWithoutQueryOut, nsACString* aUrlQueryOut,
     132             :              ErrorResult& aRv);
     133             : 
     134             : private:
     135             :   void
     136             :   CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction,
     137             :                       ErrorResult& aRv);
     138             : 
     139             :   already_AddRefed<InternalRequest>
     140             :   ToInternalRequest(const nsAString& aIn, ErrorResult& aRv);
     141             : 
     142             :   void
     143             :   SerializeCacheStream(nsIInputStream* aStream, CacheReadStreamOrVoid* aStreamOut,
     144             :                        nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList,
     145             :                        ErrorResult& aRv);
     146             : 
     147             :   void
     148             :   SerializeSendStream(nsIInputStream* aStream, CacheReadStream& aReadStreamOut,
     149             :                       ErrorResult& aRv);
     150             : };
     151             : 
     152             : } // namespace cache
     153             : } // namespace dom
     154             : } // namespace mozilla
     155             : 
     156             : #endif // mozilla_dom_cache_TypesUtils_h

Generated by: LCOV version 1.13