LCOV - code coverage report
Current view: top level - media/mtransport/ipc - NrIceStunAddrMessageUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 16 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       3             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #ifndef mozilla_net_NrIceStunAddrMessageUtils_h
       6             : #define mozilla_net_NrIceStunAddrMessageUtils_h
       7             : 
       8             : // forward declare NrIceStunAddr for --disable-webrtc builds where
       9             : // the header will not be available.
      10             : namespace mozilla {
      11             :   class NrIceStunAddr;
      12             : } // namespace mozilla
      13             : 
      14             : #include "ipc/IPCMessageUtils.h"
      15             : #ifdef MOZ_WEBRTC
      16             : #include "mtransport/nricestunaddr.h"
      17             : #endif
      18             : 
      19             : namespace IPC {
      20             : 
      21             : template<>
      22             : struct ParamTraits<mozilla::NrIceStunAddr>
      23             : {
      24           0 :   static void Write(Message* aMsg, const mozilla::NrIceStunAddr &aParam)
      25             :   {
      26             : #ifdef MOZ_WEBRTC
      27           0 :     const size_t bufSize = aParam.SerializationBufferSize();
      28           0 :     char* buffer = new char[bufSize];
      29           0 :     aParam.Serialize(buffer, bufSize);
      30           0 :     aMsg->WriteBytes((void*)buffer, bufSize);
      31           0 :     delete[] buffer;
      32             : #endif
      33           0 :   }
      34             : 
      35           0 :   static bool Read(const Message* aMsg,
      36             :                    PickleIterator* aIter,
      37             :                    mozilla::NrIceStunAddr* aResult)
      38             :   {
      39             : #ifdef MOZ_WEBRTC
      40           0 :     const size_t bufSize = aResult->SerializationBufferSize();
      41           0 :     char* buffer = new char[bufSize];
      42             :     bool result =
      43           0 :       aMsg->ReadBytesInto(aIter, (void*)buffer, bufSize);
      44             : 
      45           0 :     if (result) {
      46           0 :       result = result &&
      47           0 :                (NS_OK == aResult->Deserialize(buffer, bufSize));
      48             :     }
      49           0 :     delete[] buffer;
      50             : 
      51           0 :     return result;
      52             : #else
      53             :     return false;
      54             : #endif
      55             :   }
      56             : };
      57             : 
      58             : } // namespace IPC
      59             : 
      60             : #endif // mozilla_net_NrIceStunAddrMessageUtils_h

Generated by: LCOV version 1.13