OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "remoting/jingle_glue/jingle_thread.h" | 5 #include "remoting/jingle_glue/jingle_thread.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "third_party/libjingle/source/talk/base/ssladapter.h" | 9 #include "third_party/libjingle/source/talk/base/ssladapter.h" |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 JingleThread::~JingleThread() { } | 36 JingleThread::~JingleThread() { } |
37 | 37 |
38 void JingleThread::Start() { | 38 void JingleThread::Start() { |
39 Thread::Start(); | 39 Thread::Start(); |
40 started_event_.Wait(); | 40 started_event_.Wait(); |
41 } | 41 } |
42 | 42 |
43 void JingleThread::Run() { | 43 void JingleThread::Run() { |
44 LOG(INFO) << "Started Jingle thread."; | |
45 | |
46 MessageLoopForIO message_loop; | 44 MessageLoopForIO message_loop; |
47 message_loop_ = &message_loop; | 45 message_loop_ = &message_loop; |
48 | 46 |
49 TaskPump task_pump; | 47 TaskPump task_pump; |
50 task_pump_ = &task_pump; | 48 task_pump_ = &task_pump; |
51 | 49 |
52 // Signal after we've initialized |message_loop_| and |task_pump_|. | 50 // Signal after we've initialized |message_loop_| and |task_pump_|. |
53 started_event_.Signal(); | 51 started_event_.Signal(); |
54 | 52 |
55 Post(this, kRunTasksMessageId); | 53 Post(this, kRunTasksMessageId); |
56 | 54 |
57 Thread::Run(); | 55 Thread::Run(); |
58 | 56 |
59 message_loop.RunAllPending(); | 57 message_loop.RunAllPending(); |
60 | 58 |
61 task_pump_ = NULL; | 59 task_pump_ = NULL; |
62 message_loop_ = NULL; | 60 message_loop_ = NULL; |
63 | |
64 LOG(INFO) << "Jingle thread finished."; | |
65 } | 61 } |
66 | 62 |
67 // This method is called every 20ms to process tasks from |message_loop_| | 63 // This method is called every 20ms to process tasks from |message_loop_| |
68 // on this thread. | 64 // on this thread. |
69 // TODO(sergeyu): Remove it when JingleThread moved to Chromium's base::Thread. | 65 // TODO(sergeyu): Remove it when JingleThread moved to Chromium's base::Thread. |
70 void JingleThread::PumpAuxiliaryLoops() { | 66 void JingleThread::PumpAuxiliaryLoops() { |
71 MessageLoop::current()->RunAllPending(); | 67 MessageLoop::current()->RunAllPending(); |
72 | 68 |
73 // Schedule next execution 20ms from now. | 69 // Schedule next execution 20ms from now. |
74 PostDelayed(20, this, kRunTasksMessageId); | 70 PostDelayed(20, this, kRunTasksMessageId); |
75 } | 71 } |
76 | 72 |
77 void JingleThread::OnMessage(talk_base::Message* msg) { | 73 void JingleThread::OnMessage(talk_base::Message* msg) { |
78 PumpAuxiliaryLoops(); | 74 PumpAuxiliaryLoops(); |
79 } | 75 } |
80 | 76 |
81 } // namespace remoting | 77 } // namespace remoting |
OLD | NEW |