ice_transport.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2019 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  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. #ifndef PC_ICE_TRANSPORT_H_
  11. #define PC_ICE_TRANSPORT_H_
  12. #include "api/ice_transport_interface.h"
  13. #include "rtc_base/constructor_magic.h"
  14. #include "rtc_base/thread.h"
  15. #include "rtc_base/thread_checker.h"
  16. namespace webrtc {
  17. // Implementation of IceTransportInterface that does not take ownership
  18. // of its underlying IceTransport. It depends on its creator class to
  19. // ensure that Clear() is called before the underlying IceTransport
  20. // is deallocated.
  21. class IceTransportWithPointer : public IceTransportInterface {
  22. public:
  23. explicit IceTransportWithPointer(cricket::IceTransportInternal* internal)
  24. : creator_thread_(rtc::Thread::Current()), internal_(internal) {
  25. RTC_DCHECK(internal_);
  26. }
  27. cricket::IceTransportInternal* internal() override;
  28. // This call will ensure that the pointer passed at construction is
  29. // no longer in use by this object. Later calls to internal() will return
  30. // null.
  31. void Clear();
  32. protected:
  33. ~IceTransportWithPointer() override;
  34. private:
  35. RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(IceTransportWithPointer);
  36. const rtc::Thread* creator_thread_;
  37. cricket::IceTransportInternal* internal_ RTC_GUARDED_BY(creator_thread_);
  38. };
  39. } // namespace webrtc
  40. #endif // PC_ICE_TRANSPORT_H_