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

Side by Side Diff: webrtc/base/asyncinvoker-inl.h

Issue 2689233003: Relanding: Use std::unique_ptr instead of rtc::scoped_refptr in AsyncInvoker. (Closed)
Patch Set: . Created 3 years, 10 months 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
« no previous file with comments | « webrtc/base/asyncinvoker.cc ('k') | webrtc/base/messagequeue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_ASYNCINVOKER_INL_H_ 11 #ifndef WEBRTC_BASE_ASYNCINVOKER_INL_H_
12 #define WEBRTC_BASE_ASYNCINVOKER_INL_H_ 12 #define WEBRTC_BASE_ASYNCINVOKER_INL_H_
13 13
14 #include "webrtc/base/bind.h" 14 #include "webrtc/base/bind.h"
15 #include "webrtc/base/callback.h" 15 #include "webrtc/base/callback.h"
16 #include "webrtc/base/criticalsection.h" 16 #include "webrtc/base/criticalsection.h"
17 #include "webrtc/base/messagehandler.h" 17 #include "webrtc/base/messagehandler.h"
18 #include "webrtc/base/refcount.h"
19 #include "webrtc/base/scoped_ref_ptr.h"
20 #include "webrtc/base/sigslot.h" 18 #include "webrtc/base/sigslot.h"
21 #include "webrtc/base/thread.h" 19 #include "webrtc/base/thread.h"
22 20
23 namespace rtc { 21 namespace rtc {
24 22
25 class AsyncInvoker; 23 class AsyncInvoker;
26 24
27 // Helper class for AsyncInvoker. Runs a task and triggers a callback 25 // Helper class for AsyncInvoker. Runs a task and triggers a callback
28 // on the calling thread if necessary. Instances are ref-counted so their 26 // on the calling thread if necessary.
29 // lifetime can be independent of AsyncInvoker. 27 class AsyncClosure {
30 class AsyncClosure : public RefCountInterface {
31 public: 28 public:
29 virtual ~AsyncClosure() {}
32 // Runs the asynchronous task, and triggers a callback to the calling 30 // Runs the asynchronous task, and triggers a callback to the calling
33 // thread if needed. Should be called from the target thread. 31 // thread if needed. Should be called from the target thread.
34 virtual void Execute() = 0; 32 virtual void Execute() = 0;
35 protected:
36 ~AsyncClosure() override {}
37 }; 33 };
38 34
39 // Simple closure that doesn't trigger a callback for the calling thread. 35 // Simple closure that doesn't trigger a callback for the calling thread.
40 template <class FunctorT> 36 template <class FunctorT>
41 class FireAndForgetAsyncClosure : public AsyncClosure { 37 class FireAndForgetAsyncClosure : public AsyncClosure {
42 public: 38 public:
43 explicit FireAndForgetAsyncClosure(const FunctorT& functor) 39 explicit FireAndForgetAsyncClosure(const FunctorT& functor)
44 : functor_(functor) {} 40 : functor_(functor) {}
45 virtual void Execute() { 41 virtual void Execute() {
46 functor_(); 42 functor_();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 TriggerCallback(); 126 TriggerCallback();
131 } 127 }
132 128
133 private: 129 private:
134 FunctorT functor_; 130 FunctorT functor_;
135 }; 131 };
136 132
137 } // namespace rtc 133 } // namespace rtc
138 134
139 #endif // WEBRTC_BASE_ASYNCINVOKER_INL_H_ 135 #endif // WEBRTC_BASE_ASYNCINVOKER_INL_H_
OLDNEW
« no previous file with comments | « webrtc/base/asyncinvoker.cc ('k') | webrtc/base/messagequeue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698