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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_pump.h" | 9 #include "base/message_pump.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 task_pump_ = NULL; | 86 task_pump_ = NULL; |
87 message_loop_ = NULL; | 87 message_loop_ = NULL; |
88 } | 88 } |
89 | 89 |
90 void JingleThread::Stop() { | 90 void JingleThread::Stop() { |
91 // Shutdown gracefully: make sure that we excute all messages left in the | 91 // Shutdown gracefully: make sure that we excute all messages left in the |
92 // queue before exiting. Thread::Stop() would not do that. | 92 // queue before exiting. Thread::Stop() would not do that. |
93 Post(this, kStopMessageId); | 93 Post(this, kStopMessageId); |
94 stopped_event_.Wait(); | 94 stopped_event_.Wait(); |
| 95 |
| 96 // This will wait until the thread is actually finished. |
| 97 Thread::Stop(); |
95 } | 98 } |
96 | 99 |
97 MessageLoop* JingleThread::message_loop() { | 100 MessageLoop* JingleThread::message_loop() { |
98 return message_loop_; | 101 return message_loop_; |
99 } | 102 } |
100 | 103 |
101 // Returns task pump if the thread is running, otherwise NULL is returned. | 104 // Returns task pump if the thread is running, otherwise NULL is returned. |
102 TaskPump* JingleThread::task_pump() { | 105 TaskPump* JingleThread::task_pump() { |
103 return task_pump_; | 106 return task_pump_; |
104 } | 107 } |
(...skipping 15 matching lines...) Expand all Loading... |
120 // otherwise post another task to try again later. | 123 // otherwise post another task to try again later. |
121 if (msgq_.size() > 0 || fPeekKeep_) { | 124 if (msgq_.size() > 0 || fPeekKeep_) { |
122 Post(this, kStopMessageId); | 125 Post(this, kStopMessageId); |
123 } else { | 126 } else { |
124 MessageQueue::Quit(); | 127 MessageQueue::Quit(); |
125 } | 128 } |
126 } | 129 } |
127 } | 130 } |
128 | 131 |
129 } // namespace remoting | 132 } // namespace remoting |
OLD | NEW |