Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: remoting/protocol/jingle_session.cc

Issue 1534193004: Use std::move() instead of scoped_ptr<>::Pass(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.h" 5 #include "remoting/protocol/jingle_session.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return error_; 89 return error_;
90 } 90 }
91 91
92 void JingleSession::StartConnection(const std::string& peer_jid, 92 void JingleSession::StartConnection(const std::string& peer_jid,
93 scoped_ptr<Authenticator> authenticator) { 93 scoped_ptr<Authenticator> authenticator) {
94 DCHECK(CalledOnValidThread()); 94 DCHECK(CalledOnValidThread());
95 DCHECK(authenticator.get()); 95 DCHECK(authenticator.get());
96 DCHECK_EQ(authenticator->state(), Authenticator::MESSAGE_READY); 96 DCHECK_EQ(authenticator->state(), Authenticator::MESSAGE_READY);
97 97
98 peer_jid_ = peer_jid; 98 peer_jid_ = peer_jid;
99 authenticator_ = authenticator.Pass(); 99 authenticator_ = std::move(authenticator);
100 100
101 // Generate random session ID. There are usually not more than 1 101 // Generate random session ID. There are usually not more than 1
102 // concurrent session per host, so a random 64-bit integer provides 102 // concurrent session per host, so a random 64-bit integer provides
103 // enough entropy. In the worst case connection will fail when two 103 // enough entropy. In the worst case connection will fail when two
104 // clients generate the same session ID concurrently. 104 // clients generate the same session ID concurrently.
105 session_id_ = base::Uint64ToString( 105 session_id_ = base::Uint64ToString(
106 base::RandGenerator(std::numeric_limits<uint64_t>::max())); 106 base::RandGenerator(std::numeric_limits<uint64_t>::max()));
107 107
108 transport_ = session_manager_->transport_factory_->CreateTransport(); 108 transport_ = session_manager_->transport_factory_->CreateTransport();
109 109
(...skipping 11 matching lines...) Expand all
121 121
122 void JingleSession::InitializeIncomingConnection( 122 void JingleSession::InitializeIncomingConnection(
123 const JingleMessage& initiate_message, 123 const JingleMessage& initiate_message,
124 scoped_ptr<Authenticator> authenticator) { 124 scoped_ptr<Authenticator> authenticator) {
125 DCHECK(CalledOnValidThread()); 125 DCHECK(CalledOnValidThread());
126 DCHECK(initiate_message.description.get()); 126 DCHECK(initiate_message.description.get());
127 DCHECK(authenticator.get()); 127 DCHECK(authenticator.get());
128 DCHECK_EQ(authenticator->state(), Authenticator::WAITING_MESSAGE); 128 DCHECK_EQ(authenticator->state(), Authenticator::WAITING_MESSAGE);
129 129
130 peer_jid_ = initiate_message.from; 130 peer_jid_ = initiate_message.from;
131 authenticator_ = authenticator.Pass(); 131 authenticator_ = std::move(authenticator);
132 session_id_ = initiate_message.sid; 132 session_id_ = initiate_message.sid;
133 133
134 SetState(ACCEPTING); 134 SetState(ACCEPTING);
135 135
136 config_ = 136 config_ =
137 SessionConfig::SelectCommon(initiate_message.description->config(), 137 SessionConfig::SelectCommon(initiate_message.description->config(),
138 session_manager_->protocol_config_.get()); 138 session_manager_->protocol_config_.get());
139 if (!config_) { 139 if (!config_) {
140 LOG(WARNING) << "Rejecting connection from " << peer_jid_ 140 LOG(WARNING) << "Rejecting connection from " << peer_jid_
141 << " because no compatible configuration has been found."; 141 << " because no compatible configuration has been found.";
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 // Send the session-accept message. 176 // Send the session-accept message.
177 JingleMessage message(peer_jid_, JingleMessage::SESSION_ACCEPT, 177 JingleMessage message(peer_jid_, JingleMessage::SESSION_ACCEPT,
178 session_id_); 178 session_id_);
179 179
180 scoped_ptr<buzz::XmlElement> auth_message; 180 scoped_ptr<buzz::XmlElement> auth_message;
181 if (authenticator_->state() == Authenticator::MESSAGE_READY) 181 if (authenticator_->state() == Authenticator::MESSAGE_READY)
182 auth_message = authenticator_->GetNextMessage(); 182 auth_message = authenticator_->GetNextMessage();
183 183
184 message.description.reset(new ContentDescription( 184 message.description.reset(new ContentDescription(
185 CandidateSessionConfig::CreateFrom(*config_), auth_message.Pass())); 185 CandidateSessionConfig::CreateFrom(*config_), std::move(auth_message)));
186 SendMessage(message); 186 SendMessage(message);
187 187
188 // Update state. 188 // Update state.
189 SetState(ACCEPTED); 189 SetState(ACCEPTED);
190 190
191 if (authenticator_->state() == Authenticator::ACCEPTED) { 191 if (authenticator_->state() == Authenticator::ACCEPTED) {
192 OnAuthenticated(); 192 OnAuthenticated();
193 } else { 193 } else {
194 DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE); 194 DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE);
195 if (authenticator_->started()) { 195 if (authenticator_->started()) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 Close(PEER_IS_OFFLINE); 319 Close(PEER_IS_OFFLINE);
320 } 320 }
321 } 321 }
322 } 322 }
323 323
324 void JingleSession::OnOutgoingTransportInfo( 324 void JingleSession::OnOutgoingTransportInfo(
325 scoped_ptr<XmlElement> transport_info) { 325 scoped_ptr<XmlElement> transport_info) {
326 DCHECK(CalledOnValidThread()); 326 DCHECK(CalledOnValidThread());
327 327
328 JingleMessage message(peer_jid_, JingleMessage::TRANSPORT_INFO, session_id_); 328 JingleMessage message(peer_jid_, JingleMessage::TRANSPORT_INFO, session_id_);
329 message.transport_info = transport_info.Pass(); 329 message.transport_info = std::move(transport_info);
330 330
331 scoped_ptr<IqRequest> request = session_manager_->iq_sender()->SendIq( 331 scoped_ptr<IqRequest> request = session_manager_->iq_sender()->SendIq(
332 message.ToXml(), base::Bind(&JingleSession::OnTransportInfoResponse, 332 message.ToXml(), base::Bind(&JingleSession::OnTransportInfoResponse,
333 base::Unretained(this))); 333 base::Unretained(this)));
334 if (request) { 334 if (request) {
335 request->SetTimeout(base::TimeDelta::FromSeconds(kTransportInfoTimeout)); 335 request->SetTimeout(base::TimeDelta::FromSeconds(kTransportInfoTimeout));
336 transport_info_requests_.push_back(request.release()); 336 transport_info_requests_.push_back(request.release());
337 } else { 337 } else {
338 LOG(ERROR) << "Failed to send a transport-info message"; 338 LOG(ERROR) << "Failed to send a transport-info message";
339 } 339 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 } 602 }
603 } 603 }
604 604
605 bool JingleSession::is_session_active() { 605 bool JingleSession::is_session_active() {
606 return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED || 606 return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED ||
607 state_ == AUTHENTICATING || state_ == AUTHENTICATED; 607 state_ == AUTHENTICATING || state_ == AUTHENTICATED;
608 } 608 }
609 609
610 } // namespace protocol 610 } // namespace protocol
611 } // namespace remoting 611 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698