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

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

Issue 6394004: Log source ip and port in NetLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK. Created 9 years, 11 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
« no previous file with comments | « net/socket/tcp_client_socket_libevent.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/tcp_client_socket_win.h" 5 #include "net/socket/tcp_client_socket_win.h"
6 6
7 #include <mstcpip.h> 7 #include <mstcpip.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 sizeof(keepalive_vals), NULL, 0, 750 sizeof(keepalive_vals), NULL, 0,
751 &bytes_returned, NULL, NULL); 751 &bytes_returned, NULL, NULL);
752 DCHECK(!rv) << "Could not enable TCP Keep-Alive for socket: " << socket_ 752 DCHECK(!rv) << "Could not enable TCP Keep-Alive for socket: " << socket_
753 << " [error: " << WSAGetLastError() << "]."; 753 << " [error: " << WSAGetLastError() << "].";
754 754
755 // Disregard any failure in disabling nagle or enabling TCP Keep-Alive. 755 // Disregard any failure in disabling nagle or enabling TCP Keep-Alive.
756 return 0; 756 return 0;
757 } 757 }
758 758
759 void TCPClientSocketWin::LogConnectCompletion(int net_error) { 759 void TCPClientSocketWin::LogConnectCompletion(int net_error) {
760 scoped_refptr<NetLog::EventParameters> params;
761 if (net_error != OK)
762 params = new NetLogIntegerParameter("net_error", net_error);
763 net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT, params);
764 if (net_error == OK) 760 if (net_error == OK)
765 UpdateConnectionTypeHistograms(CONNECTION_ANY); 761 UpdateConnectionTypeHistograms(CONNECTION_ANY);
762
763 if (net_error != OK) {
764 net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT,
765 make_scoped_refptr(
766 new NetLogIntegerParameter("net_error", net_error)));
767 return;
768 }
769
770 struct sockaddr_storage source_address;
771 socklen_t addrlen = sizeof(source_address);
772 int rv = getsockname(
773 socket_, reinterpret_cast<struct sockaddr*>(&source_address), &addrlen);
774 if (rv != 0) {
775 LOG(ERROR) << "getsockname() [rv: " << rv
776 << "] error: " << WSAGetLastError();
777 NOTREACHED();
778 scoped_refptr<NetLog::EventParameters> params;
779 net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT, NULL);
780 return;
781 }
782
783 const std::string source_address_str =
784 NetAddressToStringWithPort(
785 reinterpret_cast<const struct sockaddr*>(&source_address),
786 sizeof(source_address));
787 net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT,
788 make_scoped_refptr(new NetLogStringParameter(
789 "source address",
790 source_address_str)));
766 } 791 }
767 792
768 void TCPClientSocketWin::DoReadCallback(int rv) { 793 void TCPClientSocketWin::DoReadCallback(int rv) {
769 DCHECK_NE(rv, ERR_IO_PENDING); 794 DCHECK_NE(rv, ERR_IO_PENDING);
770 DCHECK(read_callback_); 795 DCHECK(read_callback_);
771 796
772 // since Run may result in Read being called, clear read_callback_ up front. 797 // since Run may result in Read being called, clear read_callback_ up front.
773 CompletionCallback* c = read_callback_; 798 CompletionCallback* c = read_callback_;
774 read_callback_ = NULL; 799 read_callback_ = NULL;
775 c->Run(rv); 800 c->Run(rv);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 use_history_.set_was_used_to_convey_data(); 884 use_history_.set_was_used_to_convey_data();
860 LogByteTransfer(net_log_, NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes, 885 LogByteTransfer(net_log_, NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes,
861 core_->write_buffer_.buf); 886 core_->write_buffer_.buf);
862 } 887 }
863 } 888 }
864 core_->write_iobuffer_ = NULL; 889 core_->write_iobuffer_ = NULL;
865 DoWriteCallback(rv); 890 DoWriteCallback(rv);
866 } 891 }
867 892
868 } // namespace net 893 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_client_socket_libevent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698