| 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 "remoting/jingle_glue/jingle_thread.h" | 5 #include "remoting/jingle_glue/jingle_thread.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop_proxy.h" | |
| 10 #include "base/message_pump.h" | 9 #include "base/message_pump.h" |
| 11 #include "base/time.h" | 10 #include "base/time.h" |
| 12 #include "third_party/libjingle/source/talk/base/ssladapter.h" | 11 #include "third_party/libjingle/source/talk/base/ssladapter.h" |
| 13 | 12 |
| 14 namespace remoting { | 13 namespace remoting { |
| 15 | 14 |
| 16 const uint32 kRunTasksMessageId = 1; | 15 const uint32 kRunTasksMessageId = 1; |
| 17 const uint32 kStopMessageId = 2; | 16 const uint32 kStopMessageId = 2; |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 JingleThread::~JingleThread() { } | 146 JingleThread::~JingleThread() { } |
| 148 | 147 |
| 149 void JingleThread::Start() { | 148 void JingleThread::Start() { |
| 150 Thread::Start(); | 149 Thread::Start(); |
| 151 started_event_.Wait(); | 150 started_event_.Wait(); |
| 152 } | 151 } |
| 153 | 152 |
| 154 void JingleThread::Run() { | 153 void JingleThread::Run() { |
| 155 JingleThreadMessageLoop message_loop(this); | 154 JingleThreadMessageLoop message_loop(this); |
| 156 message_loop_ = &message_loop; | 155 message_loop_ = &message_loop; |
| 157 message_loop_proxy_ = base::MessageLoopProxy::CreateForCurrentThread(); | |
| 158 | 156 |
| 159 TaskPump task_pump; | 157 TaskPump task_pump; |
| 160 task_pump_ = &task_pump; | 158 task_pump_ = &task_pump; |
| 161 | 159 |
| 162 // Signal after we've initialized |message_loop_| and |task_pump_|. | 160 // Signal after we've initialized |message_loop_| and |task_pump_|. |
| 163 started_event_.Signal(); | 161 started_event_.Signal(); |
| 164 | 162 |
| 165 message_loop.Run(); | 163 message_loop.Run(); |
| 166 | 164 |
| 167 stopped_event_.Signal(); | 165 stopped_event_.Signal(); |
| 168 | 166 |
| 169 task_pump_ = NULL; | 167 task_pump_ = NULL; |
| 170 message_loop_ = NULL; | 168 message_loop_ = NULL; |
| 171 } | 169 } |
| 172 | 170 |
| 173 void JingleThread::Stop() { | 171 void JingleThread::Stop() { |
| 174 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 172 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 175 stopped_event_.Wait(); | 173 stopped_event_.Wait(); |
| 176 | 174 |
| 177 // This will wait until the thread is actually finished. | 175 // This will wait until the thread is actually finished. |
| 178 Thread::Stop(); | 176 Thread::Stop(); |
| 179 } | 177 } |
| 180 | 178 |
| 181 MessageLoop* JingleThread::message_loop() { | 179 MessageLoop* JingleThread::message_loop() { |
| 182 return message_loop_; | 180 return message_loop_; |
| 183 } | 181 } |
| 184 | 182 |
| 185 base::MessageLoopProxy* JingleThread::message_loop_proxy() { | |
| 186 return message_loop_proxy_; | |
| 187 } | |
| 188 | |
| 189 TaskPump* JingleThread::task_pump() { | 183 TaskPump* JingleThread::task_pump() { |
| 190 return task_pump_; | 184 return task_pump_; |
| 191 } | 185 } |
| 192 | 186 |
| 193 } // namespace remoting | 187 } // namespace remoting |
| OLD | NEW |