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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(). | 68 // Reset the callback so that it's not called from Close(). |
69 state_change_callback_.reset(); | 69 state_change_callback_.Reset(); |
70 Close(); | 70 Close(); |
71 jingle_session_manager_->SessionDestroyed(this); | 71 jingle_session_manager_->SessionDestroyed(this); |
72 } | 72 } |
73 | 73 |
74 void JingleSession::Init(cricket::Session* cricket_session) { | 74 void JingleSession::Init(cricket::Session* cricket_session) { |
75 DCHECK(CalledOnValidThread()); | 75 DCHECK(CalledOnValidThread()); |
76 | 76 |
77 cricket_session_ = cricket_session; | 77 cricket_session_ = cricket_session; |
78 jid_ = cricket_session_->remote_name(); | 78 jid_ = cricket_session_->remote_name(); |
79 cricket_session_->SignalState.connect( | 79 cricket_session_->SignalState.connect( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // Session may be destroyed only after it is closed. | 120 // Session may be destroyed only after it is closed. |
121 DCHECK(state_ == FAILED || state_ == CLOSED); | 121 DCHECK(state_ == FAILED || state_ == CLOSED); |
122 | 122 |
123 cricket::Session* session = cricket_session_; | 123 cricket::Session* session = cricket_session_; |
124 if (cricket_session_) | 124 if (cricket_session_) |
125 cricket_session_->SignalState.disconnect(this); | 125 cricket_session_->SignalState.disconnect(this); |
126 cricket_session_ = NULL; | 126 cricket_session_ = NULL; |
127 return session; | 127 return session; |
128 } | 128 } |
129 | 129 |
130 void JingleSession::SetStateChangeCallback(StateChangeCallback* callback) { | 130 void JingleSession::SetStateChangeCallback( |
| 131 const StateChangeCallback& callback) { |
131 DCHECK(CalledOnValidThread()); | 132 DCHECK(CalledOnValidThread()); |
132 DCHECK(callback); | 133 DCHECK(!callback.is_null()); |
133 state_change_callback_.reset(callback); | 134 state_change_callback_ = callback; |
134 } | 135 } |
135 | 136 |
136 Session::Error JingleSession::error() { | 137 Session::Error JingleSession::error() { |
137 DCHECK(CalledOnValidThread()); | 138 DCHECK(CalledOnValidThread()); |
138 return error_; | 139 return error_; |
139 } | 140 } |
140 | 141 |
141 void JingleSession::CreateStreamChannel( | 142 void JingleSession::CreateStreamChannel( |
142 const std::string& name, const StreamChannelCallback& callback) { | 143 const std::string& name, const StreamChannelCallback& callback) { |
143 DCHECK(CalledOnValidThread()); | 144 DCHECK(CalledOnValidThread()); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 460 } |
460 | 461 |
461 void JingleSession::SetState(State new_state) { | 462 void JingleSession::SetState(State new_state) { |
462 DCHECK(CalledOnValidThread()); | 463 DCHECK(CalledOnValidThread()); |
463 | 464 |
464 if (new_state != state_) { | 465 if (new_state != state_) { |
465 DCHECK_NE(state_, CLOSED); | 466 DCHECK_NE(state_, CLOSED); |
466 DCHECK_NE(state_, FAILED); | 467 DCHECK_NE(state_, FAILED); |
467 | 468 |
468 state_ = new_state; | 469 state_ = new_state; |
469 if (state_change_callback_.get()) | 470 if (!state_change_callback_.is_null()) |
470 state_change_callback_->Run(new_state); | 471 state_change_callback_.Run(new_state); |
471 } | 472 } |
472 } | 473 } |
473 | 474 |
474 } // namespace protocol | 475 } // namespace protocol |
475 } // namespace remoting | 476 } // namespace remoting |
OLD | NEW |