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/protocol/connection_to_host.h" | 5 #include "remoting/protocol/connection_to_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void ConnectionToHost::Disconnect(const base::Closure& shutdown_task) { | 79 void ConnectionToHost::Disconnect(const base::Closure& shutdown_task) { |
80 if (MessageLoop::current() != message_loop_) { | 80 if (MessageLoop::current() != message_loop_) { |
81 message_loop_->PostTask( | 81 message_loop_->PostTask( |
82 FROM_HERE, base::Bind(&ConnectionToHost::Disconnect, | 82 FROM_HERE, base::Bind(&ConnectionToHost::Disconnect, |
83 base::Unretained(this), shutdown_task)); | 83 base::Unretained(this), shutdown_task)); |
84 return; | 84 return; |
85 } | 85 } |
86 | 86 |
87 CloseChannels(); | 87 CloseChannels(); |
88 | 88 |
89 if (session_.get()) { | 89 if (session_.get()) |
90 session_->Close(); | |
91 session_.reset(); | 90 session_.reset(); |
92 } | |
93 | 91 |
94 if (session_manager_.get()) { | 92 if (session_manager_.get()) |
95 session_manager_->Close(); | |
96 session_manager_.reset(); | 93 session_manager_.reset(); |
97 } | |
98 | 94 |
99 if (signal_strategy_.get()) { | 95 if (signal_strategy_.get()) |
100 signal_strategy_->Close(); | |
101 signal_strategy_.reset(); | 96 signal_strategy_.reset(); |
102 } | |
103 | 97 |
104 shutdown_task.Run(); | 98 shutdown_task.Run(); |
105 } | 99 } |
106 | 100 |
107 void ConnectionToHost::InitSession() { | 101 void ConnectionToHost::InitSession() { |
108 DCHECK_EQ(message_loop_, MessageLoop::current()); | 102 DCHECK_EQ(message_loop_, MessageLoop::current()); |
109 | 103 |
110 // Initialize chromotocol |session_manager_|. | 104 // Initialize chromotocol |session_manager_|. |
111 JingleSessionManager* session_manager = | 105 JingleSessionManager* session_manager = |
112 new JingleSessionManager(network_manager_.release(), | 106 JingleSessionManager::CreateSandboxed( |
113 socket_factory_.release(), | 107 network_manager_.release(), socket_factory_.release(), |
114 port_allocator_session_factory_.release()); | 108 port_allocator_session_factory_.release()); |
115 | 109 |
116 // TODO(ajwong): Make this a command switch when we're more stable. | 110 // TODO(ajwong): Make this a command switch when we're more stable. |
117 session_manager->set_allow_local_ips(true); | 111 session_manager->set_allow_local_ips(true); |
118 session_manager->Init( | 112 session_manager->Init( |
119 local_jid_, signal_strategy_.get(), | 113 local_jid_, signal_strategy_.get(), |
120 NewCallback(this, &ConnectionToHost::OnNewSession), NULL, NULL); | 114 NewCallback(this, &ConnectionToHost::OnNewSession), NULL, NULL); |
121 session_manager_.reset(session_manager); | 115 session_manager_.reset(session_manager); |
122 | 116 |
123 CandidateSessionConfig* candidate_config = | 117 CandidateSessionConfig* candidate_config = |
124 CandidateSessionConfig::CreateDefault(); | 118 CandidateSessionConfig::CreateDefault(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // Create and enable the input stub now that we're authenticated. | 207 // Create and enable the input stub now that we're authenticated. |
214 input_sender_.reset(new InputSender(session_->event_channel())); | 208 input_sender_.reset(new InputSender(session_->event_channel())); |
215 } | 209 } |
216 | 210 |
217 ConnectionToHost::State ConnectionToHost::state() const { | 211 ConnectionToHost::State ConnectionToHost::state() const { |
218 return state_; | 212 return state_; |
219 } | 213 } |
220 | 214 |
221 } // namespace protocol | 215 } // namespace protocol |
222 } // namespace remoting | 216 } // namespace remoting |
OLD | NEW |