Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2015 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 | |
| 11 #ifndef WEBRTC_BASE_KEEP_REF_UNTIL_DONE_H_ | |
| 12 #define WEBRTC_BASE_KEEP_REF_UNTIL_DONE_H_ | |
| 13 | |
| 14 #include "webrtc/base/bind.h" | |
| 15 #include "webrtc/base/callback.h" | |
| 16 #include "webrtc/base/refcount.h" | |
| 17 #include "webrtc/base/scoped_ref_ptr.h" | |
| 18 | |
| 19 namespace rtc { | |
| 20 | |
| 21 namespace impl { | |
| 22 static inline void DoNothing(const scoped_refptr<RefCountInterface>& object) {} | |
| 23 } // namespace impl | |
| 24 | |
| 25 // KeepRefUntilDone keeps a reference to |object| until the returned | |
| 26 // callback goes out of scope. If the returned callback is copied, the | |
| 27 // reference will be released when the last callback goes out of scope. | |
| 28 static inline Callback0<void> KeepRefUntilDone(RefCountInterface* object) { | |
|
tommi
2015/11/30 13:05:01
I actually kinda liked having the same compatibili
magjed_webrtc
2015/11/30 15:41:52
If you don't put this definition in a cc file, you
| |
| 29 return rtc::Bind(&impl::DoNothing, scoped_refptr<RefCountInterface>(object)); | |
| 30 } | |
| 31 | |
| 32 } // namespace rtc | |
| 33 | |
| 34 | |
| 35 #endif // WEBRTC_BASE_KEEP_REF_UNTIL_DONE_H_ | |
| OLD | NEW |