Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/net/NrIceStunAddrMessageUtils.h
Line
Count
Source (jump to first uncovered line)
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
  static void Write(Message* aMsg, const mozilla::NrIceStunAddr &aParam)
25
0
  {
26
0
#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
0
#endif
33
0
  }
34
35
  static bool Read(const Message* aMsg,
36
                   PickleIterator* aIter,
37
                   mozilla::NrIceStunAddr* aResult)
38
0
  {
39
0
#ifdef MOZ_WEBRTC
40
0
    const size_t bufSize = aResult->SerializationBufferSize();
41
0
    char* buffer = new char[bufSize];
42
0
    bool result =
43
0
      aMsg->ReadBytesInto(aIter, (void*)buffer, bufSize);
44
0
45
0
    if (result) {
46
0
      result = result &&
47
0
               (NS_OK == aResult->Deserialize(buffer, bufSize));
48
0
    }
49
0
    delete[] buffer;
50
0
51
0
    return result;
52
#else
53
    return false;
54
#endif
55
  }
56
};
57
58
} // namespace IPC
59
60
#endif // mozilla_net_NrIceStunAddrMessageUtils_h