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

Side by Side Diff: net/socket/ssl_client_socket_mac.cc

Issue 7084007: Adds URLRequestJob bytes read to NetLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 9 years, 6 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) 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 "net/socket/ssl_client_socket_mac.h" 5 #include "net/socket/ssl_client_socket_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 #include <netdb.h> 8 #include <netdb.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 // There's a subtle difference here in semantics of the "would block" errors. 1188 // There's a subtle difference here in semantics of the "would block" errors.
1189 // In our code, ERR_IO_PENDING means the whole operation is async, while 1189 // In our code, ERR_IO_PENDING means the whole operation is async, while
1190 // errSSLWouldBlock means that the stream isn't ending (and is often returned 1190 // errSSLWouldBlock means that the stream isn't ending (and is often returned
1191 // along with partial data). So even though "would block" is returned, if we 1191 // along with partial data). So even though "would block" is returned, if we
1192 // have data, let's just return it. This is further complicated by the fact 1192 // have data, let's just return it. This is further complicated by the fact
1193 // that errSSLWouldBlock is also used to short-circuit SSLRead()'s 1193 // that errSSLWouldBlock is also used to short-circuit SSLRead()'s
1194 // transparent renegotiation, so that we can update our state machine above, 1194 // transparent renegotiation, so that we can update our state machine above,
1195 // which otherwise would get out of sync with the SSLContextRef's internal 1195 // which otherwise would get out of sync with the SSLContextRef's internal
1196 // state machine. 1196 // state machine.
1197 if (processed > 0) { 1197 if (processed > 0) {
1198 LogByteTransfer(net_log_, NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, 1198 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED,
1199 processed, user_read_buf_->data()); 1199 processed, user_read_buf_->data());
1200 return processed; 1200 return processed;
1201 } 1201 }
1202 1202
1203 switch (status) { 1203 switch (status) {
1204 case errSSLClosedNoNotify: 1204 case errSSLClosedNoNotify:
1205 // TODO(wtc): Unless we have received the close_notify alert, we need to 1205 // TODO(wtc): Unless we have received the close_notify alert, we need to
1206 // return an error code indicating that the SSL connection ended 1206 // return an error code indicating that the SSL connection ended
1207 // uncleanly, a potential truncation attack. See http://crbug.com/18586. 1207 // uncleanly, a potential truncation attack. See http://crbug.com/18586.
1208 return OK; 1208 return OK;
1209 1209
1210 default: 1210 default:
1211 return NetErrorFromOSStatus(status); 1211 return NetErrorFromOSStatus(status);
1212 } 1212 }
1213 } 1213 }
1214 1214
1215 int SSLClientSocketMac::DoPayloadWrite() { 1215 int SSLClientSocketMac::DoPayloadWrite() {
1216 // Too much data in flight? 1216 // Too much data in flight?
1217 if (send_buffer_.size() > kWriteSizePauseLimit) 1217 if (send_buffer_.size() > kWriteSizePauseLimit)
1218 return ERR_IO_PENDING; 1218 return ERR_IO_PENDING;
1219 1219
1220 size_t processed = 0; 1220 size_t processed = 0;
1221 OSStatus status = SSLWrite(ssl_context_, 1221 OSStatus status = SSLWrite(ssl_context_,
1222 user_write_buf_->data(), 1222 user_write_buf_->data(),
1223 user_write_buf_len_, 1223 user_write_buf_len_,
1224 &processed); 1224 &processed);
1225 1225
1226 if (processed > 0) { 1226 if (processed > 0) {
1227 LogByteTransfer(net_log_, NetLog::TYPE_SSL_SOCKET_BYTES_SENT, processed, 1227 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, processed,
1228 user_write_buf_->data()); 1228 user_write_buf_->data());
1229 return processed; 1229 return processed;
1230 } 1230 }
1231 1231
1232 return NetErrorFromOSStatus(status); 1232 return NetErrorFromOSStatus(status);
1233 } 1233 }
1234 1234
1235 int SSLClientSocketMac::DoCompletedRenegotiation(int result) { 1235 int SSLClientSocketMac::DoCompletedRenegotiation(int result) {
1236 // The user had a read in progress, which was interrupted by the 1236 // The user had a read in progress, which was interrupted by the
1237 // renegotiation. Return the application data that was processed after the 1237 // renegotiation. Return the application data that was processed after the
1238 // handshake completed. 1238 // handshake completed.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 if (rv < 0 && rv != ERR_IO_PENDING) { 1393 if (rv < 0 && rv != ERR_IO_PENDING) {
1394 us->write_io_buf_ = NULL; 1394 us->write_io_buf_ = NULL;
1395 return OSStatusFromNetError(rv); 1395 return OSStatusFromNetError(rv);
1396 } 1396 }
1397 1397
1398 // always lie to our caller 1398 // always lie to our caller
1399 return noErr; 1399 return noErr;
1400 } 1400 }
1401 1401
1402 } // namespace net 1402 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698