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.h" | 5 #include "remoting/protocol/jingle_session.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 if (local_private_key) { | 58 if (local_private_key) { |
59 std::vector<uint8> key_bytes; | 59 std::vector<uint8> key_bytes; |
60 CHECK(local_private_key->ExportPrivateKey(&key_bytes)); | 60 CHECK(local_private_key->ExportPrivateKey(&key_bytes)); |
61 local_private_key_.reset( | 61 local_private_key_.reset( |
62 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes)); | 62 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes)); |
63 CHECK(local_private_key_.get()); | 63 CHECK(local_private_key_.get()); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 JingleSession::~JingleSession() { | 67 JingleSession::~JingleSession() { |
68 // Reset the callback so that it's not called from Close(). | |
69 state_change_callback_.Reset(); | |
70 Close(); | 68 Close(); |
71 jingle_session_manager_->SessionDestroyed(this); | 69 jingle_session_manager_->SessionDestroyed(this); |
72 } | 70 } |
73 | 71 |
74 void JingleSession::Init(cricket::Session* cricket_session) { | 72 void JingleSession::Init(cricket::Session* cricket_session) { |
75 DCHECK(CalledOnValidThread()); | 73 DCHECK(CalledOnValidThread()); |
76 | 74 |
77 cricket_session_ = cricket_session; | 75 cricket_session_ = cricket_session; |
78 jid_ = cricket_session_->remote_name(); | 76 jid_ = cricket_session_->remote_name(); |
79 cricket_session_->SignalState.connect( | 77 cricket_session_->SignalState.connect( |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 } | 226 } |
229 | 227 |
230 const std::string& JingleSession::shared_secret() { | 228 const std::string& JingleSession::shared_secret() { |
231 DCHECK(CalledOnValidThread()); | 229 DCHECK(CalledOnValidThread()); |
232 return shared_secret_; | 230 return shared_secret_; |
233 } | 231 } |
234 | 232 |
235 | 233 |
236 void JingleSession::Close() { | 234 void JingleSession::Close() { |
237 DCHECK(CalledOnValidThread()); | 235 DCHECK(CalledOnValidThread()); |
238 | 236 // Reset the callback so that we don't call it anymore. |
Wez
2011/11/09 02:32:22
nit: Could reword: Ensure that we won't notify the
Sergey Ulanov
2011/11/09 21:24:00
Done.
| |
237 state_change_callback_.Reset(); | |
239 CloseInternal(net::ERR_CONNECTION_CLOSED, false); | 238 CloseInternal(net::ERR_CONNECTION_CLOSED, false); |
240 } | 239 } |
241 | 240 |
242 void JingleSession::OnSessionState( | 241 void JingleSession::OnSessionState( |
243 BaseSession* session, BaseSession::State state) { | 242 BaseSession* session, BaseSession::State state) { |
244 DCHECK(CalledOnValidThread()); | 243 DCHECK(CalledOnValidThread()); |
245 DCHECK_EQ(cricket_session_, session); | 244 DCHECK_EQ(cricket_session_, session); |
246 | 245 |
247 if (state_ == FAILED || state_ == CLOSED) { | 246 if (state_ == FAILED || state_ == CLOSED) { |
248 // Don't do anything if we already closed. | 247 // Don't do anything if we already closed. |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 DCHECK_NE(state_, FAILED); | 466 DCHECK_NE(state_, FAILED); |
468 | 467 |
469 state_ = new_state; | 468 state_ = new_state; |
470 if (!state_change_callback_.is_null()) | 469 if (!state_change_callback_.is_null()) |
471 state_change_callback_.Run(new_state); | 470 state_change_callback_.Run(new_state); |
472 } | 471 } |
473 } | 472 } |
474 | 473 |
475 } // namespace protocol | 474 } // namespace protocol |
476 } // namespace remoting | 475 } // namespace remoting |
OLD | NEW |