OLD | NEW |
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 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 void AsyncInvoker::DoInvoke(Thread* thread, | 57 void AsyncInvoker::DoInvoke(Thread* thread, |
58 const scoped_refptr<AsyncClosure>& closure, | 58 const scoped_refptr<AsyncClosure>& closure, |
59 uint32 id) { | 59 uint32 id) { |
60 if (destroying_) { | 60 if (destroying_) { |
61 LOG(LS_WARNING) << "Tried to invoke while destroying the invoker."; | 61 LOG(LS_WARNING) << "Tried to invoke while destroying the invoker."; |
62 return; | 62 return; |
63 } | 63 } |
64 thread->Post(this, id, new ScopedRefMessageData<AsyncClosure>(closure)); | 64 thread->Post(this, id, new ScopedRefMessageData<AsyncClosure>(closure)); |
65 } | 65 } |
66 | 66 |
| 67 void AsyncInvoker::DoInvokeDelayed(Thread* thread, |
| 68 const scoped_refptr<AsyncClosure>& closure, |
| 69 uint32 delay_ms, |
| 70 uint32 id) { |
| 71 if (destroying_) { |
| 72 LOG(LS_WARNING) << "Tried to invoke while destroying the invoker."; |
| 73 return; |
| 74 } |
| 75 thread->PostDelayed(delay_ms, this, id, |
| 76 new ScopedRefMessageData<AsyncClosure>(closure)); |
| 77 } |
| 78 |
67 NotifyingAsyncClosureBase::NotifyingAsyncClosureBase(AsyncInvoker* invoker, | 79 NotifyingAsyncClosureBase::NotifyingAsyncClosureBase(AsyncInvoker* invoker, |
68 Thread* calling_thread) | 80 Thread* calling_thread) |
69 : invoker_(invoker), calling_thread_(calling_thread) { | 81 : invoker_(invoker), calling_thread_(calling_thread) { |
70 calling_thread->SignalQueueDestroyed.connect( | 82 calling_thread->SignalQueueDestroyed.connect( |
71 this, &NotifyingAsyncClosureBase::CancelCallback); | 83 this, &NotifyingAsyncClosureBase::CancelCallback); |
72 invoker->SignalInvokerDestroyed.connect( | 84 invoker->SignalInvokerDestroyed.connect( |
73 this, &NotifyingAsyncClosureBase::CancelCallback); | 85 this, &NotifyingAsyncClosureBase::CancelCallback); |
74 } | 86 } |
75 | 87 |
76 NotifyingAsyncClosureBase::~NotifyingAsyncClosureBase() { | 88 NotifyingAsyncClosureBase::~NotifyingAsyncClosureBase() { |
(...skipping 10 matching lines...) Expand all Loading... |
87 void NotifyingAsyncClosureBase::CancelCallback() { | 99 void NotifyingAsyncClosureBase::CancelCallback() { |
88 // If the callback is triggering when this is called, block the | 100 // If the callback is triggering when this is called, block the |
89 // destructor of the dying object here by waiting until the callback | 101 // destructor of the dying object here by waiting until the callback |
90 // is done triggering. | 102 // is done triggering. |
91 CritScope cs(&crit_); | 103 CritScope cs(&crit_); |
92 // calling_thread_ == NULL means do not trigger the callback. | 104 // calling_thread_ == NULL means do not trigger the callback. |
93 calling_thread_ = NULL; | 105 calling_thread_ = NULL; |
94 } | 106 } |
95 | 107 |
96 } // namespace rtc | 108 } // namespace rtc |
OLD | NEW |