| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #ifndef PC_ICE_TRANSPORT_H_ |
| 12 | #define PC_ICE_TRANSPORT_H_ |
| 13 |
| 14 | #include "api/ice_transport_interface.h" |
| 15 | #include "rtc_base/checks.h" |
| 16 | #include "rtc_base/thread.h" |
| 17 | #include "rtc_base/thread_annotations.h" |
| 18 |
| 19 | namespace webrtc { |
| 20 |
| 21 | // Implementation of IceTransportInterface that does not take ownership |
| 22 | // of its underlying IceTransport. It depends on its creator class to |
| 23 | // ensure that Clear() is called before the underlying IceTransport |
| 24 | // is deallocated. |
| 25 | class IceTransportWithPointer : public IceTransportInterface { |
| 26 | public: |
| 27 | explicit IceTransportWithPointer(cricket::IceTransportInternal* internal) |
| 28 | : creator_thread_(rtc::Thread::Current()), internal_(internal) { |
| 29 | RTC_DCHECK(internal_); |
| 30 | } |
| 31 |
| 32 | IceTransportWithPointer() = delete; |
| 33 | IceTransportWithPointer(const IceTransportWithPointer&) = delete; |
| 34 | IceTransportWithPointer& operator=(const IceTransportWithPointer&) = delete; |
| 35 |
| 36 | cricket::IceTransportInternal* internal() override; |
| 37 | // This call will ensure that the pointer passed at construction is |
| 38 | // no longer in use by this object. Later calls to internal() will return |
| 39 | // null. |
| 40 | void Clear(); |
| 41 |
| 42 | protected: |
| 43 | ~IceTransportWithPointer() override; |
| 44 |
| 45 | private: |
| 46 | const rtc::Thread* creator_thread_; |
| 47 | cricket::IceTransportInternal* internal_ RTC_GUARDED_BY(creator_thread_); |
| 48 | }; |
| 49 |
| 50 | } // namespace webrtc |
| 51 |
| 52 | #endif // PC_ICE_TRANSPORT_H_ |
| 53 |