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/jingle_session_manager.h" | 5 #include "remoting/protocol/jingle_session_manager.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 : message_loop_(message_loop), | 31 : message_loop_(message_loop), |
32 signal_strategy_(NULL), | 32 signal_strategy_(NULL), |
33 allow_nat_traversal_(false), | 33 allow_nat_traversal_(false), |
34 allow_local_ips_(false), | 34 allow_local_ips_(false), |
35 http_port_allocator_(NULL), | 35 http_port_allocator_(NULL), |
36 closed_(false), | 36 closed_(false), |
37 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { | 37 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { |
38 } | 38 } |
39 | 39 |
40 JingleSessionManager::~JingleSessionManager() { | 40 JingleSessionManager::~JingleSessionManager() { |
| 41 // Session manager can be destroyed only after all sessions are destroyed. |
| 42 DCHECK(sessions_.empty()); |
41 Close(); | 43 Close(); |
42 } | 44 } |
43 | 45 |
44 void JingleSessionManager::Init( | 46 void JingleSessionManager::Init( |
45 const std::string& local_jid, | 47 const std::string& local_jid, |
46 SignalStrategy* signal_strategy, | 48 SignalStrategy* signal_strategy, |
47 Listener* listener, | 49 Listener* listener, |
48 crypto::RSAPrivateKey* private_key, | 50 crypto::RSAPrivateKey* private_key, |
49 const std::string& certificate, | 51 const std::string& certificate, |
50 bool allow_nat_traversal) { | 52 bool allow_nat_traversal) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 jingle_info_request_->Send(base::Bind( | 106 jingle_info_request_->Send(base::Bind( |
105 &JingleSessionManager::OnJingleInfo, base::Unretained(this))); | 107 &JingleSessionManager::OnJingleInfo, base::Unretained(this))); |
106 } else { | 108 } else { |
107 listener_->OnSessionManagerInitialized(); | 109 listener_->OnSessionManagerInitialized(); |
108 } | 110 } |
109 } | 111 } |
110 | 112 |
111 void JingleSessionManager::Close() { | 113 void JingleSessionManager::Close() { |
112 DCHECK(CalledOnValidThread()); | 114 DCHECK(CalledOnValidThread()); |
113 | 115 |
114 // Close() can be called only after all sessions are destroyed. | |
115 DCHECK(sessions_.empty()); | |
116 | |
117 if (!closed_) { | 116 if (!closed_) { |
118 cricket_session_manager_->RemoveClient(kChromotingXmlNamespace); | 117 cricket_session_manager_->RemoveClient(kChromotingXmlNamespace); |
119 jingle_signaling_connector_.reset(); | 118 jingle_signaling_connector_.reset(); |
120 cricket_session_manager_.reset(); | |
121 closed_ = true; | 119 closed_ = true; |
122 } | 120 } |
123 } | 121 } |
124 | 122 |
125 void JingleSessionManager::set_allow_local_ips(bool allow_local_ips) { | 123 void JingleSessionManager::set_allow_local_ips(bool allow_local_ips) { |
126 allow_local_ips_ = allow_local_ips; | 124 allow_local_ips_ = allow_local_ips; |
127 } | 125 } |
128 | 126 |
129 Session* JingleSessionManager::Connect( | 127 Session* JingleSessionManager::Connect( |
130 const std::string& host_jid, | 128 const std::string& host_jid, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 const std::string& certificate) { | 316 const std::string& certificate) { |
319 cricket::SessionDescription* desc = new cricket::SessionDescription(); | 317 cricket::SessionDescription* desc = new cricket::SessionDescription(); |
320 desc->AddContent( | 318 desc->AddContent( |
321 ContentDescription::kChromotingContentName, kChromotingXmlNamespace, | 319 ContentDescription::kChromotingContentName, kChromotingXmlNamespace, |
322 new ContentDescription(config, "", certificate)); | 320 new ContentDescription(config, "", certificate)); |
323 return desc; | 321 return desc; |
324 } | 322 } |
325 | 323 |
326 } // namespace protocol | 324 } // namespace protocol |
327 } // namespace remoting | 325 } // namespace remoting |
OLD | NEW |