Change RTCPeerConnection GetStats to use Date timestamp format
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Oct 2012 11:06:29 +0000 (11:06 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Oct 2012 11:06:29 +0000 (11:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=98263

Patch by Harald Alvestrand <hta@google.com> on 2012-10-04
Reviewed by Yury Semikhatsky.

Source/Platform:

* chromium/public/WebRTCStatsResponse.h:
(WebRTCStatsResponse):

Source/WebCore:

Tested by extension to RTCPeerConnection-stats test.

* Modules/mediastream/RTCStatsElement.cpp:
(WebCore::RTCStatsElement::create):
(WebCore::RTCStatsElement::RTCStatsElement):
* Modules/mediastream/RTCStatsElement.h: long -> double
(RTCStatsElement):
(WebCore::RTCStatsElement::timestamp):
* Modules/mediastream/RTCStatsElement.idl: long -> Date
* Modules/mediastream/RTCStatsReport.cpp:
(WebCore::RTCStatsReport::addElement):
* Modules/mediastream/RTCStatsReport.h:
(RTCStatsReport):
* Modules/mediastream/RTCStatsResponse.cpp:
(WebCore::RTCStatsResponse::addElement):
* Modules/mediastream/RTCStatsResponse.h:
(RTCStatsResponse):
* platform/chromium/support/WebRTCStatsResponse.cpp:
(WebKit::WebRTCStatsResponse::addElement):
* platform/mediastream/RTCStatsResponseBase.h:
(RTCStatsResponseBase):

Tools:

* DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp:
(MockWebRTCPeerConnectionHandler::getStats):

LayoutTests:

* fast/mediastream/RTCPeerConnection-stats-expected.txt:
* fast/mediastream/RTCPeerConnection-stats.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130383 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/RTCPeerConnection-stats-expected.txt
LayoutTests/fast/mediastream/RTCPeerConnection-stats.html
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebRTCStatsResponse.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCStatsElement.cpp
Source/WebCore/Modules/mediastream/RTCStatsElement.h
Source/WebCore/Modules/mediastream/RTCStatsElement.idl
Source/WebCore/Modules/mediastream/RTCStatsReport.cpp
Source/WebCore/Modules/mediastream/RTCStatsReport.h
Source/WebCore/Modules/mediastream/RTCStatsResponse.cpp
Source/WebCore/Modules/mediastream/RTCStatsResponse.h
Source/WebCore/platform/chromium/support/WebRTCStatsResponse.cpp
Source/WebCore/platform/mediastream/RTCStatsResponseBase.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp

index c909418..ef5bce6 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-04  Harald Alvestrand  <hta@google.com>
+
+        Change RTCPeerConnection GetStats to use Date timestamp format
+        https://bugs.webkit.org/show_bug.cgi?id=98263
+
+        Reviewed by Yury Semikhatsky.
+
+        * fast/mediastream/RTCPeerConnection-stats-expected.txt:
+        * fast/mediastream/RTCPeerConnection-stats.html:
+
 2012-10-04  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r130377.
index 99cd8f9..4ba1dbe 100644 (file)
@@ -14,6 +14,7 @@ PASS pc.getStats(statsHandler2) did not throw exception.
 PASS statsHandler2 was called
 PASS result.length is >= 2
 PASS local.length is 1
+PASS timestamp is >= startTime
 PASS local[0].stat("type") is "audio"
 PASS successfullyParsed is true
 
index 5985b7a..be1338c 100644 (file)
@@ -9,6 +9,7 @@ description("Tests the RTCPeerConnection stats interface.");
 
 var pc = null;
 var result;
+var timestamp;
 var local;
 
 function getUserMedia(dictionary, callback) {
@@ -49,10 +50,13 @@ function statsHandler2(status)
     shouldBeGreaterThanOrEqual('result.length', '2');
     local = result[0].local();
     shouldBe('local.length', '1');
+    timestamp = local[0].timestamp;
+    shouldBeGreaterThanOrEqual('timestamp', 'startTime');
     shouldBe('local[0].stat("type")', '"audio"');
     finishJSTest();
 }
 
+var startTime = new Date().getTime();
 shouldNotThrow('pc = new webkitRTCPeerConnection(null)');
 shouldNotThrow('pc.getStats(statsHandler1)');
 
index 1ac046f..ae1e6b4 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-04  Harald Alvestrand  <hta@google.com>
+
+        Change RTCPeerConnection GetStats to use Date timestamp format
+        https://bugs.webkit.org/show_bug.cgi?id=98263
+
+        Reviewed by Yury Semikhatsky.
+
+        * chromium/public/WebRTCStatsResponse.h:
+        (WebRTCStatsResponse):
+
 2012-10-04  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r130377.
index da25e1c..326794e 100644 (file)
@@ -52,7 +52,7 @@ public:
     WEBKIT_EXPORT void reset();
 
     WEBKIT_EXPORT size_t addReport();
-    WEBKIT_EXPORT size_t addElement(size_t report, bool isLocal, long timestamp);
+    WEBKIT_EXPORT size_t addElement(size_t report, bool isLocal, double timestamp);
     WEBKIT_EXPORT void addStatistic(size_t report, bool isLocal, size_t element, WebString name, WebString value);
 
 #if WEBKIT_IMPLEMENTATION
index 4bdcae8..0e2af6b 100644 (file)
@@ -1,3 +1,32 @@
+2012-10-04  Harald Alvestrand  <hta@google.com>
+
+        Change RTCPeerConnection GetStats to use Date timestamp format
+        https://bugs.webkit.org/show_bug.cgi?id=98263
+
+        Reviewed by Yury Semikhatsky.
+
+        Tested by extension to RTCPeerConnection-stats test.
+
+        * Modules/mediastream/RTCStatsElement.cpp:
+        (WebCore::RTCStatsElement::create):
+        (WebCore::RTCStatsElement::RTCStatsElement):
+        * Modules/mediastream/RTCStatsElement.h: long -> double
+        (RTCStatsElement):
+        (WebCore::RTCStatsElement::timestamp):
+        * Modules/mediastream/RTCStatsElement.idl: long -> Date
+        * Modules/mediastream/RTCStatsReport.cpp:
+        (WebCore::RTCStatsReport::addElement):
+        * Modules/mediastream/RTCStatsReport.h:
+        (RTCStatsReport):
+        * Modules/mediastream/RTCStatsResponse.cpp:
+        (WebCore::RTCStatsResponse::addElement):
+        * Modules/mediastream/RTCStatsResponse.h:
+        (RTCStatsResponse):
+        * platform/chromium/support/WebRTCStatsResponse.cpp:
+        (WebKit::WebRTCStatsResponse::addElement):
+        * platform/mediastream/RTCStatsResponseBase.h:
+        (RTCStatsResponseBase):
+
 2012-10-04  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r130377.
index 4a3331f..9d51e54 100644 (file)
 
 namespace WebCore {
 
-PassRefPtr<RTCStatsElement> RTCStatsElement::create(long timestamp)
+PassRefPtr<RTCStatsElement> RTCStatsElement::create(double timestamp)
 {
     return adoptRef(new RTCStatsElement(timestamp));
 }
 
-RTCStatsElement::RTCStatsElement(long timestamp)
+RTCStatsElement::RTCStatsElement(double timestamp)
     : m_timestamp(timestamp)
 {
 }
index 7f8d1bd..0afab5f 100644 (file)
@@ -34,15 +34,15 @@ namespace WebCore {
 
 class RTCStatsElement : public RefCounted<RTCStatsElement> {
 public:
-    static PassRefPtr<RTCStatsElement> create(long timestamp);
-    long timestamp() const { return m_timestamp; }
+    static PassRefPtr<RTCStatsElement> create(double timestamp);
+    double timestamp() const { return m_timestamp; }
     String stat(const String& name) const;
     void addStatistic(const String& name, const String& value);
 
 private:
-    explicit RTCStatsElement(long timestamp);
+    explicit RTCStatsElement(double timestamp);
 
-    long m_timestamp;
+    double m_timestamp;
     HashMap<String, String> m_stats;
 };
 
index c1b0948..37d91a2 100644 (file)
@@ -27,7 +27,7 @@ module mediastream {
     interface [
         Conditional=MEDIA_STREAM,
     ] RTCStatsElement {
-        readonly attribute long timestamp;
+        readonly attribute Date timestamp;
         DOMString stat(in DOMString name);
     };
 }
index 5e95095..027c170 100644 (file)
@@ -39,7 +39,7 @@ RTCStatsReport::RTCStatsReport()
 {
 }
 
-size_t RTCStatsReport::addElement(bool isLocal, long timestamp)
+size_t RTCStatsReport::addElement(bool isLocal, double timestamp)
 {
     if (isLocal) {
         m_local.append(RTCStatsElement::create(timestamp));
index ef7dcac..e6c680c 100644 (file)
@@ -40,7 +40,7 @@ public:
     const Vector<RefPtr<RTCStatsElement> >& local() const { return m_local; }
     const Vector<RefPtr<RTCStatsElement> >& remote() const { return m_remote; }
 
-    size_t addElement(bool isLocal, long timestamp);
+    size_t addElement(bool isLocal, double timestamp);
     void addStatistic(bool isLocal, size_t element, String name, String value);
 
 private:
index 2acafa3..1ece63d 100644 (file)
@@ -45,7 +45,7 @@ size_t RTCStatsResponse::addReport()
     return m_result.size() - 1;
 }
 
-size_t RTCStatsResponse::addElement(size_t report, bool isLocal, long timestamp)
+size_t RTCStatsResponse::addElement(size_t report, bool isLocal, double timestamp)
 {
     ASSERT(report >= 0 && report < m_result.size());
     return m_result[report]->addElement(isLocal, timestamp);
index 3fa8047..d4940de 100644 (file)
@@ -45,7 +45,7 @@ public:
     const Vector<RefPtr<RTCStatsReport> >& result() const { return m_result; };
 
     virtual size_t addReport() OVERRIDE;
-    virtual size_t addElement(size_t report, bool isLocal, long timestamp) OVERRIDE;
+    virtual size_t addElement(size_t report, bool isLocal, double timestamp) OVERRIDE;
     virtual void addStatistic(size_t report, bool isLocal, size_t element, String name, String value) OVERRIDE;
 
 private:
index 09d7e10..6888566 100644 (file)
@@ -60,7 +60,7 @@ size_t WebRTCStatsResponse::addReport()
     return m_private->addReport();
 }
 
-size_t WebRTCStatsResponse::addElement(size_t report, bool isLocal, long timestamp)
+size_t WebRTCStatsResponse::addElement(size_t report, bool isLocal, double timestamp)
 {
     return m_private->addElement(report, isLocal, timestamp);
 }
index 5547c5c..4496f67 100644 (file)
@@ -38,7 +38,7 @@ public:
     virtual ~RTCStatsResponseBase() { }
 
     virtual size_t addReport() = 0;
-    virtual size_t addElement(size_t report, bool isLocal, long timestamp) = 0;
+    virtual size_t addElement(size_t report, bool isLocal, double timestamp) = 0;
     virtual void addStatistic(size_t report, bool isLocal, size_t element, String name, String value) = 0;
 };
 
index a5cb88d..e834fbb 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-04  Harald Alvestrand  <hta@google.com>
+
+        Change RTCPeerConnection GetStats to use Date timestamp format
+        https://bugs.webkit.org/show_bug.cgi?id=98263
+
+        Reviewed by Yury Semikhatsky.
+
+        * DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp:
+        (MockWebRTCPeerConnectionHandler::getStats):
+
 2012-10-04  Dirk Pranke  <dpranke@chromium.org>
 
         [NRWT] --skipped option is ignored when --test-list is used
index 3add09a..f0a2f62 100644 (file)
@@ -43,6 +43,7 @@
 #include <public/WebRTCVoidRequest.h>
 #include <public/WebString.h>
 #include <public/WebVector.h>
+#include <wtf/DateMath.h>
 
 using namespace WebKit;
 
@@ -215,12 +216,13 @@ void MockWebRTCPeerConnectionHandler::removeStream(const WebMediaStreamDescripto
 void MockWebRTCPeerConnectionHandler::getStats(const WebRTCStatsRequest& request)
 {
     WebRTCStatsResponse response = request.createResponse();
+    double currentDate = WTF::jsCurrentTime();
     for (int i = 0; i < m_streamCount; ++i) {
         size_t reportIndex = response.addReport();
-        size_t elementIndex = response.addElement(reportIndex, true, 12345);
+        size_t elementIndex = response.addElement(reportIndex, true, currentDate);
         response.addStatistic(reportIndex, true, elementIndex, "type", "audio");
         reportIndex = response.addReport();
-        elementIndex = response.addElement(reportIndex, true, 12345);
+        elementIndex = response.addElement(reportIndex, true, currentDate);
         response.addStatistic(reportIndex, true, elementIndex, "type", "video");
     }
     postTask(new RTCStatsRequestSucceededTask(this, request, response));