Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/protocol/websocket/WebSocketFrame.h
Line
Count
Source (jump to first uncovered line)
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
#ifndef mozilla_net_WebSocketFrame_h
8
#define mozilla_net_WebSocketFrame_h
9
10
#include "nsAutoPtr.h"
11
#include "nsIWebSocketEventService.h"
12
#include "nsString.h"
13
14
namespace IPC {
15
class Message;
16
}
17
18
namespace mozilla {
19
namespace net {
20
21
class WebSocketFrameData final
22
{
23
public:
24
  WebSocketFrameData();
25
26
  explicit WebSocketFrameData(const WebSocketFrameData& aData);
27
28
  WebSocketFrameData(DOMHighResTimeStamp aTimeStamp, bool aFinBit,
29
                     bool aRsvBit1, bool aRsvBit2, bool aRsvBit3,
30
                     uint8_t aOpCode, bool aMaskBit, uint32_t aMask,
31
                     const nsCString& aPayload);
32
33
  ~WebSocketFrameData();
34
35
  // For IPC serialization
36
  void WriteIPCParams(IPC::Message* aMessage) const;
37
  bool ReadIPCParams(const IPC::Message* aMessage, PickleIterator* aIter);
38
39
  DOMHighResTimeStamp mTimeStamp;
40
41
  bool mFinBit : 1;
42
  bool mRsvBit1 : 1;
43
  bool mRsvBit2 : 1;
44
  bool mRsvBit3 : 1;
45
  bool mMaskBit : 1;
46
  uint8_t mOpCode;
47
48
  uint32_t mMask;
49
50
  nsCString mPayload;
51
};
52
53
class WebSocketFrame final : public nsIWebSocketFrame
54
{
55
public:
56
  NS_DECL_THREADSAFE_ISUPPORTS
57
  NS_DECL_NSIWEBSOCKETFRAME
58
59
  explicit WebSocketFrame(const WebSocketFrameData& aData);
60
61
  WebSocketFrame(bool aFinBit, bool aRsvBit1, bool aRsvBit2, bool aRsvBit3,
62
                 uint8_t aOpCode, bool aMaskBit, uint32_t aMask,
63
                 const nsCString& aPayload);
64
65
  const WebSocketFrameData& Data() const
66
0
  {
67
0
    return mData;
68
0
  }
69
70
private:
71
0
  ~WebSocketFrame() = default;
72
73
  WebSocketFrameData mData;
74
};
75
76
} // net namespace
77
} // mozilla namespace
78
79
#endif // mozilla_net_WebSocketFrame_h