| 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" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/message_pump.h" | 10 #include "base/message_pump.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 JingleThread::~JingleThread() { | 147 JingleThread::~JingleThread() { |
| 148 // It is important to call Stop here. If we wait for the base class to | 148 // It is important to call Stop here. If we wait for the base class to |
| 149 // call Stop in it's d'tor, then JingleThread::Run() will access member | 149 // call Stop in it's d'tor, then JingleThread::Run() will access member |
| 150 // variables that are already gone. See similar comments in | 150 // variables that are already gone. See similar comments in |
| 151 // base/threading/thread.h. | 151 // base/threading/thread.h. |
| 152 if (message_loop_) | 152 if (message_loop_) |
| 153 Stop(); | 153 Stop(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void JingleThread::Start() { | 156 bool JingleThread::Start() { |
| 157 Thread::Start(); | 157 if (!Thread::Start()) |
| 158 return false; |
| 158 started_event_.Wait(); | 159 started_event_.Wait(); |
| 160 return true; |
| 159 } | 161 } |
| 160 | 162 |
| 161 void JingleThread::Run() { | 163 void JingleThread::Run() { |
| 162 JingleThreadMessageLoop message_loop(this); | 164 JingleThreadMessageLoop message_loop(this); |
| 163 message_loop_ = &message_loop; | 165 message_loop_ = &message_loop; |
| 164 message_loop_proxy_ = base::MessageLoopProxy::current(); | 166 message_loop_proxy_ = base::MessageLoopProxy::current(); |
| 165 | 167 |
| 166 TaskPump task_pump; | 168 TaskPump task_pump; |
| 167 task_pump_ = &task_pump; | 169 task_pump_ = &task_pump; |
| 168 | 170 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 191 | 193 |
| 192 base::MessageLoopProxy* JingleThread::message_loop_proxy() { | 194 base::MessageLoopProxy* JingleThread::message_loop_proxy() { |
| 193 return message_loop_proxy_; | 195 return message_loop_proxy_; |
| 194 } | 196 } |
| 195 | 197 |
| 196 TaskPump* JingleThread::task_pump() { | 198 TaskPump* JingleThread::task_pump() { |
| 197 return task_pump_; | 199 return task_pump_; |
| 198 } | 200 } |
| 199 | 201 |
| 200 } // namespace remoting | 202 } // namespace remoting |
| OLD | NEW |