Changeset 130260 in webkit
- Timestamp:
- Oct 3, 2012 1:01:25 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r130255 r130260 1 2012-10-03 Harald Alvestrand <hta@google.com> 2 3 Add data passing to the GetStats interface of RTCPeerConnection 4 https://bugs.webkit.org/show_bug.cgi?id=98003 5 6 Reviewed by Adam Barth. 7 8 * fast/mediastream/RTCPeerConnection-stats-expected.txt: 9 * fast/mediastream/RTCPeerConnection-stats.html: 10 1 11 2012-10-02 Arko Saha <arko@motorola.com> 2 12 -
trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stats-expected.txt
r129908 r130260 5 5 6 6 PASS pc = new webkitRTCPeerConnection(null) did not throw exception. 7 PASS pc.getStats(statsHandler ) did not throw exception.8 PASS statsHandler was called7 PASS pc.getStats(statsHandler1) did not throw exception. 8 PASS statsHandler1 was called 9 9 PASS status is non-null. 10 10 PASS result.length is 0 11 PASS getUserMedia({audio:true, video:true}, gotStream) did not throw exception. 12 PASS Got a stream. 13 PASS pc.getStats(statsHandler2) did not throw exception. 14 PASS statsHandler2 was called 15 PASS result.length is >= 2 16 PASS local.length is 1 17 PASS local[0].stat("type") is "audio" 11 18 PASS successfullyParsed is true 12 19 -
trunk/LayoutTests/fast/mediastream/RTCPeerConnection-stats.html
r129908 r130260 9 9 10 10 var pc = null; 11 var result; 12 var local; 11 13 12 function statsHandler(status) 14 function getUserMedia(dictionary, callback) { 15 try { 16 navigator.webkitGetUserMedia(dictionary, callback, error); 17 } catch (e) { 18 testFailed('webkitGetUserMedia threw exception :' + e); 19 finishJSTest(); 20 } 21 } 22 23 function error() { 24 testFailed('Stream generation failed.'); 25 finishJSTest(); 26 } 27 28 function statsHandler1(status) 13 29 { 14 testPassed("statsHandler was called");30 testPassed("statsHandler1 was called"); 15 31 shouldBeNonNull('status'); 16 32 result = status.result(); 17 33 shouldBe('result.length', '0'); 34 shouldNotThrow('getUserMedia({audio:true, video:true}, gotStream)'); 35 } 36 37 function gotStream(s) { 38 testPassed('Got a stream.'); 39 stream = s; 40 41 pc.addStream(stream); 42 shouldNotThrow('pc.getStats(statsHandler2)'); 43 } 44 45 function statsHandler2(status) 46 { 47 testPassed("statsHandler2 was called"); 48 result = status.result(); 49 shouldBeGreaterThanOrEqual('result.length', '2'); 50 local = result[0].local(); 51 shouldBe('local.length', '1'); 52 shouldBe('local[0].stat("type")', '"audio"'); 18 53 finishJSTest(); 19 54 } 20 55 21 56 shouldNotThrow('pc = new webkitRTCPeerConnection(null)'); 22 shouldNotThrow('pc.getStats(statsHandler )');57 shouldNotThrow('pc.getStats(statsHandler1)'); 23 58 24 59 window.jsTestIsAsync = true; -
trunk/Source/Platform/ChangeLog
r130180 r130260 1 2012-10-03 Harald Alvestrand <hta@google.com> 2 3 Add data passing to the GetStats interface of RTCPeerConnection 4 https://bugs.webkit.org/show_bug.cgi?id=98003 5 6 Reviewed by Adam Barth. 7 8 * Platform.gypi: 9 * chromium/public/WebRTCStatsRequest.h: 10 (WebKit): 11 (WebRTCStatsRequest): 12 * chromium/public/WebRTCStatsResponse.h: Added. 13 (WebCore): 14 (WebKit): 15 (WebRTCStatsResponse): 16 (WebKit::WebRTCStatsResponse::WebRTCStatsResponse): 17 (WebKit::WebRTCStatsResponse::~WebRTCStatsResponse): 18 (WebKit::WebRTCStatsResponse::operator=): 19 1 20 2012-10-02 Terry Anderson <tdanderson@chromium.org> 2 21 -
trunk/Source/Platform/Platform.gypi
r129894 r130260 113 113 'chromium/public/WebRTCSessionDescription.h', 114 114 'chromium/public/WebRTCSessionDescriptionRequest.h', 115 'chromium/public/WebRTCStatsRequest.h', 116 'chromium/public/WebRTCStatsResponse.h', 115 117 'chromium/public/WebRTCVoidRequest.h', 116 118 'chromium/public/WebRect.h', -
trunk/Source/Platform/chromium/public/WebRTCStatsRequest.h
r129908 r130260 42 42 namespace WebKit { 43 43 44 class WebRTCStatsResponse; 45 46 // The WebRTCStatsRequest class represents a JavaScript call on 47 // RTCPeerConnection.getStats(). The user of this API will use 48 // the calls on this class and WebRTCStatsResponse to fill in the 49 // data that will be returned via a callback to the user in an 50 // RTCStatsResponse structure. 51 // 52 // The typical usage pattern is: 53 // WebRTCStatsRequest request = <from somewhere> 54 // WebRTCStatsResponse response = request.createResponse(); 55 // 56 // For each item on which statistics are going to be reported: 57 // size_t reportIndex = response.addReport(); 58 // Add local information: 59 // size_t elementIndex = response.addElement(reportIndex, true, dateNow()); 60 // For each statistic being reported on: 61 // response.addStatistic(reportIndex, true, elementIndex, 62 // "name of statistic", "statistic value"); 63 // Remote information (typically RTCP-derived) is added in the same way. 64 // When finished adding information: 65 // request.requestSucceeded(response); 66 44 67 class WebRTCStatsRequest { 45 68 public: … … 58 81 WEBKIT_EXPORT void reset(); 59 82 60 WEBKIT_EXPORT void requestSucceeded() const; 83 WEBKIT_EXPORT void requestSucceeded(const WebRTCStatsResponse&) const; 84 85 WEBKIT_EXPORT WebRTCStatsResponse createResponse() const; 61 86 62 87 #if WEBKIT_IMPLEMENTATION -
trunk/Source/Platform/chromium/public/WebRTCStatsResponse.h
r130259 r130260 23 23 */ 24 24 25 #ifndef RTCStatsRequestImpl_h26 #define RTCStatsRequestImpl_h25 #ifndef WebRTCStatsResponse_h 26 #define WebRTCStatsResponse_h 27 27 28 #if ENABLE(MEDIA_STREAM) 29 30 #include "ActiveDOMObject.h" 31 #include "RTCStatsRequest.h" 32 #include <wtf/PassRefPtr.h> 33 #include <wtf/RefCounted.h> 34 #include <wtf/text/WTFString.h> 28 #include "WebCommon.h" 29 #include "WebPrivatePtr.h" 30 #include "WebString.h" 35 31 36 32 namespace WebCore { 33 class RTCStatsResponseBase; 34 } 37 35 38 class RTCStatsCallback; 36 namespace WebKit { 39 37 40 class RTCStatsRequestImpl : public RTCStatsRequest, public ActiveDOMObject{38 class WebRTCStatsResponse { 41 39 public: 42 static PassRefPtr<RTCStatsRequestImpl> create(ScriptExecutionContext*, PassRefPtr<RTCStatsCallback>); 43 virtual ~RTCStatsRequestImpl(); 40 WebRTCStatsResponse() { } 41 WebRTCStatsResponse(const WebRTCStatsResponse& other) { assign(other); } 42 ~WebRTCStatsResponse() { reset(); } 44 43 45 virtual void requestSucceeded(); 44 WebRTCStatsResponse& operator=(const WebRTCStatsResponse& other) 45 { 46 assign(other); 47 return *this; 48 } 46 49 47 // ActiveDOMObject 48 virtual void stop() OVERRIDE; 50 WEBKIT_EXPORT void assign(const WebRTCStatsResponse&); 51 52 WEBKIT_EXPORT void reset(); 53 54 WEBKIT_EXPORT size_t addReport(); 55 WEBKIT_EXPORT size_t addElement(size_t report, bool isLocal, long timestamp); 56 WEBKIT_EXPORT void addStatistic(size_t report, bool isLocal, size_t element, WebString name, WebString value); 57 58 #if WEBKIT_IMPLEMENTATION 59 WebRTCStatsResponse(const WTF::PassRefPtr<WebCore::RTCStatsResponseBase>&); 60 61 operator WTF::PassRefPtr<WebCore::RTCStatsResponseBase>() const; 62 #endif 49 63 50 64 private: 51 RTCStatsRequestImpl(ScriptExecutionContext*, PassRefPtr<RTCStatsCallback>); 52 53 void clear(); 54 55 RefPtr<RTCStatsCallback> m_successCallback; 65 WebPrivatePtr<WebCore::RTCStatsResponseBase> m_private; 56 66 }; 57 67 58 } // namespace Web Core68 } // namespace WebKit 59 69 60 #endif // ENABLE(MEDIA_STREAM) 61 62 #endif // RTCStatsRequestImpl_h 70 #endif // WebRTCStatsResponse_h -
trunk/Source/WebCore/ChangeLog
r130259 r130260 1 2012-10-03 Harald Alvestrand <hta@google.com> 2 3 Add data passing to the GetStats interface of RTCPeerConnection 4 https://bugs.webkit.org/show_bug.cgi?id=98003 5 6 Reviewed by Adam Barth. 7 8 Added an RTCStatsResponseBase interface to platform, and let the 9 RTCStatsRequestImpl class produce an implementation of it that's returned 10 to WebCore. 11 12 Tested by extension of the RTCPeerConnection-stats.html test. 13 14 * Modules/mediastream/RTCStatsElement.cpp: 15 (WebCore::RTCStatsElement::addStatistic): 16 (WebCore): 17 * Modules/mediastream/RTCStatsElement.h: 18 (RTCStatsElement): 19 * Modules/mediastream/RTCStatsReport.cpp: 20 (WebCore): 21 (WebCore::RTCStatsReport::addElement): 22 (WebCore::RTCStatsReport::addStatistic): 23 * Modules/mediastream/RTCStatsReport.h: 24 (RTCStatsReport): 25 * Modules/mediastream/RTCStatsRequestImpl.cpp: 26 (WebCore::RTCStatsRequestImpl::createResponse): 27 (WebCore): 28 (WebCore::RTCStatsRequestImpl::requestSucceeded): 29 * Modules/mediastream/RTCStatsRequestImpl.h: 30 (RTCStatsRequestImpl): 31 * Modules/mediastream/RTCStatsResponse.cpp: 32 (WebCore::RTCStatsResponse::create): 33 (WebCore::RTCStatsResponse::addReport): 34 (WebCore): 35 (WebCore::RTCStatsResponse::addElement): 36 (WebCore::RTCStatsResponse::addStatistic): 37 * Modules/mediastream/RTCStatsResponse.h: 38 (RTCStatsResponse): 39 * WebCore.gypi: 40 * platform/chromium/support/WebRTCStatsRequest.cpp: 41 (WebKit::WebRTCStatsRequest::response): 42 (WebKit): 43 (WebKit::WebRTCStatsRequest::requestSucceeded): 44 * platform/chromium/support/WebRTCStatsResponse.cpp: Added. 45 (WebKit): 46 (WebKit::WebRTCStatsResponse::WebRTCStatsResponse): 47 (WebKit::WebRTCStatsResponse::assign): 48 (WebKit::WebRTCStatsResponse::reset): 49 (WebKit::WebRTCStatsResponse::operator WTF::PassRefPtr<WebCore::RTCStatsResponseBase>): 50 (WebKit::WebRTCStatsResponse::addReport): 51 (WebKit::WebRTCStatsResponse::addElement): 52 (WebKit::WebRTCStatsResponse::addStatistic): 53 * platform/mediastream/RTCStatsRequest.h: 54 (WebCore): 55 (RTCStatsRequest): 56 * platform/mediastream/RTCStatsResponseBase.h: Added. 57 (WebCore): 58 (RTCStatsResponseBase): 59 (WebCore::RTCStatsResponseBase::~RTCStatsResponseBase): 60 1 61 2012-10-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 62 -
trunk/Source/WebCore/Modules/mediastream/RTCStatsElement.cpp
r129908 r130260 48 48 } 49 49 50 void RTCStatsElement::addStatistic(const String& name, const String& value) 51 { 52 m_stats.add(name, value); 53 } 54 50 55 } // namespace WebCore 51 56 -
trunk/Source/WebCore/Modules/mediastream/RTCStatsElement.h
r129908 r130260 38 38 long timestamp() const { return m_timestamp; } 39 39 String stat(const String& name) const; 40 void addStatistic(const String& name, const String& value); 40 41 41 42 private: -
trunk/Source/WebCore/Modules/mediastream/RTCStatsReport.cpp
r129908 r130260 40 40 } 41 41 42 size_t RTCStatsReport::addElement(bool isLocal, long timestamp) 43 { 44 if (isLocal) { 45 m_local.append(RTCStatsElement::create(timestamp)); 46 return m_local.size() - 1; 47 } 48 m_remote.append(RTCStatsElement::create(timestamp)); 49 return m_remote.size() - 1; 50 } 51 52 void RTCStatsReport::addStatistic(bool isLocal, size_t element, String name, String value) 53 { 54 if (isLocal) { 55 ASSERT(element >= 0 && element < m_local.size()); 56 m_local[element]->addStatistic(name, value); 57 } else { 58 ASSERT(element >= 0 && element < m_remote.size()); 59 m_remote[element]->addStatistic(name, value); 60 } 61 } 62 42 63 } // namespace WebCore 43 64 -
trunk/Source/WebCore/Modules/mediastream/RTCStatsReport.h
r129908 r130260 41 41 const Vector<RefPtr<RTCStatsElement> >& remote() const { return m_remote; } 42 42 43 size_t addElement(bool isLocal, long timestamp); 44 void addStatistic(bool isLocal, size_t element, String name, String value); 45 43 46 private: 44 47 RTCStatsReport(); -
trunk/Source/WebCore/Modules/mediastream/RTCStatsRequestImpl.cpp
r129908 r130260 52 52 } 53 53 54 void RTCStatsRequestImpl::requestSucceeded() 54 PassRefPtr<RTCStatsResponseBase> RTCStatsRequestImpl::createResponse() 55 { 56 return RTCStatsResponse::create(); 57 } 58 59 void RTCStatsRequestImpl::requestSucceeded(PassRefPtr<RTCStatsResponseBase> response) 55 60 { 56 61 if (!m_successCallback) 57 62 return; 58 // FIXME: Fill in content of stats parameter. 59 RefPtr<RTCStatsResponse> stats = RTCStatsResponse::create(); 60 m_successCallback->handleEvent(stats.get()); 63 m_successCallback->handleEvent(static_cast<RTCStatsResponse*>(response.get())); 61 64 clear(); 62 65 } -
trunk/Source/WebCore/Modules/mediastream/RTCStatsRequestImpl.h
r129908 r130260 30 30 #include "ActiveDOMObject.h" 31 31 #include "RTCStatsRequest.h" 32 #include "RTCStatsResponse.h" 32 33 #include <wtf/PassRefPtr.h> 33 34 #include <wtf/RefCounted.h> … … 43 44 virtual ~RTCStatsRequestImpl(); 44 45 45 virtual void requestSucceeded(); 46 virtual PassRefPtr<RTCStatsResponseBase> createResponse(); 47 virtual void requestSucceeded(PassRefPtr<RTCStatsResponseBase>); 46 48 47 49 // ActiveDOMObject -
trunk/Source/WebCore/Modules/mediastream/RTCStatsResponse.cpp
r129908 r130260 34 34 { 35 35 return adoptRef(new RTCStatsResponse()); 36 // FIXME: Pass an RTCStatsRequest argument and populate from it.37 36 } 38 37 … … 41 40 } 42 41 42 size_t RTCStatsResponse::addReport() 43 { 44 m_result.append(RTCStatsReport::create()); 45 return m_result.size() - 1; 46 } 47 48 size_t RTCStatsResponse::addElement(size_t report, bool isLocal, long timestamp) 49 { 50 ASSERT(report >= 0 && report < m_result.size()); 51 return m_result[report]->addElement(isLocal, timestamp); 52 } 53 54 void RTCStatsResponse::addStatistic(size_t report, bool isLocal, size_t element, String name, String value) 55 { 56 ASSERT(report >= 0 && report < m_result.size()); 57 return m_result[report]->addStatistic(isLocal, element, name, value); 58 } 59 43 60 } // namespace WebCore 44 61 -
trunk/Source/WebCore/Modules/mediastream/RTCStatsResponse.h
r129908 r130260 35 35 #include "MediaStreamTrack.h" 36 36 #include "RTCStatsReport.h" 37 #include "RTCStatsResponseBase.h" 37 38 38 39 namespace WebCore { 39 40 40 class RTCStatsResponse : public R efCounted<RTCStatsResponse>{41 class RTCStatsResponse : public RTCStatsResponseBase { 41 42 public: 42 43 static PassRefPtr<RTCStatsResponse> create(); 43 44 44 45 const Vector<RefPtr<RTCStatsReport> >& result() const { return m_result; }; 46 47 virtual size_t addReport() OVERRIDE; 48 virtual size_t addElement(size_t report, bool isLocal, long timestamp) OVERRIDE; 49 virtual void addStatistic(size_t report, bool isLocal, size_t element, String name, String value) OVERRIDE; 45 50 46 51 private: -
trunk/Source/WebCore/WebCore.gypi
r130106 r130260 8374 8374 'platform/chromium/support/WebRTCSessionDescriptionRequest.cpp', 8375 8375 'platform/chromium/support/WebRTCStatsRequest.cpp', 8376 'platform/chromium/support/WebRTCStatsResponse.cpp', 8376 8377 'platform/chromium/support/WebRTCVoidRequest.cpp', 8377 8378 'platform/chromium/support/WebScrollbarThemeGeometryNative.cpp', -
trunk/Source/WebCore/platform/chromium/support/WebRTCStatsRequest.cpp
r129908 r130260 34 34 35 35 #include <public/WebRTCStatsRequest.h> 36 #include <public/WebRTCStatsResponse.h> 36 37 37 38 #include "RTCStatsRequest.h" 39 #include "RTCStatsResponse.h" 38 40 #include <wtf/PassOwnPtr.h> 39 41 … … 57 59 } 58 60 59 void WebRTCStatsRequest::requestSucceeded() const61 WebRTCStatsResponse WebRTCStatsRequest::createResponse() const 60 62 { 61 m_private->requestSucceeded(); 63 return WebRTCStatsResponse(m_private->createResponse()); 64 } 65 66 void WebRTCStatsRequest::requestSucceeded(const WebRTCStatsResponse& response) const 67 { 68 m_private->requestSucceeded(response); 62 69 } 63 70 -
trunk/Source/WebCore/platform/chromium/support/WebRTCStatsResponse.cpp
r130259 r130260 27 27 #if ENABLE(MEDIA_STREAM) 28 28 29 #include "RTCStatsElement.h"29 #include <public/WebRTCStatsResponse.h> 30 30 31 #include <wtf/text/StringHash.h> 31 #include "RTCStatsResponseBase.h" 32 #include <wtf/PassOwnPtr.h> 32 33 33 namespace WebCore { 34 using namespace WebCore; 34 35 35 PassRefPtr<RTCStatsElement> RTCStatsElement::create(long timestamp) 36 { 37 return adoptRef(new RTCStatsElement(timestamp)); 38 } 36 namespace WebKit { 39 37 40 RTCStatsElement::RTCStatsElement(long timestamp)41 : m_ timestamp(timestamp)38 WebRTCStatsResponse::WebRTCStatsResponse(const PassRefPtr<RTCStatsResponseBase>& request) 39 : m_private(request) 42 40 { 43 41 } 44 42 45 String RTCStatsElement::stat(const String& name) const 43 void WebRTCStatsResponse::assign(const WebRTCStatsResponse& other) 46 44 { 47 return m_stats.get(name);45 m_private = other.m_private; 48 46 } 49 47 50 } // namespace WebCore 48 void WebRTCStatsResponse::reset() 49 { 50 m_private.reset(); 51 } 52 53 WebRTCStatsResponse::operator WTF::PassRefPtr<WebCore::RTCStatsResponseBase>() const 54 { 55 return m_private.get(); 56 } 57 58 size_t WebRTCStatsResponse::addReport() 59 { 60 return m_private->addReport(); 61 } 62 63 size_t WebRTCStatsResponse::addElement(size_t report, bool isLocal, long timestamp) 64 { 65 return m_private->addElement(report, isLocal, timestamp); 66 } 67 68 void WebRTCStatsResponse::addStatistic(size_t report, bool isLocal, size_t element, WebString name, WebString value) 69 { 70 m_private->addStatistic(report, isLocal, element, name, value); 71 } 72 73 } // namespace WebKit 51 74 52 75 #endif // ENABLE(MEDIA_STREAM) 76 -
trunk/Source/WebCore/platform/mediastream/RTCStatsRequest.h
r129908 r130260 40 40 namespace WebCore { 41 41 42 class RTCStatsResponseBase; 43 42 44 class RTCStatsRequest : public RefCounted<RTCStatsRequest> { 43 45 public: 44 46 virtual ~RTCStatsRequest() { } 45 47 46 virtual void requestSucceeded() = 0; 48 virtual PassRefPtr<RTCStatsResponseBase> createResponse() = 0; 49 virtual void requestSucceeded(PassRefPtr<RTCStatsResponseBase>) = 0; 47 50 48 51 protected: -
trunk/Source/WebCore/platform/mediastream/RTCStatsResponseBase.h
r130259 r130260 23 23 */ 24 24 25 #ifndef RTCStats Element_h26 #define RTCStats Element_h25 #ifndef RTCStatsResponseBase_h 26 #define RTCStatsResponseBase_h 27 27 28 #include <wtf/HashMap.h> 28 #if ENABLE(MEDIA_STREAM) 29 29 30 #include <wtf/PassRefPtr.h> 30 31 #include <wtf/RefCounted.h> … … 33 34 namespace WebCore { 34 35 35 class RTCStats Element : public RefCounted<RTCStatsElement> {36 class RTCStatsResponseBase : public RefCounted<RTCStatsResponseBase> { 36 37 public: 37 static PassRefPtr<RTCStatsElement> create(long timestamp); 38 long timestamp() const { return m_timestamp; } 39 String stat(const String& name) const; 38 virtual ~RTCStatsResponseBase() { } 40 39 41 private: 42 explicit RTCStatsElement(long timestamp); 43 44 long m_timestamp; 45 HashMap<String, String> m_stats; 40 virtual size_t addReport() = 0; 41 virtual size_t addElement(size_t report, bool isLocal, long timestamp) = 0; 42 virtual void addStatistic(size_t report, bool isLocal, size_t element, String name, String value) = 0; 46 43 }; 47 44 48 45 } // namespace WebCore 49 46 50 #endif // RTCStatsElement_h 47 #endif // ENABLE(MEDIA_STREAM) 48 49 #endif // RTCStatsResponseBase_h -
trunk/Tools/ChangeLog
r130237 r130260 1 2012-10-03 Harald Alvestrand <hta@google.com> 2 3 Add data passing to the GetStats interface of RTCPeerConnection 4 https://bugs.webkit.org/show_bug.cgi?id=98003 5 6 Reviewed by Adam Barth. 7 8 * DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp: 9 (RTCStatsRequestSucceededTask::RTCStatsRequestSucceededTask): 10 (MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler): 11 (MockWebRTCPeerConnectionHandler::addStream): 12 (MockWebRTCPeerConnectionHandler::removeStream): 13 (MockWebRTCPeerConnectionHandler::getStats): 14 * DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h: 15 (MockWebRTCPeerConnectionHandler): 16 1 17 == Rolled over to ChangeLog-2012-10-02 == -
trunk/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp
r129908 r130260 40 40 #include <public/WebRTCSessionDescriptionRequest.h> 41 41 #include <public/WebRTCStatsRequest.h> 42 #include <public/WebRTCStatsResponse.h> 42 43 #include <public/WebRTCVoidRequest.h> 43 44 #include <public/WebString.h> … … 84 85 class RTCStatsRequestSucceededTask : public MethodTask<MockWebRTCPeerConnectionHandler> { 85 86 public: 86 RTCStatsRequestSucceededTask(MockWebRTCPeerConnectionHandler* object, const WebKit::WebRTCStatsRequest& request) 87 : MethodTask<MockWebRTCPeerConnectionHandler>(object) 88 , m_request(request) 89 { 90 } 91 92 virtual void runIfValid() OVERRIDE 93 { 94 m_request.requestSucceeded(); 87 RTCStatsRequestSucceededTask(MockWebRTCPeerConnectionHandler* object, const WebKit::WebRTCStatsRequest& request, const WebKit::WebRTCStatsResponse& response) 88 : MethodTask<MockWebRTCPeerConnectionHandler>(object) 89 , m_request(request) 90 , m_response(response) 91 { 92 } 93 94 virtual void runIfValid() OVERRIDE 95 { 96 m_request.requestSucceeded(m_response); 95 97 } 96 98 97 99 private: 98 100 WebKit::WebRTCStatsRequest m_request; 101 WebKit::WebRTCStatsResponse m_response; 99 102 }; 100 103 … … 125 128 MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler(WebRTCPeerConnectionHandlerClient* client) 126 129 : m_client(client) 130 , m_streamCount(0) 127 131 { 128 132 } … … 196 200 bool MockWebRTCPeerConnectionHandler::addStream(const WebMediaStreamDescriptor& stream, const WebMediaConstraints&) 197 201 { 202 m_streamCount += 1; 198 203 m_client->didAddRemoteStream(stream); 199 204 m_client->negotiationNeeded(); … … 203 208 void MockWebRTCPeerConnectionHandler::removeStream(const WebMediaStreamDescriptor& stream) 204 209 { 210 m_streamCount -= 1; 205 211 m_client->didRemoveRemoteStream(stream); 206 212 m_client->negotiationNeeded(); … … 209 215 void MockWebRTCPeerConnectionHandler::getStats(const WebRTCStatsRequest& request) 210 216 { 211 postTask(new RTCStatsRequestSucceededTask(this, request)); 212 } 213 217 WebRTCStatsResponse response = request.createResponse(); 218 for (int i = 0; i < m_streamCount; ++i) { 219 size_t reportIndex = response.addReport(); 220 size_t elementIndex = response.addElement(reportIndex, true, 12345); 221 response.addStatistic(reportIndex, true, elementIndex, "type", "audio"); 222 reportIndex = response.addReport(); 223 elementIndex = response.addElement(reportIndex, true, 12345); 224 response.addStatistic(reportIndex, true, elementIndex, "type", "video"); 225 } 226 postTask(new RTCStatsRequestSucceededTask(this, request, response)); 227 } 214 228 215 229 void MockWebRTCPeerConnectionHandler::stop() -
trunk/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h
r129908 r130260 73 73 WebKit::WebRTCSessionDescription m_localDescription; 74 74 WebKit::WebRTCSessionDescription m_remoteDescription; 75 int m_streamCount; 75 76 }; 76 77
Note: See TracChangeset
for help on using the changeset viewer.