LCOV - code coverage report
Current view: top level - dom/workers - ServiceWorkerUpdaterChild.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 29 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 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             : #include "ServiceWorkerUpdaterChild.h"
       8             : #include "nsThreadUtils.h"
       9             : 
      10             : namespace mozilla {
      11             : namespace dom {
      12             : namespace workers {
      13             : 
      14           0 : ServiceWorkerUpdaterChild::ServiceWorkerUpdaterChild(GenericPromise* aPromise,
      15             :                                                      CancelableRunnable* aSuccessRunnable,
      16           0 :                                                      CancelableRunnable* aFailureRunnable)
      17             :   : mSuccessRunnable(aSuccessRunnable)
      18           0 :   , mFailureRunnable(aFailureRunnable)
      19             : {
      20             :   // TODO: remove the main thread restriction after fixing bug 1364821.
      21           0 :   MOZ_ASSERT(NS_IsMainThread());
      22             : 
      23           0 :   MOZ_ASSERT(aPromise);
      24           0 :   MOZ_ASSERT(aSuccessRunnable);
      25           0 :   MOZ_ASSERT(aFailureRunnable);
      26             : 
      27           0 :   aPromise->Then(GetMainThreadSerialEventTarget(), __func__,
      28           0 :     [this]() {
      29           0 :       mPromiseHolder.Complete();
      30           0 :       Unused << Send__delete__(this);
      31           0 :   }).Track(mPromiseHolder);
      32           0 : }
      33             : 
      34             : mozilla::ipc::IPCResult
      35           0 : ServiceWorkerUpdaterChild::RecvProceed(const bool& aAllowed)
      36             : {
      37             :   // If we have a callback, it will resolve the promise.
      38             : 
      39           0 :   if (aAllowed) {
      40           0 :     mSuccessRunnable->Run();
      41           0 :     mFailureRunnable->Cancel();
      42             :   } else {
      43           0 :     mFailureRunnable->Run();
      44           0 :     mSuccessRunnable->Cancel();
      45             :   }
      46             : 
      47           0 :   mSuccessRunnable = nullptr;
      48           0 :   mFailureRunnable = nullptr;
      49             : 
      50           0 :   return IPC_OK();
      51             : }
      52             : 
      53             : void
      54           0 : ServiceWorkerUpdaterChild::ActorDestroy(ActorDestroyReason aWhy)
      55             : {
      56           0 :   if (mSuccessRunnable) {
      57           0 :     mSuccessRunnable->Cancel();
      58             :   }
      59             : 
      60           0 :   if (mFailureRunnable) {
      61           0 :     mFailureRunnable->Cancel();
      62             :   }
      63             : 
      64           0 :   mPromiseHolder.DisconnectIfExists();
      65           0 : }
      66             : 
      67             : } // namespace workers
      68             : } // namespace dom
      69             : } // namespace mozilla

Generated by: LCOV version 1.13