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

Side by Side Diff: webrtc/base/keep_ref_until_done.h

Issue 1487493002: Add helper KeepRefUntilDone (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments. Now uses RefCountedInterface instead of a template. Created 5 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 unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698