| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/socket/socket_api.h" | 5 #include "extensions/browser/api/socket/socket_api.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 base::MakeUnique<base::FundamentalValue>(net::ERR_INVALID_ARGUMENT)); | 1066 base::MakeUnique<base::FundamentalValue>(net::ERR_INVALID_ARGUMENT)); |
| 1067 error_ = kSocketNotConnectedError; | 1067 error_ = kSocketNotConnectedError; |
| 1068 AsyncWorkCompleted(); | 1068 AsyncWorkCompleted(); |
| 1069 return; | 1069 return; |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 net::URLRequestContext* url_request_context = | 1072 net::URLRequestContext* url_request_context = |
| 1073 url_request_getter_->GetURLRequestContext(); | 1073 url_request_getter_->GetURLRequestContext(); |
| 1074 | 1074 |
| 1075 TLSSocket::UpgradeSocketToTLS( | 1075 TLSSocket::UpgradeSocketToTLS( |
| 1076 socket, | 1076 socket, url_request_context->ssl_config_service(), |
| 1077 url_request_context->ssl_config_service(), | |
| 1078 url_request_context->cert_verifier(), | 1077 url_request_context->cert_verifier(), |
| 1079 url_request_context->transport_security_state(), | 1078 url_request_context->transport_security_state(), |
| 1080 extension_id(), | 1079 url_request_context->cert_transparency_verifier(), |
| 1080 url_request_context->ct_policy_enforcer(), extension_id(), |
| 1081 params_->options.get(), | 1081 params_->options.get(), |
| 1082 base::Bind(&SocketSecureFunction::TlsConnectDone, this)); | 1082 base::Bind(&SocketSecureFunction::TlsConnectDone, this)); |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 void SocketSecureFunction::TlsConnectDone(std::unique_ptr<TLSSocket> socket, | 1085 void SocketSecureFunction::TlsConnectDone(std::unique_ptr<TLSSocket> socket, |
| 1086 int result) { | 1086 int result) { |
| 1087 // if an error occurred, socket MUST be NULL. | 1087 // if an error occurred, socket MUST be NULL. |
| 1088 DCHECK(result == net::OK || socket == NULL); | 1088 DCHECK(result == net::OK || socket == NULL); |
| 1089 | 1089 |
| 1090 if (socket && result == net::OK) { | 1090 if (socket && result == net::OK) { |
| 1091 ReplaceSocket(params_->socket_id, socket.release()); | 1091 ReplaceSocket(params_->socket_id, socket.release()); |
| 1092 } else { | 1092 } else { |
| 1093 RemoveSocket(params_->socket_id); | 1093 RemoveSocket(params_->socket_id); |
| 1094 error_ = net::ErrorToString(result); | 1094 error_ = net::ErrorToString(result); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 results_ = api::socket::Secure::Results::Create(result); | 1097 results_ = api::socket::Secure::Results::Create(result); |
| 1098 AsyncWorkCompleted(); | 1098 AsyncWorkCompleted(); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 } // namespace extensions | 1101 } // namespace extensions |
| OLD | NEW |