Deprecate owned naked pointers to cricket::SessionDescription

Recommended usage is to create copies with Clone() and to
call JsepSessionDescription::Initialize using std::move.

Bug: webrtc:10612
Change-Id: I626a08a35ba8e112471cec0374c944e96f8effbc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135941
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27911}
This commit is contained in:
Harald Alvestrand 2019-05-10 09:31:04 +02:00 committed by Commit Bot
parent 0da11562dc
commit 8da35a60ab
4 changed files with 15 additions and 11 deletions

View File

@ -23,6 +23,7 @@
#include "api/jsep.h"
#include "api/jsep_ice_candidate.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/deprecation.h"
namespace cricket {
class SessionDescription;
@ -47,8 +48,8 @@ class JsepSessionDescription : public SessionDescriptionInterface {
bool Initialize(std::unique_ptr<cricket::SessionDescription> description,
const std::string& session_id,
const std::string& session_version);
// Backwards compatible version. To be deprecated.
bool Initialize(cricket::SessionDescription* description,
// Backwards compatible version. Replace with version above.
RTC_DEPRECATED bool Initialize(cricket::SessionDescription* description,
const std::string& session_id,
const std::string& session_version);

View File

@ -95,6 +95,7 @@ rtc_static_library("rtc_pc_base") {
"../p2p:rtc_p2p",
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:deprecation",
"../rtc_base:rtc_task_queue",
"../rtc_base:stringutils",
"../rtc_base/third_party/base64",

View File

@ -29,6 +29,7 @@
#include "p2p/base/transport_info.h"
#include "pc/media_protocol_names.h"
#include "pc/simulcast_description.h"
#include "rtc_base/deprecation.h"
#include "rtc_base/socket_address.h"
namespace cricket {
@ -598,8 +599,9 @@ class SessionDescription {
~SessionDescription();
std::unique_ptr<SessionDescription> Clone() const;
// Older API - to be deprecated. Still expects caller to take ownership.
SessionDescription* Copy() const;
// Older API - deprecated. Still expects caller to take ownership.
// Replace with Clone().
RTC_DEPRECATED SessionDescription* Copy() const;
struct MediaTransportSetting;

View File

@ -2239,12 +2239,12 @@ void MutateJsepSctpPort(JsepSessionDescription* jdesc,
const SessionDescription& desc,
int port) {
// Take our pre-built session description and change the SCTP port.
cricket::SessionDescription* mutant = desc.Copy();
std::unique_ptr<cricket::SessionDescription> mutant = desc.Clone();
SctpDataContentDescription* dcdesc =
mutant->GetContentDescriptionByName(kDataContentName)->as_sctp();
dcdesc->set_port(port);
// Note: mutant's owned by jdesc now.
ASSERT_TRUE(jdesc->Initialize(mutant, kSessionId, kSessionVersion));
ASSERT_TRUE(
jdesc->Initialize(std::move(mutant), kSessionId, kSessionVersion));
}
TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) {
@ -2895,11 +2895,11 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpColonPort) {
void MutateJsepSctpMaxMessageSize(const SessionDescription& desc,
int new_value,
JsepSessionDescription* jdesc) {
cricket::SessionDescription* mutant = desc.Copy();
std::unique_ptr<cricket::SessionDescription> mutant = desc.Clone();
SctpDataContentDescription* dcdesc =
mutant->GetContentDescriptionByName(kDataContentName)->as_sctp();
dcdesc->set_max_message_size(new_value);
jdesc->Initialize(mutant, kSessionId, kSessionVersion);
jdesc->Initialize(std::move(mutant), kSessionId, kSessionVersion);
}
TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithMaxMessageSize) {