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

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

Issue 2571683004: Fixing possible crash due to RefCountedChannel assignment operator. (Closed)
Patch Set: Use RefCountedObject instead of custom class. Created 4 years 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 | « no previous file | webrtc/p2p/base/transportcontroller.cc » ('j') | webrtc/p2p/base/transportcontroller.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/transportcontroller.h
diff --git a/webrtc/p2p/base/transportcontroller.h b/webrtc/p2p/base/transportcontroller.h
index cdac4b6dcb5e72a08761a593b02d2f5fae9812c5..b95a020c8daa099fe17b62b2396dc2eace6d5559 100644
--- a/webrtc/p2p/base/transportcontroller.h
+++ b/webrtc/p2p/base/transportcontroller.h
@@ -17,6 +17,8 @@
#include <vector>
#include "webrtc/base/asyncinvoker.h"
+#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/refcountedobject.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/p2p/base/candidate.h"
@@ -163,44 +165,15 @@ class TransportController : public sigslot::has_slots<>,
private:
void OnMessage(rtc::Message* pmsg) override;
- // This structure groups the DTLS and ICE channels, and helps keep track of
- // how many external objects (BaseChannels) reference each channel.
- struct RefCountedChannel {
- RefCountedChannel() = default;
- // TODO(deadbeef): Change the types of |dtls| and |ice| to
- // DtlsTransportChannelWrapper and P2PTransportChannelWrapper,
- // once TransportChannelImpl is removed.
- explicit RefCountedChannel(TransportChannelImpl* dtls,
- TransportChannelImpl* ice)
- : ice_(ice), dtls_(dtls), ref_(0) {}
-
- void AddRef() { ++ref_; }
- void DecRef() {
- ASSERT(ref_ > 0);
- --ref_;
- }
- int ref() const { return ref_; }
-
- // Currently, all ICE-related calls still go through this DTLS channel. But
- // that will change once we get rid of TransportChannelImpl, and the DTLS
- // channel interface no longer includes ICE-specific methods.
- const TransportChannelImpl* dtls() const { return dtls_.get(); }
- TransportChannelImpl* dtls() { return dtls_.get(); }
- const TransportChannelImpl* ice() const { return ice_.get(); }
- TransportChannelImpl* ice() { return ice_.get(); }
-
- private:
- std::unique_ptr<TransportChannelImpl> ice_;
- std::unique_ptr<TransportChannelImpl> dtls_;
- int ref_ = 0;
- };
+ class ChannelPair;
+ typedef rtc::RefCountedObject<ChannelPair> RefCountedChannel;
// Helper functions to get a channel or transport, or iterator to it (in case
// it needs to be erased).
- std::vector<RefCountedChannel>::iterator GetChannelIterator_n(
+ std::vector<RefCountedChannel*>::iterator GetChannelIterator_n(
const std::string& transport_name,
int component);
- std::vector<RefCountedChannel>::const_iterator GetChannelIterator_n(
+ std::vector<RefCountedChannel*>::const_iterator GetChannelIterator_n(
const std::string& transport_name,
int component) const;
const JsepTransport* GetJsepTransport_n(
@@ -264,7 +237,7 @@ class TransportController : public sigslot::has_slots<>,
PortAllocator* const port_allocator_ = nullptr;
std::map<std::string, std::unique_ptr<JsepTransport>> transports_;
- std::vector<RefCountedChannel> channels_;
+ std::vector<RefCountedChannel*> channels_;
// Aggregate state for TransportChannelImpls.
IceConnectionState connection_state_ = kIceConnectionConnecting;
@@ -282,6 +255,8 @@ class TransportController : public sigslot::has_slots<>,
bool quic_ = false;
webrtc::MetricsObserverInterface* metrics_observer_ = nullptr;
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(TransportController);
};
} // namespace cricket
« no previous file with comments | « no previous file | webrtc/p2p/base/transportcontroller.cc » ('j') | webrtc/p2p/base/transportcontroller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698