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