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

Unified Diff: net/socket/ssl_server_socket_nss.cc

Issue 274783002: Implement SSL server socket over OpenSSL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary comment. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/socket/ssl_server_socket_nss.cc
diff --git a/net/socket/ssl_server_socket_nss.cc b/net/socket/ssl_server_socket_nss.cc
index 6abb531603dee36083f88aca4223a0183fe83052..38823e4c6caee3bf89d8f22c1871d751884d9a7e 100644
--- a/net/socket/ssl_server_socket_nss.cc
+++ b/net/socket/ssl_server_socket_nss.cc
@@ -29,6 +29,7 @@
#include <limits>
+#include "base/callback_helpers.h"
#include "base/lazy_instance.h"
#include "base/memory/ref_counted.h"
#include "crypto/rsa_private_key.h"
@@ -247,6 +248,7 @@ int SSLServerSocketNSS::SetSendBufferSize(int32 size) {
}
bool SSLServerSocketNSS::IsConnected() const {
+ // TODO(wtc): Check transport_socket_->IsConnected() as well.
wtc 2014/05/16 19:36:14 This comment should say: find out if we should che
byungchul 2014/05/16 19:50:32 Done.
return completed_handshake_;
}
@@ -291,6 +293,7 @@ bool SSLServerSocketNSS::UsingTCPFastOpen() const {
}
bool SSLServerSocketNSS::WasNpnNegotiated() const {
+ NOTIMPLEMENTED();
return false;
}
@@ -497,6 +500,8 @@ void SSLServerSocketNSS::OnSendComplete(int result) {
return;
}
+ // TODO(byungchul): This state machine is not correct. Copy the state machine
+ // of SSLClientSocketNSS::OnSendComplete() which handles it better.
if (!completed_handshake_)
return;
@@ -529,11 +534,12 @@ void SSLServerSocketNSS::OnRecvComplete(int result) {
void SSLServerSocketNSS::OnHandshakeIOComplete(int result) {
int rv = DoHandshakeLoop(result);
- if (rv != ERR_IO_PENDING) {
- net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_SERVER_HANDSHAKE, rv);
- if (!user_handshake_callback_.is_null())
- DoHandshakeCallback(rv);
- }
+ if (rv == ERR_IO_PENDING)
+ return;
+
+ net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_SERVER_HANDSHAKE, rv);
+ if (!user_handshake_callback_.is_null())
+ DoHandshakeCallback(rv);
}
// Return 0 for EOF,
@@ -725,7 +731,7 @@ int SSLServerSocketNSS::DoReadLoop(int result) {
int SSLServerSocketNSS::DoWriteLoop(int result) {
DCHECK(completed_handshake_);
- DCHECK(next_handshake_state_ == STATE_NONE);
+ DCHECK_EQ(next_handshake_state_, STATE_NONE);
if (result < 0)
return result;
@@ -772,36 +778,25 @@ int SSLServerSocketNSS::DoHandshake() {
void SSLServerSocketNSS::DoHandshakeCallback(int rv) {
DCHECK_NE(rv, ERR_IO_PENDING);
-
- CompletionCallback c = user_handshake_callback_;
- user_handshake_callback_.Reset();
- c.Run(rv > OK ? OK : rv);
+ ResetAndReturn(&user_handshake_callback_).Run(rv > OK ? OK : rv);
}
void SSLServerSocketNSS::DoReadCallback(int rv) {
DCHECK(rv != ERR_IO_PENDING);
DCHECK(!user_read_callback_.is_null());
- // Since Run may result in Read being called, clear |user_read_callback_|
- // up front.
- CompletionCallback c = user_read_callback_;
- user_read_callback_.Reset();
user_read_buf_ = NULL;
user_read_buf_len_ = 0;
- c.Run(rv);
+ ResetAndReturn(&user_read_callback_).Run(rv);
}
void SSLServerSocketNSS::DoWriteCallback(int rv) {
DCHECK(rv != ERR_IO_PENDING);
DCHECK(!user_write_callback_.is_null());
- // Since Run may result in Write being called, clear |user_write_callback_|
- // up front.
- CompletionCallback c = user_write_callback_;
- user_write_callback_.Reset();
user_write_buf_ = NULL;
user_write_buf_len_ = 0;
- c.Run(rv);
+ ResetAndReturn(&user_write_callback_).Run(rv);
}
// static

Powered by Google App Engine
This is Rietveld 408576698