OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/jingle_session_manager.h" | 5 #include "remoting/protocol/jingle_session_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "remoting/protocol/authenticator.h" | 10 #include "remoting/protocol/authenticator.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 const IncomingSessionCallback& incoming_session_callback) { | 39 const IncomingSessionCallback& incoming_session_callback) { |
40 incoming_session_callback_ = incoming_session_callback; | 40 incoming_session_callback_ = incoming_session_callback; |
41 } | 41 } |
42 | 42 |
43 void JingleSessionManager::set_protocol_config( | 43 void JingleSessionManager::set_protocol_config( |
44 std::unique_ptr<CandidateSessionConfig> config) { | 44 std::unique_ptr<CandidateSessionConfig> config) { |
45 protocol_config_ = std::move(config); | 45 protocol_config_ = std::move(config); |
46 } | 46 } |
47 | 47 |
48 std::unique_ptr<Session> JingleSessionManager::Connect( | 48 std::unique_ptr<Session> JingleSessionManager::Connect( |
49 const std::string& host_jid, | 49 const SignalingAddress& peer_address, |
50 std::unique_ptr<Authenticator> authenticator) { | 50 std::unique_ptr<Authenticator> authenticator) { |
51 std::unique_ptr<JingleSession> session(new JingleSession(this)); | 51 std::unique_ptr<JingleSession> session(new JingleSession(this)); |
52 session->StartConnection(host_jid, std::move(authenticator)); | 52 session->StartConnection(peer_address, std::move(authenticator)); |
53 sessions_[session->session_id_] = session.get(); | 53 sessions_[session->session_id_] = session.get(); |
54 return std::move(session); | 54 return std::move(session); |
55 } | 55 } |
56 | 56 |
57 void JingleSessionManager::set_authenticator_factory( | 57 void JingleSessionManager::set_authenticator_factory( |
58 std::unique_ptr<AuthenticatorFactory> authenticator_factory) { | 58 std::unique_ptr<AuthenticatorFactory> authenticator_factory) { |
59 DCHECK(CalledOnValidThread()); | 59 DCHECK(CalledOnValidThread()); |
60 authenticator_factory_ = std::move(authenticator_factory); | 60 authenticator_factory_ = std::move(authenticator_factory); |
61 } | 61 } |
62 | 62 |
(...skipping 14 matching lines...) Expand all Loading... |
77 } | 77 } |
78 | 78 |
79 if (message->action == JingleMessage::SESSION_INITIATE) { | 79 if (message->action == JingleMessage::SESSION_INITIATE) { |
80 // Description must be present in session-initiate messages. | 80 // Description must be present in session-initiate messages. |
81 DCHECK(message->description.get()); | 81 DCHECK(message->description.get()); |
82 | 82 |
83 SendReply(std::move(stanza_copy), JingleMessageReply::NONE); | 83 SendReply(std::move(stanza_copy), JingleMessageReply::NONE); |
84 | 84 |
85 std::unique_ptr<Authenticator> authenticator = | 85 std::unique_ptr<Authenticator> authenticator = |
86 authenticator_factory_->CreateAuthenticator( | 86 authenticator_factory_->CreateAuthenticator( |
87 signal_strategy_->GetLocalJid(), message->from.id()); | 87 signal_strategy_->GetLocalAddress().id(), message->from.id()); |
88 | 88 |
89 JingleSession* session = new JingleSession(this); | 89 JingleSession* session = new JingleSession(this); |
90 session->InitializeIncomingConnection(*message, | 90 session->InitializeIncomingConnection(*message, |
91 std::move(authenticator)); | 91 std::move(authenticator)); |
92 sessions_[session->session_id_] = session; | 92 sessions_[session->session_id_] = session; |
93 | 93 |
94 // Destroy the session if it was rejected due to incompatible protocol. | 94 // Destroy the session if it was rejected due to incompatible protocol. |
95 if (session->state_ != Session::ACCEPTING) { | 95 if (session->state_ != Session::ACCEPTING) { |
96 delete session; | 96 delete session; |
97 DCHECK(sessions_.find(message->sid) == sessions_.end()); | 97 DCHECK(sessions_.find(message->sid) == sessions_.end()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 signal_strategy_->SendStanza( | 147 signal_strategy_->SendStanza( |
148 JingleMessageReply(error).ToXml(original_stanza.get())); | 148 JingleMessageReply(error).ToXml(original_stanza.get())); |
149 } | 149 } |
150 | 150 |
151 void JingleSessionManager::SessionDestroyed(JingleSession* session) { | 151 void JingleSessionManager::SessionDestroyed(JingleSession* session) { |
152 sessions_.erase(session->session_id_); | 152 sessions_.erase(session->session_id_); |
153 } | 153 } |
154 | 154 |
155 } // namespace protocol | 155 } // namespace protocol |
156 } // namespace remoting | 156 } // namespace remoting |
OLD | NEW |