LCOV - code coverage report
Current view: top level - dom/webbrowserpersist - WebBrowserPersistDocumentChild.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 63 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  *
       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             : #include "WebBrowserPersistDocumentChild.h"
       8             : 
       9             : #include "mozilla/dom/ContentChild.h"
      10             : #include "mozilla/ipc/IPCStreamUtils.h"
      11             : #include "nsIDocument.h"
      12             : #include "nsIInputStream.h"
      13             : #include "WebBrowserPersistLocalDocument.h"
      14             : #include "WebBrowserPersistResourcesChild.h"
      15             : #include "WebBrowserPersistSerializeChild.h"
      16             : 
      17             : namespace mozilla {
      18             : 
      19           0 : WebBrowserPersistDocumentChild::WebBrowserPersistDocumentChild()
      20             : {
      21           0 : }
      22             : 
      23             : WebBrowserPersistDocumentChild::~WebBrowserPersistDocumentChild() = default;
      24             : 
      25             : void
      26           0 : WebBrowserPersistDocumentChild::Start(nsIDocument* aDocument)
      27             : {
      28           0 :     RefPtr<WebBrowserPersistLocalDocument> doc;
      29           0 :     if (aDocument) {
      30           0 :         doc = new WebBrowserPersistLocalDocument(aDocument);
      31             :     }
      32           0 :     Start(doc);
      33           0 : }
      34             : 
      35             : void
      36           0 : WebBrowserPersistDocumentChild::Start(nsIWebBrowserPersistDocument* aDocument)
      37             : {
      38           0 :     MOZ_ASSERT(!mDocument);
      39           0 :     if (!aDocument) {
      40           0 :         SendInitFailure(NS_ERROR_FAILURE);
      41           0 :         return;
      42             :     }
      43             : 
      44           0 :     WebBrowserPersistDocumentAttrs attrs;
      45           0 :     nsCOMPtr<nsIInputStream> postDataStream;
      46             : #define ENSURE(e) do {           \
      47             :         nsresult rv = (e);       \
      48             :         if (NS_FAILED(rv)) {     \
      49             :             SendInitFailure(rv); \
      50             :             return;              \
      51             :         }                        \
      52             :     } while(0)
      53           0 :     ENSURE(aDocument->GetIsPrivate(&(attrs.isPrivate())));
      54           0 :     ENSURE(aDocument->GetDocumentURI(attrs.documentURI()));
      55           0 :     ENSURE(aDocument->GetBaseURI(attrs.baseURI()));
      56           0 :     ENSURE(aDocument->GetContentType(attrs.contentType()));
      57           0 :     ENSURE(aDocument->GetCharacterSet(attrs.characterSet()));
      58           0 :     ENSURE(aDocument->GetTitle(attrs.title()));
      59           0 :     ENSURE(aDocument->GetReferrer(attrs.referrer()));
      60           0 :     ENSURE(aDocument->GetContentDisposition(attrs.contentDisposition()));
      61           0 :     ENSURE(aDocument->GetCacheKey(&(attrs.cacheKey())));
      62           0 :     ENSURE(aDocument->GetPersistFlags(&(attrs.persistFlags())));
      63           0 :     ENSURE(aDocument->GetPostData(getter_AddRefs(postDataStream)));
      64             : #undef ENSURE
      65             : 
      66           0 :     mozilla::ipc::AutoIPCStream autoStream;
      67           0 :     autoStream.Serialize(postDataStream,
      68           0 :                          static_cast<mozilla::dom::ContentChild*>(Manager()));
      69             : 
      70           0 :     mDocument = aDocument;
      71           0 :     SendAttributes(attrs, autoStream.TakeOptionalValue());
      72             : }
      73             : 
      74             : mozilla::ipc::IPCResult
      75           0 : WebBrowserPersistDocumentChild::RecvSetPersistFlags(const uint32_t& aNewFlags)
      76             : {
      77           0 :     mDocument->SetPersistFlags(aNewFlags);
      78           0 :     return IPC_OK();
      79             : }
      80             : 
      81             : PWebBrowserPersistResourcesChild*
      82           0 : WebBrowserPersistDocumentChild::AllocPWebBrowserPersistResourcesChild()
      83             : {
      84           0 :     auto* actor = new WebBrowserPersistResourcesChild();
      85           0 :     NS_ADDREF(actor);
      86           0 :     return actor;
      87             : }
      88             : 
      89             : mozilla::ipc::IPCResult
      90           0 : WebBrowserPersistDocumentChild::RecvPWebBrowserPersistResourcesConstructor(PWebBrowserPersistResourcesChild* aActor)
      91             : {
      92             :     RefPtr<WebBrowserPersistResourcesChild> visitor =
      93           0 :         static_cast<WebBrowserPersistResourcesChild*>(aActor);
      94           0 :     nsresult rv = mDocument->ReadResources(visitor);
      95           0 :     if (NS_FAILED(rv)) {
      96             :         // This is a sync failure on the child side but an async
      97             :         // failure on the parent side -- it already got NS_OK from
      98             :         // ReadResources, so the error has to be reported via the
      99             :         // visitor instead.
     100           0 :         visitor->EndVisit(mDocument, rv);
     101             :     }
     102           0 :     return IPC_OK();
     103             : }
     104             : 
     105             : bool
     106           0 : WebBrowserPersistDocumentChild::DeallocPWebBrowserPersistResourcesChild(PWebBrowserPersistResourcesChild* aActor)
     107             : {
     108             :     auto* castActor =
     109           0 :         static_cast<WebBrowserPersistResourcesChild*>(aActor);
     110           0 :     NS_RELEASE(castActor);
     111           0 :     return true;
     112             : }
     113             : 
     114             : PWebBrowserPersistSerializeChild*
     115           0 : WebBrowserPersistDocumentChild::AllocPWebBrowserPersistSerializeChild(
     116             :             const WebBrowserPersistURIMap& aMap,
     117             :             const nsCString& aRequestedContentType,
     118             :             const uint32_t& aEncoderFlags,
     119             :             const uint32_t& aWrapColumn)
     120             : {
     121           0 :     auto* actor = new WebBrowserPersistSerializeChild(aMap);
     122           0 :     NS_ADDREF(actor);
     123           0 :     return actor;
     124             : }
     125             : 
     126             : mozilla::ipc::IPCResult
     127           0 : WebBrowserPersistDocumentChild::RecvPWebBrowserPersistSerializeConstructor(
     128             :             PWebBrowserPersistSerializeChild* aActor,
     129             :             const WebBrowserPersistURIMap& aMap,
     130             :             const nsCString& aRequestedContentType,
     131             :             const uint32_t& aEncoderFlags,
     132             :             const uint32_t& aWrapColumn)
     133             : {
     134             :     auto* castActor =
     135           0 :         static_cast<WebBrowserPersistSerializeChild*>(aActor);
     136             :     // This actor performs the roles of: completion, URI map, and output stream.
     137           0 :     nsresult rv = mDocument->WriteContent(castActor,
     138             :                                           castActor,
     139             :                                           aRequestedContentType,
     140             :                                           aEncoderFlags,
     141             :                                           aWrapColumn,
     142           0 :                                           castActor);
     143           0 :     if (NS_FAILED(rv)) {
     144           0 :         castActor->OnFinish(mDocument, castActor, aRequestedContentType, rv);
     145             :     }
     146           0 :     return IPC_OK();
     147             : }
     148             : 
     149             : bool
     150           0 : WebBrowserPersistDocumentChild::DeallocPWebBrowserPersistSerializeChild(PWebBrowserPersistSerializeChild* aActor)
     151             : {
     152             :     auto* castActor =
     153           0 :         static_cast<WebBrowserPersistSerializeChild*>(aActor);
     154           0 :     NS_RELEASE(castActor);
     155           0 :     return true;
     156             : }
     157             : 
     158             : } // namespace mozilla

Generated by: LCOV version 1.13