Chromium Code Reviews| Index: webrtc/base/release_when_done_callback.h |
| diff --git a/webrtc/base/release_when_done_callback.h b/webrtc/base/release_when_done_callback.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e764e257eb4bbb10158cbfa0d8fd9f4e92f8ea45 |
| --- /dev/null |
| +++ b/webrtc/base/release_when_done_callback.h |
| @@ -0,0 +1,36 @@ |
| +/* |
| + * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
|
mflodman
2015/11/30 08:45:10
s/2004/2015
perkj_webrtc
2015/11/30 12:54:19
Done.
|
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#ifndef WEBRTC_BASE_RELEASE_WHEN_DONE_CALLBACK_H_ |
| +#define WEBRTC_BASE_RELEASE_WHEN_DONE_CALLBACK_H_ |
| + |
| +#include "webrtc/base/bind.h" |
| +#include "webrtc/base/callback.h" |
| +#include "webrtc/base/scoped_ref_ptr.h" |
| + |
| +namespace rtc { |
| + |
| +namespace impl { |
| +template <class T> |
| +void ReleaseRef(const scoped_refptr<T>& object) {} |
|
magjed_webrtc
2015/11/30 09:22:17
Should this be a static function?
perkj_webrtc
2015/11/30 12:54:19
Done.
|
| +} // namespace impl |
| + |
| +// ReleaseWhenDoneCallback keeps a reference to |object| until the returned |
| +// callback goes out of scope. If the returned callback is copied, the |
| +// reference will be released when the last callback goes out of scope. |
| +template <class ObjectT> |
| +Callback0<void> ReleaseWhenDoneCallback(ObjectT* object) { |
|
tommi
2015/11/30 08:45:51
What's the difference between this implementation
magjed_webrtc
2015/11/30 09:22:17
The argument type should be const scoped_refptr<Ob
magjed_webrtc
2015/11/30 09:22:17
ditto: Should this be a static function?
perkj_webrtc
2015/11/30 12:54:19
Renamed.
The difference would be that the callbac
perkj_webrtc
2015/11/30 12:54:19
Done.
|
| + return rtc::Bind(&impl::ReleaseRef<ObjectT>, scoped_refptr<ObjectT>(object)); |
| +} |
| + |
| +} // namespace rtc |
| + |
| + |
| +#endif // WEBRTC_BASE_RELEASE_WHEN_DONE_CALLBACK_H_ |