Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: webrtc/p2p/base/fakesession.h

Issue 1304043008: Replacing SSLIdentity* with scoped_refptr<RTCCertificate> in TransportChannel layer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Making overriding "virtual" methods use the override keyword Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel_unittest.cc ('k') | webrtc/p2p/base/p2ptransportchannel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/fakesession.h
diff --git a/webrtc/p2p/base/fakesession.h b/webrtc/p2p/base/fakesession.h
index 5597a44dface14acd8ef4944596a42fc5c6830e8..bd3c08902508fafc1cf414db3fecbb2d141e48bf 100644
--- a/webrtc/p2p/base/fakesession.h
+++ b/webrtc/p2p/base/fakesession.h
@@ -47,15 +47,14 @@ class FakeTransportChannel : public TransportChannelImpl,
int component)
: TransportChannelImpl(content_name, component),
transport_(transport),
- dest_(NULL),
+ dest_(nullptr),
state_(STATE_INIT),
async_(false),
- identity_(NULL),
do_dtls_(false),
role_(ICEROLE_UNKNOWN),
tiebreaker_(0),
remote_ice_mode_(ICEMODE_FULL),
- dtls_fingerprint_("", NULL, 0),
+ dtls_fingerprint_("", nullptr, 0),
ssl_role_(rtc::SSL_CLIENT),
connection_count_(0) {
}
@@ -77,11 +76,11 @@ class FakeTransportChannel : public TransportChannelImpl,
async_ = async;
}
- virtual Transport* GetTransport() {
+ Transport* GetTransport() override {
return transport_;
}
- virtual TransportChannelState GetState() const {
+ TransportChannelState GetState() const override {
if (connection_count_ == 0) {
return TransportChannelState::STATE_FAILED;
}
@@ -93,36 +92,38 @@ class FakeTransportChannel : public TransportChannelImpl,
return TransportChannelState::STATE_FAILED;
}
- virtual void SetIceRole(IceRole role) { role_ = role; }
- virtual IceRole GetIceRole() const { return role_; }
- virtual void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; }
- virtual void SetIceCredentials(const std::string& ice_ufrag,
- const std::string& ice_pwd) {
+ void SetIceRole(IceRole role) override { role_ = role; }
+ IceRole GetIceRole() const override { return role_; }
+ void SetIceTiebreaker(uint64 tiebreaker) override {
+ tiebreaker_ = tiebreaker;
+ }
+ void SetIceCredentials(const std::string& ice_ufrag,
+ const std::string& ice_pwd) override {
ice_ufrag_ = ice_ufrag;
ice_pwd_ = ice_pwd;
}
- virtual void SetRemoteIceCredentials(const std::string& ice_ufrag,
- const std::string& ice_pwd) {
+ void SetRemoteIceCredentials(const std::string& ice_ufrag,
+ const std::string& ice_pwd) override {
remote_ice_ufrag_ = ice_ufrag;
remote_ice_pwd_ = ice_pwd;
}
- virtual void SetRemoteIceMode(IceMode mode) { remote_ice_mode_ = mode; }
- virtual bool SetRemoteFingerprint(const std::string& alg, const uint8* digest,
- size_t digest_len) {
+ void SetRemoteIceMode(IceMode mode) override { remote_ice_mode_ = mode; }
+ bool SetRemoteFingerprint(const std::string& alg, const uint8* digest,
+ size_t digest_len) override {
dtls_fingerprint_ = rtc::SSLFingerprint(alg, digest, digest_len);
return true;
}
- virtual bool SetSslRole(rtc::SSLRole role) {
+ bool SetSslRole(rtc::SSLRole role) override {
ssl_role_ = role;
return true;
}
- virtual bool GetSslRole(rtc::SSLRole* role) const {
+ bool GetSslRole(rtc::SSLRole* role) const override {
*role = ssl_role_;
return true;
}
- virtual void Connect() {
+ void Connect() override {
if (state_ == STATE_INIT) {
state_ = STATE_CONNECTING;
}
@@ -147,7 +148,7 @@ class FakeTransportChannel : public TransportChannelImpl,
// This simulates the delivery of candidates.
dest_ = dest;
dest_->dest_ = this;
- if (identity_ && dest_->identity_) {
+ if (certificate_ && dest_->certificate_) {
do_dtls_ = true;
dest_->do_dtls_ = true;
NegotiateSrtpCiphers();
@@ -177,8 +178,8 @@ class FakeTransportChannel : public TransportChannelImpl,
void SetReceivingTimeout(int timeout) override {}
- virtual int SendPacket(const char* data, size_t len,
- const rtc::PacketOptions& options, int flags) {
+ int SendPacket(const char* data, size_t len,
+ const rtc::PacketOptions& options, int flags) override {
if (state_ != STATE_CONNECTED) {
return -1;
}
@@ -195,22 +196,22 @@ class FakeTransportChannel : public TransportChannelImpl,
}
return static_cast<int>(len);
}
- virtual int SetOption(rtc::Socket::Option opt, int value) {
+ int SetOption(rtc::Socket::Option opt, int value) override {
return true;
}
- virtual bool GetOption(rtc::Socket::Option opt, int* value) {
+ bool GetOption(rtc::Socket::Option opt, int* value) override {
return true;
}
- virtual int GetError() {
+ int GetError() override {
return 0;
}
- virtual void OnSignalingReady() {
+ void OnSignalingReady() override {
}
- virtual void OnCandidate(const Candidate& candidate) {
+ void OnCandidate(const Candidate& candidate) override {
}
- virtual void OnMessage(rtc::Message* msg) {
+ void OnMessage(rtc::Message* msg) override {
PacketMessageData* data = static_cast<PacketMessageData*>(
msg->pdata);
dest_->SignalReadPacket(dest_, data->packet.data<char>(),
@@ -218,26 +219,26 @@ class FakeTransportChannel : public TransportChannelImpl,
delete data;
}
- bool SetLocalIdentity(rtc::SSLIdentity* identity) {
- identity_ = identity;
+ bool SetLocalCertificate(
+ const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override {
+ certificate_ = certificate;
return true;
}
-
- void SetRemoteCertificate(rtc::FakeSSLCertificate* cert) {
+ void SetRemoteSSLCertificate(rtc::FakeSSLCertificate* cert) {
remote_cert_ = cert;
}
- virtual bool IsDtlsActive() const {
+ bool IsDtlsActive() const override {
return do_dtls_;
}
- virtual bool SetSrtpCiphers(const std::vector<std::string>& ciphers) {
+ bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override {
srtp_ciphers_ = ciphers;
return true;
}
- virtual bool GetSrtpCipher(std::string* cipher) {
+ bool GetSrtpCipher(std::string* cipher) override {
if (!chosen_srtp_cipher_.empty()) {
*cipher = chosen_srtp_cipher_;
return true;
@@ -245,19 +246,16 @@ class FakeTransportChannel : public TransportChannelImpl,
return false;
}
- virtual bool GetSslCipher(std::string* cipher) {
+ bool GetSslCipher(std::string* cipher) override {
return false;
}
- virtual bool GetLocalIdentity(rtc::SSLIdentity** identity) const {
- if (!identity_)
- return false;
-
- *identity = identity_->GetReference();
- return true;
+ rtc::scoped_refptr<rtc::RTCCertificate>
+ GetLocalCertificate() const override {
+ return certificate_;
}
- virtual bool GetRemoteCertificate(rtc::SSLCertificate** cert) const {
+ bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override {
if (!remote_cert_)
return false;
@@ -265,12 +263,12 @@ class FakeTransportChannel : public TransportChannelImpl,
return true;
}
- virtual bool ExportKeyingMaterial(const std::string& label,
- const uint8* context,
- size_t context_len,
- bool use_context,
- uint8* result,
- size_t result_len) {
+ bool ExportKeyingMaterial(const std::string& label,
+ const uint8* context,
+ size_t context_len,
+ bool use_context,
+ uint8* result,
+ size_t result_len) override {
if (!chosen_srtp_cipher_.empty()) {
memset(result, 0xff, result_len);
return true;
@@ -307,7 +305,7 @@ class FakeTransportChannel : public TransportChannelImpl,
FakeTransportChannel* dest_;
State state_;
bool async_;
- rtc::SSLIdentity* identity_;
+ rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
rtc::FakeSSLCertificate* remote_cert_;
bool do_dtls_;
std::vector<std::string> srtp_ciphers_;
@@ -350,9 +348,7 @@ class FakeTransport : public Transport {
dest_ = dest;
for (ChannelMap::iterator it = channels_.begin(); it != channels_.end();
++it) {
- // TODO(hbos): SetLocalCertificate
- it->second->SetLocalIdentity(
- certificate_ ? certificate_->identity() : nullptr);
+ it->second->SetLocalCertificate(certificate_);
SetChannelDestination(it->first, it->second);
}
}
@@ -373,7 +369,7 @@ class FakeTransport : public Transport {
using Transport::remote_description;
protected:
- virtual TransportChannelImpl* CreateTransportChannel(int component) {
+ TransportChannelImpl* CreateTransportChannel(int component) override {
if (channels_.find(component) != channels_.end()) {
return NULL;
}
@@ -384,7 +380,7 @@ class FakeTransport : public Transport {
channels_[component] = channel;
return channel;
}
- virtual void DestroyTransportChannel(TransportChannelImpl* channel) {
+ void DestroyTransportChannel(TransportChannelImpl* channel) override {
channels_.erase(channel->component());
delete channel;
}
@@ -411,11 +407,8 @@ class FakeTransport : public Transport {
FakeTransportChannel* dest_channel = NULL;
if (dest_) {
dest_channel = dest_->GetFakeChannel(component);
- if (dest_channel) {
- // TODO(hbos): SetLocalCertificate
- dest_channel->SetLocalIdentity(
- dest_->certificate_ ? dest_->certificate_->identity() : nullptr);
- }
+ if (dest_channel)
+ dest_channel->SetLocalCertificate(dest_->certificate_);
}
channel->SetDestination(dest_channel);
}
@@ -467,9 +460,8 @@ class FakeSession : public BaseSession {
}
}
- virtual TransportChannel* CreateChannel(
- const std::string& content_name,
- int component) {
+ TransportChannel* CreateChannel(const std::string& content_name,
+ int component) override {
if (fail_create_channel_) {
return NULL;
}
@@ -493,7 +485,7 @@ class FakeSession : public BaseSession {
}
protected:
- virtual Transport* CreateTransport(const std::string& content_name) {
+ Transport* CreateTransport(const std::string& content_name) override {
return new FakeTransport(signaling_thread(), worker_thread(), content_name);
}
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel_unittest.cc ('k') | webrtc/p2p/base/p2ptransportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698