| 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/crypto/rsa_private_key.h" | |
| 8 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "crypto/rsa_private_key.h" |
| 9 #include "jingle/glue/channel_socket_adapter.h" | 9 #include "jingle/glue/channel_socket_adapter.h" |
| 10 #include "jingle/glue/stream_socket_adapter.h" | 10 #include "jingle/glue/stream_socket_adapter.h" |
| 11 #include "net/base/cert_status_flags.h" | 11 #include "net/base/cert_status_flags.h" |
| 12 #include "net/base/cert_verifier.h" | 12 #include "net/base/cert_verifier.h" |
| 13 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/ssl_config_service.h" | 15 #include "net/base/ssl_config_service.h" |
| 16 #include "net/base/x509_certificate.h" | 16 #include "net/base/x509_certificate.h" |
| 17 #include "net/socket/client_socket_factory.h" | 17 #include "net/socket/client_socket_factory.h" |
| 18 #include "net/socket/ssl_client_socket.h" | 18 #include "net/socket/ssl_client_socket.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // static | 77 // static |
| 78 JingleSession* JingleSession::CreateClientSession( | 78 JingleSession* JingleSession::CreateClientSession( |
| 79 JingleSessionManager* manager) { | 79 JingleSessionManager* manager) { |
| 80 return new JingleSession(manager, NULL, NULL); | 80 return new JingleSession(manager, NULL, NULL); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // static | 83 // static |
| 84 JingleSession* JingleSession::CreateServerSession( | 84 JingleSession* JingleSession::CreateServerSession( |
| 85 JingleSessionManager* manager, | 85 JingleSessionManager* manager, |
| 86 scoped_refptr<net::X509Certificate> certificate, | 86 scoped_refptr<net::X509Certificate> certificate, |
| 87 base::RSAPrivateKey* key) { | 87 crypto::RSAPrivateKey* key) { |
| 88 return new JingleSession(manager, certificate, key); | 88 return new JingleSession(manager, certificate, key); |
| 89 } | 89 } |
| 90 | 90 |
| 91 JingleSession::JingleSession( | 91 JingleSession::JingleSession( |
| 92 JingleSessionManager* jingle_session_manager, | 92 JingleSessionManager* jingle_session_manager, |
| 93 scoped_refptr<net::X509Certificate> server_cert, base::RSAPrivateKey* key) | 93 scoped_refptr<net::X509Certificate> server_cert, crypto::RSAPrivateKey* key) |
| 94 : jingle_session_manager_(jingle_session_manager), | 94 : jingle_session_manager_(jingle_session_manager), |
| 95 server_cert_(server_cert), | 95 server_cert_(server_cert), |
| 96 state_(INITIALIZING), | 96 state_(INITIALIZING), |
| 97 closed_(false), | 97 closed_(false), |
| 98 closing_(false), | 98 closing_(false), |
| 99 cricket_session_(NULL), | 99 cricket_session_(NULL), |
| 100 event_channel_(NULL), | 100 event_channel_(NULL), |
| 101 video_channel_(NULL), | 101 video_channel_(NULL), |
| 102 ssl_connections_(0), | 102 ssl_connections_(0), |
| 103 ALLOW_THIS_IN_INITIALIZER_LIST(connect_callback_( | 103 ALLOW_THIS_IN_INITIALIZER_LIST(connect_callback_( |
| 104 NewCallback(this, &JingleSession::OnSSLConnect))) { | 104 NewCallback(this, &JingleSession::OnSSLConnect))) { |
| 105 // TODO(hclam): Need a better way to clone a key. | 105 // TODO(hclam): Need a better way to clone a key. |
| 106 if (key) { | 106 if (key) { |
| 107 std::vector<uint8> key_bytes; | 107 std::vector<uint8> key_bytes; |
| 108 CHECK(key->ExportPrivateKey(&key_bytes)); | 108 CHECK(key->ExportPrivateKey(&key_bytes)); |
| 109 key_.reset(base::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes)); | 109 key_.reset(crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes)); |
| 110 CHECK(key_.get()); | 110 CHECK(key_.get()); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 JingleSession::~JingleSession() { | 114 JingleSession::~JingleSession() { |
| 115 DCHECK(closed_); | 115 DCHECK(closed_); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void JingleSession::Init(cricket::Session* cricket_session) { | 118 void JingleSession::Init(cricket::Session* cricket_session) { |
| 119 DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current()); | 119 DCHECK_EQ(jingle_session_manager_->message_loop(), MessageLoop::current()); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 520 |
| 521 state_ = new_state; | 521 state_ = new_state; |
| 522 if (!closed_ && state_change_callback_.get()) | 522 if (!closed_ && state_change_callback_.get()) |
| 523 state_change_callback_->Run(new_state); | 523 state_change_callback_->Run(new_state); |
| 524 } | 524 } |
| 525 } | 525 } |
| 526 | 526 |
| 527 } // namespace protocol | 527 } // namespace protocol |
| 528 | 528 |
| 529 } // namespace remoting | 529 } // namespace remoting |
| OLD | NEW |