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

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

Issue 7796026: Pass SessionConfig by reference instead of pointer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/jingle_session.h ('k') | remoting/protocol/jingle_session_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 JingleSession::JingleSession( 50 JingleSession::JingleSession(
51 JingleSessionManager* jingle_session_manager, 51 JingleSessionManager* jingle_session_manager,
52 const std::string& local_cert, 52 const std::string& local_cert,
53 crypto::RSAPrivateKey* local_private_key, 53 crypto::RSAPrivateKey* local_private_key,
54 const std::string& peer_public_key) 54 const std::string& peer_public_key)
55 : jingle_session_manager_(jingle_session_manager), 55 : jingle_session_manager_(jingle_session_manager),
56 local_cert_(local_cert), 56 local_cert_(local_cert),
57 state_(INITIALIZING), 57 state_(INITIALIZING),
58 closing_(false), 58 closing_(false),
59 cricket_session_(NULL), 59 cricket_session_(NULL),
60 config_set_(false),
60 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { 61 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
61 // TODO(hclam): Need a better way to clone a key. 62 // TODO(hclam): Need a better way to clone a key.
62 if (local_private_key) { 63 if (local_private_key) {
63 std::vector<uint8> key_bytes; 64 std::vector<uint8> key_bytes;
64 CHECK(local_private_key->ExportPrivateKey(&key_bytes)); 65 CHECK(local_private_key->ExportPrivateKey(&key_bytes));
65 local_private_key_.reset( 66 local_private_key_.reset(
66 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes)); 67 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes));
67 CHECK(local_private_key_.get()); 68 CHECK(local_private_key_.get());
68 } 69 }
69 } 70 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 DCHECK(!candidate_config_.get()); 184 DCHECK(!candidate_config_.get());
184 DCHECK(candidate_config); 185 DCHECK(candidate_config);
185 candidate_config_.reset(candidate_config); 186 candidate_config_.reset(candidate_config);
186 } 187 }
187 188
188 const std::string& JingleSession::local_certificate() const { 189 const std::string& JingleSession::local_certificate() const {
189 DCHECK(CalledOnValidThread()); 190 DCHECK(CalledOnValidThread());
190 return local_cert_; 191 return local_cert_;
191 } 192 }
192 193
193 const SessionConfig* JingleSession::config() { 194 const SessionConfig& JingleSession::config() {
194 // TODO(sergeyu): Fix ChromotingHost so that it doesn't call this 195 // TODO(sergeyu): Fix ChromotingHost so that it doesn't call this
195 // method on invalid thread and uncomment this DCHECK. 196 // method on invalid thread and uncomment this DCHECK.
196 // See crbug.com/88600 . 197 // See crbug.com/88600 .
197 // DCHECK(CalledOnValidThread()); 198 // DCHECK(CalledOnValidThread());
198 DCHECK(config_.get()); 199 DCHECK(config_set_);
199 return config_.get(); 200 return config_;
200 } 201 }
201 202
202 void JingleSession::set_config(const SessionConfig* config) { 203 void JingleSession::set_config(const SessionConfig& config) {
203 DCHECK(CalledOnValidThread()); 204 DCHECK(CalledOnValidThread());
204 DCHECK(!config_.get()); 205 DCHECK(!config_set_);
205 DCHECK(config); 206 config_ = config;
206 config_.reset(config); 207 config_set_ = true;
207 } 208 }
208 209
209 const std::string& JingleSession::initiator_token() { 210 const std::string& JingleSession::initiator_token() {
210 DCHECK(CalledOnValidThread()); 211 DCHECK(CalledOnValidThread());
211 return initiator_token_; 212 return initiator_token_;
212 } 213 }
213 214
214 void JingleSession::set_initiator_token(const std::string& initiator_token) { 215 void JingleSession::set_initiator_token(const std::string& initiator_token) {
215 DCHECK(CalledOnValidThread()); 216 DCHECK(CalledOnValidThread());
216 initiator_token_ = initiator_token; 217 initiator_token_ = initiator_token;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 const protocol::ContentDescription* content_description = 333 const protocol::ContentDescription* content_description =
333 static_cast<const protocol::ContentDescription*>(content->description); 334 static_cast<const protocol::ContentDescription*>(content->description);
334 CHECK(content_description); 335 CHECK(content_description);
335 336
336 remote_cert_ = content_description->certificate(); 337 remote_cert_ = content_description->certificate();
337 if (remote_cert_.empty()) { 338 if (remote_cert_.empty()) {
338 LOG(ERROR) << "Connection response does not specify certificate"; 339 LOG(ERROR) << "Connection response does not specify certificate";
339 return false; 340 return false;
340 } 341 }
341 342
342 scoped_ptr<SessionConfig> config( 343 SessionConfig config;
343 content_description->config()->GetFinalConfig()); 344 if (!content_description->config()->GetFinalConfig(&config)) {
344 if (!config.get()) {
345 LOG(ERROR) << "Connection response does not specify configuration"; 345 LOG(ERROR) << "Connection response does not specify configuration";
346 return false; 346 return false;
347 } 347 }
348 if (!candidate_config()->IsSupported(config.get())) { 348 if (!candidate_config()->IsSupported(config)) {
349 LOG(ERROR) << "Connection response specifies an invalid configuration"; 349 LOG(ERROR) << "Connection response specifies an invalid configuration";
350 return false; 350 return false;
351 } 351 }
352 352
353 set_config(config.release()); 353 set_config(config);
354 return true; 354 return true;
355 } 355 }
356 356
357 void JingleSession::OnAccept() { 357 void JingleSession::OnAccept() {
358 DCHECK(CalledOnValidThread()); 358 DCHECK(CalledOnValidThread());
359 359
360 // If we initiated the session, store the candidate configuration that the 360 // If we initiated the session, store the candidate configuration that the
361 // host responded with, to refer to later. 361 // host responded with, to refer to later.
362 if (cricket_session_->initiator()) { 362 if (cricket_session_->initiator()) {
363 if (!InitializeConfigFromDescription( 363 if (!InitializeConfigFromDescription(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 DCHECK_NE(state_, FAILED); 472 DCHECK_NE(state_, FAILED);
473 473
474 state_ = new_state; 474 state_ = new_state;
475 if (state_change_callback_.get()) 475 if (state_change_callback_.get())
476 state_change_callback_->Run(new_state); 476 state_change_callback_->Run(new_state);
477 } 477 }
478 } 478 }
479 479
480 } // namespace protocol 480 } // namespace protocol
481 } // namespace remoting 481 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session.h ('k') | remoting/protocol/jingle_session_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698