OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "jingle/glue/thread_wrapper.h" | 5 #include "jingle/glue/thread_wrapper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/threading/thread_local.h" | 14 #include "base/threading/thread_local.h" |
15 #include "third_party/webrtc/base/nullsocketserver.h" | 15 #include "third_party/webrtc/base/nullsocketserver.h" |
16 | 16 |
17 namespace jingle_glue { | 17 namespace jingle_glue { |
18 | 18 |
19 struct JingleThreadWrapper::PendingSend { | 19 struct JingleThreadWrapper::PendingSend { |
20 PendingSend(const rtc::Message& message_value) | 20 PendingSend(const rtc::Message& message_value) |
21 : sending_thread(JingleThreadWrapper::current()), | 21 : sending_thread(JingleThreadWrapper::current()), |
22 message(message_value), | 22 message(message_value), |
23 done_event(true, false) { | 23 done_event(base::WaitableEvent::ResetPolicy::MANUAL, |
| 24 base::WaitableEvent::InitialState::NOT_SIGNALED) { |
24 DCHECK(sending_thread); | 25 DCHECK(sending_thread); |
25 } | 26 } |
26 | 27 |
27 JingleThreadWrapper* sending_thread; | 28 JingleThreadWrapper* sending_thread; |
28 rtc::Message message; | 29 rtc::Message message; |
29 base::WaitableEvent done_event; | 30 base::WaitableEvent done_event; |
30 }; | 31 }; |
31 | 32 |
32 base::LazyInstance<base::ThreadLocalPointer<JingleThreadWrapper> > | 33 base::LazyInstance<base::ThreadLocalPointer<JingleThreadWrapper> > |
33 g_jingle_thread_wrapper = LAZY_INSTANCE_INITIALIZER; | 34 g_jingle_thread_wrapper = LAZY_INSTANCE_INITIALIZER; |
(...skipping 24 matching lines...) Expand all Loading... |
58 // static | 59 // static |
59 JingleThreadWrapper* JingleThreadWrapper::current() { | 60 JingleThreadWrapper* JingleThreadWrapper::current() { |
60 return g_jingle_thread_wrapper.Get().Get(); | 61 return g_jingle_thread_wrapper.Get().Get(); |
61 } | 62 } |
62 | 63 |
63 JingleThreadWrapper::JingleThreadWrapper( | 64 JingleThreadWrapper::JingleThreadWrapper( |
64 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 65 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
65 : task_runner_(task_runner), | 66 : task_runner_(task_runner), |
66 send_allowed_(false), | 67 send_allowed_(false), |
67 last_task_id_(0), | 68 last_task_id_(0), |
68 pending_send_event_(true, false), | 69 pending_send_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 70 base::WaitableEvent::InitialState::NOT_SIGNALED), |
69 weak_ptr_factory_(this) { | 71 weak_ptr_factory_(this) { |
70 DCHECK(task_runner->BelongsToCurrentThread()); | 72 DCHECK(task_runner->BelongsToCurrentThread()); |
71 DCHECK(!rtc::Thread::Current()); | 73 DCHECK(!rtc::Thread::Current()); |
72 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); | 74 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); |
73 rtc::MessageQueueManager::Add(this); | 75 rtc::MessageQueueManager::Add(this); |
74 SafeWrapCurrent(); | 76 SafeWrapCurrent(); |
75 } | 77 } |
76 | 78 |
77 JingleThreadWrapper::~JingleThreadWrapper() { | 79 JingleThreadWrapper::~JingleThreadWrapper() { |
78 DCHECK_EQ(this, JingleThreadWrapper::current()); | 80 DCHECK_EQ(this, JingleThreadWrapper::current()); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 317 |
316 void JingleThreadWrapper::Stop() { | 318 void JingleThreadWrapper::Stop() { |
317 NOTREACHED(); | 319 NOTREACHED(); |
318 } | 320 } |
319 | 321 |
320 void JingleThreadWrapper::Run() { | 322 void JingleThreadWrapper::Run() { |
321 NOTREACHED(); | 323 NOTREACHED(); |
322 } | 324 } |
323 | 325 |
324 } // namespace jingle_glue | 326 } // namespace jingle_glue |
OLD | NEW |