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 "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 #include "jingle/glue/dummy_chrome_socketserver.h" |
11 | 12 |
12 namespace jingle_glue { | 13 namespace jingle_glue { |
13 | 14 |
14 struct JingleThreadWrapper::PendingSend { | 15 struct JingleThreadWrapper::PendingSend { |
15 PendingSend(const talk_base::Message& message_value) | 16 PendingSend(const talk_base::Message& message_value) |
16 : sending_thread(JingleThreadWrapper::current()), | 17 : sending_thread(JingleThreadWrapper::current()), |
17 message(message_value), | 18 message(message_value), |
18 done_event(true, false) { | 19 done_event(true, false) { |
19 DCHECK(sending_thread); | 20 DCHECK(sending_thread); |
20 } | 21 } |
(...skipping 15 matching lines...) Expand all Loading... |
36 | 37 |
37 DCHECK_EQ(talk_base::Thread::Current(), current()); | 38 DCHECK_EQ(talk_base::Thread::Current(), current()); |
38 } | 39 } |
39 | 40 |
40 // static | 41 // static |
41 JingleThreadWrapper* JingleThreadWrapper::current() { | 42 JingleThreadWrapper* JingleThreadWrapper::current() { |
42 return g_jingle_thread_wrapper.Get().Get(); | 43 return g_jingle_thread_wrapper.Get().Get(); |
43 } | 44 } |
44 | 45 |
45 JingleThreadWrapper::JingleThreadWrapper(MessageLoop* message_loop) | 46 JingleThreadWrapper::JingleThreadWrapper(MessageLoop* message_loop) |
46 : message_loop_(message_loop), | 47 : talk_base::Thread(new DummyChromeSocketServer()), |
| 48 message_loop_(message_loop), |
47 send_allowed_(false), | 49 send_allowed_(false), |
48 last_task_id_(0), | 50 last_task_id_(0), |
49 pending_send_event_(true, false) { | 51 pending_send_event_(true, false) { |
50 DCHECK_EQ(message_loop_, MessageLoop::current()); | 52 DCHECK_EQ(message_loop_, MessageLoop::current()); |
51 | 53 |
52 talk_base::ThreadManager::Instance()->UnwrapCurrentThread(); | 54 talk_base::ThreadManager::Instance()->UnwrapCurrentThread(); |
53 talk_base::ThreadManager::Instance()->SetCurrentThread(this); | 55 talk_base::ThreadManager::Instance()->SetCurrentThread(this); |
54 talk_base::MessageQueueManager::Instance()->Add(this); | 56 talk_base::MessageQueueManager::Instance()->Add(this); |
55 message_loop_->AddDestructionObserver(this); | 57 message_loop_->AddDestructionObserver(this); |
56 | 58 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 290 |
289 void JingleThreadWrapper::Stop() { | 291 void JingleThreadWrapper::Stop() { |
290 NOTREACHED(); | 292 NOTREACHED(); |
291 } | 293 } |
292 | 294 |
293 void JingleThreadWrapper::Run() { | 295 void JingleThreadWrapper::Run() { |
294 NOTREACHED(); | 296 NOTREACHED(); |
295 } | 297 } |
296 | 298 |
297 } // namespace jingle_glue | 299 } // namespace jingle_glue |
OLD | NEW |