LCOV - code coverage report
Current view: top level - dom/messagechannel - SharedMessagePortMessage.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 1 42 2.4 %
Date: 2017-07-14 16:53:18 Functions: 2 6 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       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             : #include "SharedMessagePortMessage.h"
       7             : #include "MessagePort.h"
       8             : #include "MessagePortChild.h"
       9             : #include "MessagePortParent.h"
      10             : #include "mozilla/dom/File.h"
      11             : #include "mozilla/dom/PMessagePort.h"
      12             : #include "mozilla/ipc/BackgroundChild.h"
      13             : #include "mozilla/ipc/BackgroundParent.h"
      14             : 
      15             : namespace mozilla {
      16             : 
      17             : using namespace ipc;
      18             : 
      19             : namespace dom {
      20             : 
      21             : /* static */ void
      22           0 : SharedMessagePortMessage::FromSharedToMessagesChild(
      23             :                       MessagePortChild* aActor,
      24             :                       const nsTArray<RefPtr<SharedMessagePortMessage>>& aData,
      25             :                       nsTArray<ClonedMessageData>& aArray)
      26             : {
      27           0 :   MOZ_ASSERT(aActor);
      28           0 :   MOZ_ASSERT(aArray.IsEmpty());
      29           0 :   aArray.SetCapacity(aData.Length());
      30             : 
      31           0 :   PBackgroundChild* backgroundManager = aActor->Manager();
      32           0 :   MOZ_ASSERT(backgroundManager);
      33             : 
      34           0 :   for (auto& data : aData) {
      35           0 :     ClonedMessageData* message = aArray.AppendElement();
      36           0 :     data->BuildClonedMessageDataForBackgroundChild(backgroundManager, *message);
      37             :   }
      38           0 : }
      39             : 
      40             : /* static */ bool
      41           0 : SharedMessagePortMessage::FromMessagesToSharedChild(
      42             :                       nsTArray<ClonedMessageData>& aArray,
      43             :                       FallibleTArray<RefPtr<SharedMessagePortMessage>>& aData)
      44             : {
      45           0 :   MOZ_ASSERT(aData.IsEmpty());
      46             : 
      47           0 :   if (NS_WARN_IF(!aData.SetCapacity(aArray.Length(), mozilla::fallible))) {
      48           0 :     return false;
      49             :   }
      50             : 
      51           0 :   for (auto& message : aArray) {
      52           0 :     RefPtr<SharedMessagePortMessage> data = new SharedMessagePortMessage();
      53           0 :     data->StealFromClonedMessageDataForBackgroundChild(message);
      54             : 
      55           0 :     if (!aData.AppendElement(data, mozilla::fallible)) {
      56           0 :       return false;
      57             :     }
      58             :   }
      59             : 
      60           0 :   return true;
      61             : }
      62             : 
      63             : /* static */ bool
      64           0 : SharedMessagePortMessage::FromSharedToMessagesParent(
      65             :                       MessagePortParent* aActor,
      66             :                       const nsTArray<RefPtr<SharedMessagePortMessage>>& aData,
      67             :                       FallibleTArray<ClonedMessageData>& aArray)
      68             : {
      69           0 :   MOZ_ASSERT(aArray.IsEmpty());
      70             : 
      71           0 :   if (NS_WARN_IF(!aArray.SetCapacity(aData.Length(), mozilla::fallible))) {
      72           0 :     return false;
      73             :   }
      74             : 
      75           0 :   PBackgroundParent* backgroundManager = aActor->Manager();
      76           0 :   MOZ_ASSERT(backgroundManager);
      77             : 
      78           0 :   for (auto& data : aData) {
      79           0 :     ClonedMessageData* message = aArray.AppendElement(mozilla::fallible);
      80           0 :     data->BuildClonedMessageDataForBackgroundParent(backgroundManager,
      81           0 :                                                     *message);
      82             :   }
      83             : 
      84           0 :   return true;
      85             : }
      86             : 
      87             : /* static */ bool
      88           0 : SharedMessagePortMessage::FromMessagesToSharedParent(
      89             :                       nsTArray<ClonedMessageData>& aArray,
      90             :                       FallibleTArray<RefPtr<SharedMessagePortMessage>>& aData)
      91             : {
      92           0 :   MOZ_ASSERT(aData.IsEmpty());
      93             : 
      94           0 :   if (NS_WARN_IF(!aData.SetCapacity(aArray.Length(), mozilla::fallible))) {
      95           0 :     return false;
      96             :   }
      97             : 
      98           0 :   for (auto& message : aArray) {
      99           0 :     RefPtr<SharedMessagePortMessage> data = new SharedMessagePortMessage();
     100           0 :     data->StealFromClonedMessageDataForBackgroundParent(message);
     101             : 
     102           0 :     if (!aData.AppendElement(data, mozilla::fallible)) {
     103           0 :       return false;
     104             :     }
     105             :   }
     106             : 
     107           0 :   return true;
     108             : }
     109             : 
     110             : } // namespace dom
     111           9 : } // namespace mozilla

Generated by: LCOV version 1.13