LCOV - code coverage report
Current view: top level - dom/cache - CacheStorageParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 62 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 11 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             : #include "mozilla/dom/cache/CacheStorageParent.h"
       8             : 
       9             : #include "mozilla/Unused.h"
      10             : #include "mozilla/dom/ContentParent.h"
      11             : #include "mozilla/dom/cache/ActorUtils.h"
      12             : #include "mozilla/dom/cache/CacheOpParent.h"
      13             : #include "mozilla/dom/cache/ManagerId.h"
      14             : #include "mozilla/ipc/PBackgroundParent.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : namespace cache {
      19             : 
      20             : using mozilla::ipc::PBackgroundParent;
      21             : using mozilla::ipc::PrincipalInfo;
      22             : 
      23             : // declared in ActorUtils.h
      24             : PCacheStorageParent*
      25           0 : AllocPCacheStorageParent(PBackgroundParent* aManagingActor,
      26             :                          Namespace aNamespace,
      27             :                          const mozilla::ipc::PrincipalInfo& aPrincipalInfo)
      28             : {
      29           0 :   return new CacheStorageParent(aManagingActor, aNamespace, aPrincipalInfo);
      30             : }
      31             : 
      32             : // declared in ActorUtils.h
      33             : void
      34           0 : DeallocPCacheStorageParent(PCacheStorageParent* aActor)
      35             : {
      36           0 :   delete aActor;
      37           0 : }
      38             : 
      39           0 : CacheStorageParent::CacheStorageParent(PBackgroundParent* aManagingActor,
      40             :                                        Namespace aNamespace,
      41           0 :                                        const PrincipalInfo& aPrincipalInfo)
      42             :   : mNamespace(aNamespace)
      43           0 :   , mVerifiedStatus(NS_OK)
      44             : {
      45           0 :   MOZ_COUNT_CTOR(cache::CacheStorageParent);
      46           0 :   MOZ_DIAGNOSTIC_ASSERT(aManagingActor);
      47             : 
      48             :   // Start the async principal verification process immediately.
      49           0 :   mVerifier = PrincipalVerifier::CreateAndDispatch(this, aManagingActor,
      50           0 :                                                    aPrincipalInfo);
      51           0 :   MOZ_DIAGNOSTIC_ASSERT(mVerifier);
      52           0 : }
      53             : 
      54           0 : CacheStorageParent::~CacheStorageParent()
      55             : {
      56           0 :   MOZ_COUNT_DTOR(cache::CacheStorageParent);
      57           0 :   MOZ_DIAGNOSTIC_ASSERT(!mVerifier);
      58           0 : }
      59             : 
      60             : void
      61           0 : CacheStorageParent::ActorDestroy(ActorDestroyReason aReason)
      62             : {
      63           0 :   if (mVerifier) {
      64           0 :     mVerifier->RemoveListener(this);
      65           0 :     mVerifier = nullptr;
      66             :   }
      67           0 : }
      68             : 
      69             : PCacheOpParent*
      70           0 : CacheStorageParent::AllocPCacheOpParent(const CacheOpArgs& aOpArgs)
      71             : {
      72           0 :   if (aOpArgs.type() != CacheOpArgs::TStorageMatchArgs &&
      73           0 :       aOpArgs.type() != CacheOpArgs::TStorageHasArgs &&
      74           0 :       aOpArgs.type() != CacheOpArgs::TStorageOpenArgs &&
      75           0 :       aOpArgs.type() != CacheOpArgs::TStorageDeleteArgs &&
      76           0 :       aOpArgs.type() != CacheOpArgs::TStorageKeysArgs)
      77             :   {
      78           0 :     MOZ_CRASH("Invalid operation sent to CacheStorage actor!");
      79             :   }
      80             : 
      81           0 :   return new CacheOpParent(Manager(), mNamespace, aOpArgs);
      82             : }
      83             : 
      84             : bool
      85           0 : CacheStorageParent::DeallocPCacheOpParent(PCacheOpParent* aActor)
      86             : {
      87           0 :   delete aActor;
      88           0 :   return true;
      89             : }
      90             : 
      91             : mozilla::ipc::IPCResult
      92           0 : CacheStorageParent::RecvPCacheOpConstructor(PCacheOpParent* aActor,
      93             :                                             const CacheOpArgs& aOpArgs)
      94             : {
      95           0 :   auto actor = static_cast<CacheOpParent*>(aActor);
      96             : 
      97           0 :   if (mVerifier) {
      98           0 :     MOZ_DIAGNOSTIC_ASSERT(!mManagerId);
      99           0 :     actor->WaitForVerification(mVerifier);
     100           0 :     return IPC_OK();
     101             :   }
     102             : 
     103           0 :   if (NS_WARN_IF(NS_FAILED(mVerifiedStatus))) {
     104           0 :     ErrorResult result(mVerifiedStatus);
     105           0 :     Unused << CacheOpParent::Send__delete__(actor, result, void_t());
     106           0 :     result.SuppressException();
     107           0 :     return IPC_OK();
     108             :   }
     109             : 
     110           0 :   MOZ_DIAGNOSTIC_ASSERT(mManagerId);
     111           0 :   actor->Execute(mManagerId);
     112           0 :   return IPC_OK();
     113             : }
     114             : 
     115             : mozilla::ipc::IPCResult
     116           0 : CacheStorageParent::RecvTeardown()
     117             : {
     118           0 :   if (!Send__delete__(this)) {
     119             :     // child process is gone, warn and allow actor to clean up normally
     120           0 :     NS_WARNING("CacheStorage failed to delete actor.");
     121             :   }
     122           0 :   return IPC_OK();
     123             : }
     124             : 
     125             : void
     126           0 : CacheStorageParent::OnPrincipalVerified(nsresult aRv, ManagerId* aManagerId)
     127             : {
     128           0 :   MOZ_DIAGNOSTIC_ASSERT(mVerifier);
     129           0 :   MOZ_DIAGNOSTIC_ASSERT(!mManagerId);
     130           0 :   MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(mVerifiedStatus));
     131             : 
     132           0 :   if (NS_WARN_IF(NS_FAILED(aRv))) {
     133           0 :     mVerifiedStatus = aRv;
     134             :   }
     135             : 
     136           0 :   mManagerId = aManagerId;
     137           0 :   mVerifier->RemoveListener(this);
     138           0 :   mVerifier = nullptr;
     139           0 : }
     140             : 
     141             : } // namespace cache
     142             : } // namespace dom
     143             : } // namespace mozilla

Generated by: LCOV version 1.13