OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
11 | 11 |
12 namespace jingle_glue { | 12 namespace jingle_glue { |
13 | 13 |
14 struct JingleThreadWrapper::PendingSend { | 14 struct JingleThreadWrapper::PendingSend { |
15 PendingSend(const talk_base::Message& message_value) | 15 PendingSend(const talk_base::Message& message_value) |
16 : sending_thread(JingleThreadWrapper::current()), | 16 : sending_thread(JingleThreadWrapper::current()), |
17 message(message_value), | 17 message(message_value), |
18 done_event(true, false) { | 18 done_event(true, false) { |
19 DCHECK(sending_thread); | 19 DCHECK(sending_thread); |
20 } | 20 } |
21 | 21 |
22 JingleThreadWrapper* sending_thread; | 22 JingleThreadWrapper* sending_thread; |
23 talk_base::Message message; | 23 talk_base::Message message; |
24 base::WaitableEvent done_event; | 24 base::WaitableEvent done_event; |
25 }; | 25 }; |
26 | 26 |
27 base::LazyInstance<base::ThreadLocalPointer<JingleThreadWrapper> > | 27 base::LazyInstance<base::ThreadLocalPointer<JingleThreadWrapper> > |
28 g_jingle_thread_wrapper(base::LINKER_INITIALIZED); | 28 g_jingle_thread_wrapper = LAZY_INSTANCE_INITIALIZER; |
29 | 29 |
30 // static | 30 // static |
31 void JingleThreadWrapper::EnsureForCurrentThread() { | 31 void JingleThreadWrapper::EnsureForCurrentThread() { |
32 if (JingleThreadWrapper::current() == NULL) { | 32 if (JingleThreadWrapper::current() == NULL) { |
33 g_jingle_thread_wrapper.Get().Set( | 33 g_jingle_thread_wrapper.Get().Set( |
34 new JingleThreadWrapper(MessageLoop::current())); | 34 new JingleThreadWrapper(MessageLoop::current())); |
35 } | 35 } |
36 | 36 |
37 DCHECK_EQ(talk_base::Thread::Current(), current()); | 37 DCHECK_EQ(talk_base::Thread::Current(), current()); |
38 } | 38 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 286 |
287 void JingleThreadWrapper::Stop() { | 287 void JingleThreadWrapper::Stop() { |
288 NOTREACHED(); | 288 NOTREACHED(); |
289 } | 289 } |
290 | 290 |
291 void JingleThreadWrapper::Run() { | 291 void JingleThreadWrapper::Run() { |
292 NOTREACHED(); | 292 NOTREACHED(); |
293 } | 293 } |
294 | 294 |
295 } // namespace jingle_glue | 295 } // namespace jingle_glue |
OLD | NEW |