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/client/client_context.h" | 5 #include "remoting/client/client_context.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "remoting/jingle_glue/jingle_thread.h" | 10 #include "remoting/jingle_glue/jingle_thread.h" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 | 13 |
14 ClientContext::ClientContext() | 14 ClientContext::ClientContext() |
15 : main_thread_("ChromotingClientMainThread"), | 15 : main_thread_("ChromotingClientMainThread"), |
16 decode_thread_("ChromotingClientDecodeThread") { | 16 decode_thread_("ChromotingClientDecodeThread"), |
| 17 started_(false) { |
17 } | 18 } |
18 | 19 |
19 ClientContext::~ClientContext() { | 20 ClientContext::~ClientContext() { |
20 } | 21 } |
21 | 22 |
22 void ClientContext::Start() { | 23 void ClientContext::Start() { |
23 // Start all the threads. | 24 // Start all the threads. |
24 main_thread_.Start(); | 25 main_thread_.Start(); |
25 decode_thread_.Start(); | 26 decode_thread_.Start(); |
26 jingle_thread_.Start(); | 27 jingle_thread_.Start(); |
| 28 started_ = true; |
27 } | 29 } |
28 | 30 |
29 void ClientContext::Stop() { | 31 void ClientContext::Stop() { |
30 // Stop all the threads. | 32 if (started_) { |
31 jingle_thread_.Stop(); | 33 // Stop all the threads. |
32 decode_thread_.Stop(); | 34 jingle_thread_.Stop(); |
33 main_thread_.Stop(); | 35 decode_thread_.Stop(); |
| 36 main_thread_.Stop(); |
| 37 started_ = false; |
| 38 } |
34 } | 39 } |
35 | 40 |
36 JingleThread* ClientContext::jingle_thread() { | 41 JingleThread* ClientContext::jingle_thread() { |
37 return &jingle_thread_; | 42 return &jingle_thread_; |
38 } | 43 } |
39 | 44 |
40 MessageLoop* ClientContext::main_message_loop() { | 45 MessageLoop* ClientContext::main_message_loop() { |
41 return main_thread_.message_loop(); | 46 return main_thread_.message_loop(); |
42 } | 47 } |
43 | 48 |
44 MessageLoop* ClientContext::decode_message_loop() { | 49 MessageLoop* ClientContext::decode_message_loop() { |
45 return decode_thread_.message_loop(); | 50 return decode_thread_.message_loop(); |
46 } | 51 } |
47 | 52 |
48 MessageLoop* ClientContext::network_message_loop() { | 53 MessageLoop* ClientContext::network_message_loop() { |
49 return jingle_thread_.message_loop(); | 54 return jingle_thread_.message_loop(); |
50 } | 55 } |
51 | 56 |
52 } // namespace remoting | 57 } // namespace remoting |
OLD | NEW |