Commit b114d60b authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Replace uses of WebRTCStatsRequest by RTCStatsRequest

The later is a base class for RTCStatsRequestImpl (in
renderer/platform/peerconnection), and the former ceases to exist.

BUG=787254, 919392
R=guidou@chromium.org, haraken@chromium.org

Change-Id: Ie11697b7c602a5fdaac96a15e6ecc6a5dc904863
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1929523Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#718844}
parent cfdbb756
......@@ -271,7 +271,6 @@ source_set("blink_headers") {
"platform/web_rtc_rtp_source.h",
"platform/web_rtc_rtp_transceiver.h",
"platform/web_rtc_stats.h",
"platform/web_rtc_stats_request.h",
"platform/web_runtime_features.h",
"platform/web_scoped_page_pauser.h",
"platform/web_screen_info.h",
......
......@@ -59,7 +59,7 @@ class WebLocalFrame;
class WebMediaConstraints;
class WebMediaStream;
class WebMediaStreamTrack;
class WebRTCStatsRequest;
class RTCStatsRequest;
class WebString;
struct RTCDataChannelInitPlatform;
......@@ -117,7 +117,7 @@ class WebRTCPeerConnectionHandler {
virtual void AddICECandidate(RTCVoidRequest*,
scoped_refptr<RTCIceCandidatePlatform>) = 0;
virtual void RestartIce() = 0;
virtual void GetStats(const WebRTCStatsRequest&) = 0;
virtual void GetStats(RTCStatsRequest*) = 0;
// Gets stats using the new stats collection API, see
// third_party/webrtc/api/stats/. These will replace the old stats collection
// API when the new API has matured enough.
......
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_STATS_REQUEST_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_STATS_REQUEST_H_
#include "third_party/blink/public/platform/web_common.h"
#include "third_party/blink/public/platform/web_private_ptr.h"
#include "third_party/blink/public/platform/web_string.h"
namespace blink {
class RTCStatsRequest;
class WebMediaStreamTrack;
class RTCStatsResponseBase;
// The WebRTCStatsRequest class represents a JavaScript call on
// RTCPeerConnection.getStats(). The user of this API will use
// the calls on this class and RTCStatsResponseBase to fill in the
// data that will be returned via a callback to the user in an
// RTCStatsResponse structure.
//
// The typical usage pattern is:
// WebRTCStatsRequest request = <from somewhere>
// RTCStatsResponseBase* response = request.CreateResponse();
//
// For each item on which statistics are going to be reported:
// WebRTCLegacyStats stats(...);
// (configuration of stats object depends on item type)
// response.AddStats(stats);
// When finished adding information:
// request.RequestSucceeded(response);
class WebRTCStatsRequest {
public:
WebRTCStatsRequest() = default;
WebRTCStatsRequest(const WebRTCStatsRequest& other) { Assign(other); }
~WebRTCStatsRequest() { Reset(); }
WebRTCStatsRequest& operator=(const WebRTCStatsRequest& other) {
Assign(other);
return *this;
}
BLINK_PLATFORM_EXPORT void Assign(const WebRTCStatsRequest&);
BLINK_PLATFORM_EXPORT void Reset();
// This function returns true if a selector argument was given to getStats.
BLINK_PLATFORM_EXPORT bool HasSelector() const;
// The Component() accessor give the information
// required to look up a MediaStreamTrack implementation.
// It is only useful to call it when HasSelector() returns true.
BLINK_PLATFORM_EXPORT const WebMediaStreamTrack Component() const;
BLINK_PLATFORM_EXPORT void RequestSucceeded(RTCStatsResponseBase*) const;
BLINK_PLATFORM_EXPORT RTCStatsResponseBase* CreateResponse() const;
#if INSIDE_BLINK
BLINK_PLATFORM_EXPORT WebRTCStatsRequest(RTCStatsRequest*);
#endif
private:
WebPrivatePtr<RTCStatsRequest, kWebPrivatePtrDestructionCrossThread> private_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RTC_STATS_REQUEST_H_
......@@ -329,7 +329,7 @@ void MockWebRTCPeerConnectionHandler::AddICECandidate(
void MockWebRTCPeerConnectionHandler::RestartIce() {}
void MockWebRTCPeerConnectionHandler::GetStats(const WebRTCStatsRequest&) {}
void MockWebRTCPeerConnectionHandler::GetStats(RTCStatsRequest*) {}
void MockWebRTCPeerConnectionHandler::GetStats(
blink::WebRTCStatsReportCallback,
......
......@@ -56,7 +56,7 @@ class MockWebRTCPeerConnectionHandler : public WebRTCPeerConnectionHandler {
void AddICECandidate(RTCVoidRequest*,
scoped_refptr<RTCIceCandidatePlatform>) override;
void RestartIce() override;
void GetStats(const WebRTCStatsRequest&) override;
void GetStats(RTCStatsRequest*) override;
void GetStats(WebRTCStatsReportCallback,
const WebVector<webrtc::NonStandardGroupId>&) override;
webrtc::RTCErrorOr<std::unique_ptr<WebRTCRtpTransceiver>>
......
......@@ -45,7 +45,6 @@
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_crypto_algorithm_params.h"
#include "third_party/blink/public/platform/web_media_stream.h"
#include "third_party/blink/public/platform/web_rtc_stats_request.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
......@@ -117,6 +116,7 @@
#include "third_party/blink/renderer/platform/peerconnection/rtc_offer_options_platform.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_session_description_platform.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats_request.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_void_request.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
......
......@@ -622,28 +622,29 @@ bool IsHostnameCandidate(const RTCIceCandidatePlatform& candidate) {
} // namespace
// Implementation of LocalRTCStatsRequest.
LocalRTCStatsRequest::LocalRTCStatsRequest(blink::WebRTCStatsRequest impl)
LocalRTCStatsRequest::LocalRTCStatsRequest(RTCStatsRequest* impl)
: impl_(impl) {}
LocalRTCStatsRequest::LocalRTCStatsRequest() {}
LocalRTCStatsRequest::~LocalRTCStatsRequest() {}
bool LocalRTCStatsRequest::hasSelector() const {
return impl_.HasSelector();
return impl_->HasSelector();
}
blink::WebMediaStreamTrack LocalRTCStatsRequest::component() const {
return impl_.Component();
return impl_->Component();
}
scoped_refptr<LocalRTCStatsResponse> LocalRTCStatsRequest::createResponse() {
return scoped_refptr<LocalRTCStatsResponse>(
new rtc::RefCountedObject<LocalRTCStatsResponse>(impl_.CreateResponse()));
new rtc::RefCountedObject<LocalRTCStatsResponse>(
impl_->CreateResponse()));
}
void LocalRTCStatsRequest::requestSucceeded(
const LocalRTCStatsResponse* response) {
impl_.RequestSucceeded(response->webKitStatsResponse());
impl_->RequestSucceeded(response->webKitStatsResponse());
}
// Implementation of LocalRTCStatsResponse.
......@@ -1629,8 +1630,7 @@ void RTCPeerConnectionHandler::GetStandardStatsForTracker(
native_peer_connection_->GetStats(observer.get());
}
void RTCPeerConnectionHandler::GetStats(
const blink::WebRTCStatsRequest& request) {
void RTCPeerConnectionHandler::GetStats(RTCStatsRequest* request) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
scoped_refptr<LocalRTCStatsRequest> inner_request(
new rtc::RefCountedObject<LocalRTCStatsRequest>(request));
......
......@@ -20,13 +20,13 @@
#include "third_party/blink/public/platform/web_rtc_peer_connection_handler.h"
#include "third_party/blink/public/platform/web_rtc_peer_connection_handler_client.h"
#include "third_party/blink/public/platform/web_rtc_stats.h"
#include "third_party/blink/public/platform/web_rtc_stats_request.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/modules/peerconnection/media_stream_track_metrics.h"
#include "third_party/blink/renderer/modules/peerconnection/rtc_rtp_receiver_impl.h"
#include "third_party/blink/renderer/modules/peerconnection/rtc_rtp_sender_impl.h"
#include "third_party/blink/renderer/modules/peerconnection/transceiver_state_surfacer.h"
#include "third_party/blink/renderer/modules/peerconnection/webrtc_media_stream_track_adapter_map.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats_request.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats_response_base.h"
#include "third_party/webrtc/api/stats/rtc_stats.h"
#include "third_party/webrtc/api/stats/rtc_stats_collector_callback.h"
......@@ -59,10 +59,10 @@ class MODULES_EXPORT LocalRTCStatsResponse : public rtc::RefCountInterface {
Persistent<RTCStatsResponseBase> impl_;
};
// Mockable wrapper for blink::WebRTCStatsRequest
// Mockable wrapper for RTCStatsRequest
class MODULES_EXPORT LocalRTCStatsRequest : public rtc::RefCountInterface {
public:
explicit LocalRTCStatsRequest(blink::WebRTCStatsRequest impl);
explicit LocalRTCStatsRequest(RTCStatsRequest* impl);
// Constructor for testing.
LocalRTCStatsRequest();
......@@ -75,7 +75,7 @@ class MODULES_EXPORT LocalRTCStatsRequest : public rtc::RefCountInterface {
~LocalRTCStatsRequest() override;
private:
blink::WebRTCStatsRequest impl_;
CrossThreadPersistent<RTCStatsRequest> impl_;
};
// RTCPeerConnectionHandler is a delegate for the RTC PeerConnection API
......@@ -143,7 +143,7 @@ class MODULES_EXPORT RTCPeerConnectionHandler
scoped_refptr<RTCIceCandidatePlatform> candidate) override;
void RestartIce() override;
void GetStats(const blink::WebRTCStatsRequest& request) override;
void GetStats(RTCStatsRequest* request) override;
void GetStats(blink::WebRTCStatsReportCallback callback,
const blink::WebVector<webrtc::NonStandardGroupId>&
exposed_group_ids) override;
......
......@@ -32,7 +32,6 @@
#include "third_party/blink/public/platform/web_rtc_peer_connection_handler_client.h"
#include "third_party/blink/public/platform/web_rtc_rtp_receiver.h"
#include "third_party/blink/public/platform/web_rtc_stats.h"
#include "third_party/blink/public/platform/web_rtc_stats_request.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/public/web/web_heap.h"
......@@ -52,6 +51,7 @@
#include "third_party/blink/renderer/platform/peerconnection/rtc_ice_candidate_platform.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_session_description_platform.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats_request.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_void_request.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
......@@ -100,7 +100,7 @@ class MockRTCStatsResponse : public LocalRTCStatsResponse {
int statistic_count_;
};
// Mocked wrapper for blink::WebRTCStatsRequest
// Mocked wrapper for RTCStatsRequest
class MockRTCStatsRequest : public LocalRTCStatsRequest {
public:
MockRTCStatsRequest()
......
......@@ -534,7 +534,6 @@ jumbo_component("platform") {
"exported/web_rtc_rtp_source.cc",
"exported/web_rtc_rtp_transceiver.cc",
"exported/web_rtc_stats.cc",
"exported/web_rtc_stats_request.cc",
"exported/web_runtime_features.cc",
"exported/web_security_origin.cc",
"exported/web_string.cc",
......
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "third_party/blink/public/platform/web_rtc_stats_request.h"
#include "third_party/blink/public/platform/web_media_stream.h"
#include "third_party/blink/public/platform/web_media_stream_track.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats_request.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats_response_base.h"
namespace blink {
WebRTCStatsRequest::WebRTCStatsRequest(RTCStatsRequest* request)
: private_(request) {}
void WebRTCStatsRequest::Assign(const WebRTCStatsRequest& other) {
private_ = other.private_;
}
void WebRTCStatsRequest::Reset() {
private_.Reset();
}
RTCStatsResponseBase* WebRTCStatsRequest::CreateResponse() const {
return private_->CreateResponse();
}
bool WebRTCStatsRequest::HasSelector() const {
return private_->HasSelector();
}
const WebMediaStreamTrack WebRTCStatsRequest::Component() const {
return WebMediaStreamTrack(private_->Component());
}
void WebRTCStatsRequest::RequestSucceeded(
RTCStatsResponseBase* response) const {
private_->RequestSucceeded(response);
}
} // namespace blink
......@@ -40,12 +40,37 @@ namespace blink {
class MediaStreamComponent;
class RTCStatsResponseBase;
// TODO(crbug.com/787254): Merge RTCStatsRequest and RTCStatsRequestImpl
// when the former is not referenced in renderer/platform anymore.
//
// The RTCStatsRequest class represents a JavaScript call on
// RTCPeerConnection.getStats(). The user of this API will use
// the calls on this class and RTCStatsResponseBase to fill in the
// data that will be returned via a callback to the user in an
// RTCStatsResponse structure.
//
// The typical usage pattern is:
// RTCStatsRequest* request = <from somewhere>
// RTCStatsResponseBase* response = request->CreateResponse();
//
// For each item on which statistics are going to be reported:
// WebRTCLegacyStats stats(...);
// (configuration of stats object depends on item type)
// response.AddStats(stats);
// When finished adding information:
// request->RequestSucceeded(response);
class RTCStatsRequest : public GarbageCollected<RTCStatsRequest> {
public:
virtual ~RTCStatsRequest() = default;
virtual RTCStatsResponseBase* CreateResponse() = 0;
// This function returns true if a selector argument was given to getStats.
virtual bool HasSelector() = 0;
// The Component() accessor give the information
// required to look up a MediaStreamTrack implementation.
// It is only useful to call it when HasSelector() returns true.
virtual MediaStreamComponent* Component() = 0;
virtual void RequestSucceeded(RTCStatsResponseBase*) = 0;
......
......@@ -31,6 +31,8 @@
namespace blink {
// TODO(crbug.com/787254): Merge RTCStatsResponseBase and RTCStatsResponse
// when the former is not referenced in renderer/platform anymore.
class RTCStatsResponseBase : public ScriptWrappable {
public:
~RTCStatsResponseBase() override = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment