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

Side by Side Diff: runtime/bin/secure_socket.cc

Issue 910183003: Reafctor to use 'const RawAddr&' or 'RawAddr*' in the eventhandler code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor change Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/secure_socket.h" 5 #include "bin/secure_socket.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 &certificate_name)); 143 &certificate_name));
144 } 144 }
145 // If this is a server connection, it must have a certificate to connect with. 145 // If this is a server connection, it must have a certificate to connect with.
146 ASSERT(!is_server || certificate_name != NULL); 146 ASSERT(!is_server || certificate_name != NULL);
147 147
148 // The protocols_handle is guaranteed to be a valid Uint8List. 148 // The protocols_handle is guaranteed to be a valid Uint8List.
149 // It will have the correct length encoding of the protocols array. 149 // It will have the correct length encoding of the protocols array.
150 ASSERT(!Dart_IsNull(protocols_handle)); 150 ASSERT(!Dart_IsNull(protocols_handle));
151 151
152 GetFilter(args)->Connect(host_name, 152 GetFilter(args)->Connect(host_name,
153 &raw_addr, 153 raw_addr,
154 static_cast<int>(port), 154 static_cast<int>(port),
155 is_server, 155 is_server,
156 certificate_name, 156 certificate_name,
157 request_client_certificate, 157 request_client_certificate,
158 require_client_certificate, 158 require_client_certificate,
159 send_client_certificate, 159 send_client_certificate,
160 protocols_handle); 160 protocols_handle);
161 } 161 }
162 162
163 163
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 Dart_Handle SSLFilter::PeerCertificate() { 659 Dart_Handle SSLFilter::PeerCertificate() {
660 CERTCertificate* certificate = SSL_PeerCertificate(filter_); 660 CERTCertificate* certificate = SSL_PeerCertificate(filter_);
661 if (certificate == NULL) return Dart_Null(); 661 if (certificate == NULL) return Dart_Null();
662 Dart_Handle x509_object = X509FromCertificate(certificate); 662 Dart_Handle x509_object = X509FromCertificate(certificate);
663 CERT_DestroyCertificate(certificate); 663 CERT_DestroyCertificate(certificate);
664 return x509_object; 664 return x509_object;
665 } 665 }
666 666
667 667
668 void SSLFilter::Connect(const char* host_name, 668 void SSLFilter::Connect(const char* host_name,
669 RawAddr* raw_addr, 669 const RawAddr& raw_addr,
670 int port, 670 int port,
671 bool is_server, 671 bool is_server,
672 const char* certificate_name, 672 const char* certificate_name,
673 bool request_client_certificate, 673 bool request_client_certificate,
674 bool require_client_certificate, 674 bool require_client_certificate,
675 bool send_client_certificate, 675 bool send_client_certificate,
676 Dart_Handle protocols_handle) { 676 Dart_Handle protocols_handle) {
677 is_server_ = is_server; 677 is_server_ = is_server;
678 if (in_handshake_) { 678 if (in_handshake_) {
679 FATAL("Connect called twice on the same _SecureFilter."); 679 FATAL("Connect called twice on the same _SecureFilter.");
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 828
829 // Set the peer address from the address passed. The DNS has already 829 // Set the peer address from the address passed. The DNS has already
830 // been done in Dart code, so just use that address. This relies on 830 // been done in Dart code, so just use that address. This relies on
831 // following about PRNetAddr: "The raw member of the union is 831 // following about PRNetAddr: "The raw member of the union is
832 // equivalent to struct sockaddr", which is stated in the NSS 832 // equivalent to struct sockaddr", which is stated in the NSS
833 // documentation. 833 // documentation.
834 PRNetAddr peername; 834 PRNetAddr peername;
835 memset(&peername, 0, sizeof(peername)); 835 memset(&peername, 0, sizeof(peername));
836 intptr_t len = SocketAddress::GetAddrLength(raw_addr); 836 intptr_t len = SocketAddress::GetAddrLength(raw_addr);
837 ASSERT(static_cast<size_t>(len) <= sizeof(peername)); 837 ASSERT(static_cast<size_t>(len) <= sizeof(peername));
838 memmove(&peername, &raw_addr->addr, len); 838 memmove(&peername, &raw_addr.addr, len);
839 839
840 // Adjust the address family field for BSD, whose sockaddr 840 // Adjust the address family field for BSD, whose sockaddr
841 // structure has a one-byte length and one-byte address family 841 // structure has a one-byte length and one-byte address family
842 // field at the beginning. PRNetAddr has a two-byte address 842 // field at the beginning. PRNetAddr has a two-byte address
843 // family field at the beginning. 843 // family field at the beginning.
844 peername.raw.family = raw_addr->addr.sa_family; 844 peername.raw.family = raw_addr.addr.sa_family;
845 845
846 memio_SetPeerName(filter_, &peername); 846 memio_SetPeerName(filter_, &peername);
847 } 847 }
848 848
849 849
850 void SSLFilter::Handshake() { 850 void SSLFilter::Handshake() {
851 SECStatus status = SSL_ForceHandshake(filter_); 851 SECStatus status = SSL_ForceHandshake(filter_);
852 if (status == SECSuccess) { 852 if (status == SECSuccess) {
853 if (in_handshake_) { 853 if (in_handshake_) {
854 ThrowIfError(Dart_InvokeClosure( 854 ThrowIfError(Dart_InvokeClosure(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 } 1053 }
1054 if (bytes_processed > 0) { 1054 if (bytes_processed > 0) {
1055 memio_PutWriteResult(secret, bytes_processed); 1055 memio_PutWriteResult(secret, bytes_processed);
1056 } 1056 }
1057 } 1057 }
1058 return bytes_processed; 1058 return bytes_processed;
1059 } 1059 }
1060 1060
1061 } // namespace bin 1061 } // namespace bin
1062 } // namespace dart 1062 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket.h ('k') | runtime/bin/socket.h » ('j') | runtime/bin/socket_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698