Bug 1203802 - Websocket Frame Listener API for devtool Network Inspector - part 3 - timestamp, r=michal
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 26 Oct 2015 15:30:39 +0000
changeset 304689 709a898fdc8bbf27f5f250e10e638e207005ae58
parent 304688 1465c8af67d72c1e554a15d572cabdba4864cffe
child 304690 e415ff528bd18f8e5db55051ddee6ec3be2c6d6c
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1203802
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203802 - Websocket Frame Listener API for devtool Network Inspector - part 3 - timestamp, r=michal
dom/base/test/test_websocket_frame.html
netwerk/protocol/websocket/WebSocketFrame.cpp
netwerk/protocol/websocket/WebSocketFrame.h
netwerk/protocol/websocket/nsIWebSocketFrameService.idl
--- a/dom/base/test/test_websocket_frame.html
+++ b/dom/base/test/test_websocket_frame.html
@@ -34,50 +34,54 @@ ok(!!service, "We have the nsIWebSocketF
 
 var listener = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebSocketFrameListener]),
 
   frameReceived: function(aWebSocketSerialID, aFrame) {
     ok(!!aFrame, "We have received a frame");
 
     if (tests.length) {
+      ok(aFrame.timeStamp, "Checking timeStamp: " + aFrame.timeStamp);
       is(aFrame.finBit, true, "Checking finBit");
       is(aFrame.rsvBit1, true, "Checking rsvBit1");
       is(aFrame.rsvBit2, false, "Checking rsvBit2");
       is(aFrame.rsvBit3, false, "Checking rsvBit3");
       is(aFrame.opCode, aFrame.OPCODE_TEXT, "Checking opCode");
       is(aFrame.maskBit, false, "Checking maskBit");
       is(aFrame.mask, 0, "Checking mask");
       is(aFrame.payload, tests[0].payload, "Checking payload: " + aFrame.payload);
     } else {
+      ok(aFrame.timeStamp, "Checking timeStamp: " + aFrame.timeStamp);
       is(aFrame.finBit, true, "Checking finBit");
       is(aFrame.rsvBit1, false, "Checking rsvBit1");
       is(aFrame.rsvBit2, false, "Checking rsvBit2");
       is(aFrame.rsvBit3, false, "Checking rsvBit3");
       is(aFrame.opCode, aFrame.OPCODE_CLOSE, "Checking opCode");
       is(aFrame.maskBit, false, "Checking maskBit");
       is(aFrame.mask, 0, "Checking mask");
     }
 
     frameReceivedCounter++;
   },
 
   frameSent: function(aWebSocketSerialID, aFrame) {
     ok(!!aFrame, "We have sent a frame");
 
     if (tests.length) {
+      ok(aFrame.timeStamp, "Checking timeStamp: " + aFrame.timeStamp);
       is(aFrame.finBit, true, "Checking finBit");
       is(aFrame.rsvBit1, true, "Checking rsvBit1");
       is(aFrame.rsvBit2, false, "Checking rsvBit2");
       is(aFrame.rsvBit3, false, "Checking rsvBit3");
       is(aFrame.opCode, aFrame.OPCODE_TEXT, "Checking opCode");
       is(aFrame.maskBit, true, "Checking maskBit");
       ok(!!aFrame.mask, "Checking mask: " + aFrame.mask);
       is(aFrame.payload, tests[0].payload, "Checking payload: " + aFrame.payload);
     } else {
+      ok(aFrame.timeStamp, "Checking timeStamp: " + aFrame.timeStamp);
       is(aFrame.finBit, true, "Checking finBit");
       is(aFrame.rsvBit1, false, "Checking rsvBit1");
       is(aFrame.rsvBit2, false, "Checking rsvBit2");
       is(aFrame.rsvBit3, false, "Checking rsvBit3");
       is(aFrame.opCode, aFrame.OPCODE_CLOSE, "Checking opCode");
       is(aFrame.maskBit, true, "Checking maskBit");
       ok(!!aFrame.mask, "Checking mask: " + aFrame.mask);
     }
--- a/netwerk/protocol/websocket/WebSocketFrame.cpp
+++ b/netwerk/protocol/websocket/WebSocketFrame.cpp
@@ -29,16 +29,17 @@ WebSocketFrame::WebSocketFrame(bool aFin
   , mRsvBit2(aRsvBit2)
   , mRsvBit3(aRsvBit3)
   , mMaskBit(aMaskBit)
   , mOpCode(aOpCode)
   , mMask(aMask)
   , mPayload(aPayload)
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
+  mTimeStamp = PR_Now();
 }
 
 WebSocketFrame::~WebSocketFrame()
 {}
 
 #define WSF_GETTER( method, value , type )     \
 NS_IMETHODIMP                                  \
 WebSocketFrame::method(type* aValue)           \
@@ -46,16 +47,17 @@ WebSocketFrame::method(type* aValue)    
   MOZ_ASSERT(NS_IsMainThread());               \
   if (!aValue) {                               \
     return NS_ERROR_FAILURE;                   \
   }                                            \
   *aValue = value;                             \
   return NS_OK;                                \
 }
 
+WSF_GETTER(GetTimeStamp, mTimeStamp, DOMHighResTimeStamp);
 WSF_GETTER(GetFinBit, mFinBit, bool);
 WSF_GETTER(GetRsvBit1, mRsvBit1, bool);
 WSF_GETTER(GetRsvBit2, mRsvBit2, bool);
 WSF_GETTER(GetRsvBit3, mRsvBit3, bool);
 WSF_GETTER(GetOpCode, mOpCode, uint16_t);
 WSF_GETTER(GetMaskBit, mMaskBit, bool);
 WSF_GETTER(GetMask, mMask, uint32_t);
 
--- a/netwerk/protocol/websocket/WebSocketFrame.h
+++ b/netwerk/protocol/websocket/WebSocketFrame.h
@@ -21,16 +21,18 @@ public:
 
   WebSocketFrame(bool aFinBit, bool aRsvBit1, bool aRsvBit2, bool aRsvBit3,
                  uint8_t aOpCode, bool aMaskBit, uint32_t aMask,
                  const nsCString& aPayload);
 
 private:
   ~WebSocketFrame();
 
+  DOMHighResTimeStamp mTimeStamp;
+
   bool mFinBit : 1;
   bool mRsvBit1 : 1;
   bool mRsvBit2 : 1;
   bool mRsvBit3 : 1;
   bool mMaskBit : 1;
   uint8_t mOpCode;
 
   uint32_t mMask;
--- a/netwerk/protocol/websocket/nsIWebSocketFrameService.idl
+++ b/netwerk/protocol/websocket/nsIWebSocketFrameService.idl
@@ -1,18 +1,21 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "domstubs.idl"
 #include "nsISupports.idl"
 
-[scriptable, builtinclass, uuid(e668b6bf-d29d-4861-b1bc-bab70da4da5c)]
+[scriptable, builtinclass, uuid(470133f3-a04f-48a9-82bd-8d1bc7eb6f9c)]
 interface nsIWebSocketFrame : nsISupports
 {
+  readonly attribute DOMHighResTimeStamp timeStamp;
+
   readonly attribute boolean finBit;
 
   readonly attribute boolean rsvBit1;
   readonly attribute boolean rsvBit2;
   readonly attribute boolean rsvBit3;
 
   readonly attribute unsigned short opCode;