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/host/it2me_host_user_interface.h" | 5 #include "remoting/host/it2me_host_user_interface.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "remoting/host/chromoting_host.h" | 8 #include "remoting/host/chromoting_host.h" |
9 #include "remoting/host/chromoting_host_context.h" | 9 #include "remoting/host/chromoting_host_context.h" |
10 #include "remoting/host/continue_window.h" | 10 #include "remoting/host/continue_window.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 private: | 25 private: |
26 ScopedThreadProxy thread_proxy_; | 26 ScopedThreadProxy thread_proxy_; |
27 }; | 27 }; |
28 | 28 |
29 | 29 |
30 It2MeHostUserInterface::It2MeHostUserInterface(ChromotingHost* host, | 30 It2MeHostUserInterface::It2MeHostUserInterface(ChromotingHost* host, |
31 ChromotingHostContext* context) | 31 ChromotingHostContext* context) |
32 : host_(host), | 32 : host_(host), |
33 context_(context), | 33 context_(context), |
34 is_monitoring_local_inputs_(false), | 34 is_monitoring_local_inputs_(false), |
35 ui_thread_proxy_(context->ui_message_loop()) { | 35 ui_thread_proxy_(context->ui_message_loop()), |
36 callback_complete_(false, false) { | |
36 } | 37 } |
37 | 38 |
38 It2MeHostUserInterface::~It2MeHostUserInterface() { | 39 It2MeHostUserInterface::~It2MeHostUserInterface() { |
39 } | 40 } |
40 | 41 |
41 void It2MeHostUserInterface::Init() { | 42 void It2MeHostUserInterface::Init() { |
42 InitFrom(DisconnectWindow::Create(), | 43 InitFrom(DisconnectWindow::Create(), |
43 ContinueWindow::Create(), | 44 ContinueWindow::Create(), |
44 LocalInputMonitor::Create()); | 45 LocalInputMonitor::Create()); |
45 } | 46 } |
(...skipping 13 matching lines...) Expand all Loading... | |
59 void It2MeHostUserInterface::OnSignallingDisconnected() { | 60 void It2MeHostUserInterface::OnSignallingDisconnected() { |
60 } | 61 } |
61 | 62 |
62 void It2MeHostUserInterface::OnClientAuthenticated(const std::string& jid) { | 63 void It2MeHostUserInterface::OnClientAuthenticated(const std::string& jid) { |
63 // There should not be more than one concurrent authenticated connection. | 64 // There should not be more than one concurrent authenticated connection. |
64 DCHECK(authenticated_jid_.empty()); | 65 DCHECK(authenticated_jid_.empty()); |
65 authenticated_jid_ = jid; | 66 authenticated_jid_ = jid; |
66 | 67 |
67 std::string username = jid.substr(0, jid.find('/')); | 68 std::string username = jid.substr(0, jid.find('/')); |
68 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( | 69 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( |
69 &It2MeHostUserInterface::ProcessOnConnect, base::Unretained(this), | 70 &It2MeHostUserInterface::ProcessOnClientAuthenticated, |
71 base::Unretained(this), | |
70 username)); | 72 username)); |
73 CHECK(callback_complete_.TimedWait(base::TimeDelta::FromSeconds(10))); | |
71 } | 74 } |
72 | 75 |
73 void It2MeHostUserInterface::OnClientDisconnected(const std::string& jid) { | 76 void It2MeHostUserInterface::OnClientDisconnected(const std::string& jid) { |
74 if (jid == authenticated_jid_) { | 77 if (jid == authenticated_jid_) { |
75 authenticated_jid_.clear(); | 78 authenticated_jid_.clear(); |
76 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( | 79 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( |
77 &It2MeHostUserInterface::ProcessOnLastDisconnect, | 80 &It2MeHostUserInterface::ProcessOnClientDisconnected, |
78 base::Unretained(this))); | 81 base::Unretained(this))); |
82 CHECK(callback_complete_.TimedWait(base::TimeDelta::FromSeconds(10))); | |
Sergey Ulanov
2011/12/01 20:35:24
I don't think that blocking network thread on the
| |
79 } | 83 } |
80 } | 84 } |
81 | 85 |
82 void It2MeHostUserInterface::OnAccessDenied() { | 86 void It2MeHostUserInterface::OnAccessDenied() { |
83 } | 87 } |
84 | 88 |
85 void It2MeHostUserInterface::OnShutdown() { | 89 void It2MeHostUserInterface::OnShutdown() { |
86 } | 90 } |
87 | 91 |
88 void It2MeHostUserInterface::Shutdown() { | 92 void It2MeHostUserInterface::Shutdown() { |
89 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); | 93 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); |
90 | 94 |
91 MonitorLocalInputs(false); | 95 MonitorLocalInputs(false); |
92 ShowDisconnectWindow(false, std::string()); | 96 ShowDisconnectWindow(false, std::string()); |
93 ShowContinueWindow(false); | 97 ShowContinueWindow(false); |
94 StartContinueWindowTimer(false); | 98 StartContinueWindowTimer(false); |
95 | 99 |
96 ui_thread_proxy_.Detach(); | 100 ui_thread_proxy_.Detach(); |
97 } | 101 } |
98 | 102 |
99 void It2MeHostUserInterface::OnConnect(const std::string& username) { | 103 void It2MeHostUserInterface::ProcessOnClientAuthenticated( |
100 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( | 104 const std::string& username) { |
101 &It2MeHostUserInterface::ProcessOnConnect, base::Unretained(this), | |
102 username)); | |
103 } | |
104 | |
105 void It2MeHostUserInterface::OnLastDisconnect() { | |
106 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( | |
107 &It2MeHostUserInterface::ProcessOnLastDisconnect, | |
108 base::Unretained(this))); | |
109 } | |
110 | |
111 void It2MeHostUserInterface::ProcessOnConnect(const std::string& username) { | |
112 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); | 105 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); |
113 | 106 |
114 MonitorLocalInputs(true); | 107 MonitorLocalInputs(true); |
115 ShowDisconnectWindow(true, username); | 108 ShowDisconnectWindow(true, username); |
116 StartContinueWindowTimer(true); | 109 StartContinueWindowTimer(true); |
110 callback_complete_.Signal(); | |
117 } | 111 } |
118 | 112 |
119 void It2MeHostUserInterface::ProcessOnLastDisconnect() { | 113 void It2MeHostUserInterface::ProcessOnClientDisconnected() { |
120 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); | 114 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); |
121 | 115 |
122 MonitorLocalInputs(false); | 116 MonitorLocalInputs(false); |
123 ShowDisconnectWindow(false, std::string()); | 117 ShowDisconnectWindow(false, std::string()); |
124 ShowContinueWindow(false); | 118 ShowContinueWindow(false); |
125 StartContinueWindowTimer(false); | 119 StartContinueWindowTimer(false); |
120 callback_complete_.Signal(); | |
126 } | 121 } |
127 | 122 |
128 void It2MeHostUserInterface::MonitorLocalInputs(bool enable) { | 123 void It2MeHostUserInterface::MonitorLocalInputs(bool enable) { |
129 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); | 124 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); |
130 | 125 |
131 if (enable == is_monitoring_local_inputs_) | 126 if (enable == is_monitoring_local_inputs_) |
132 return; | 127 return; |
133 if (enable) { | 128 if (enable) { |
134 local_input_monitor_->Start(host_); | 129 local_input_monitor_->Start(host_); |
135 } else { | 130 } else { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 } | 195 } |
201 | 196 |
202 void It2MeHostUserInterface::OnShutdownHostTimer() { | 197 void It2MeHostUserInterface::OnShutdownHostTimer() { |
203 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); | 198 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); |
204 | 199 |
205 ShowContinueWindow(false); | 200 ShowContinueWindow(false); |
206 host_->Shutdown(base::Closure()); | 201 host_->Shutdown(base::Closure()); |
207 } | 202 } |
208 | 203 |
209 } // namespace remoting | 204 } // namespace remoting |
OLD | NEW |