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

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

Issue 1062413002: Remove unnecessary instrumentation for several jank bugs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fixes Created 5 years, 8 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
« no previous file with comments | « net/socket/ssl_session_cache_openssl.cc ('k') | net/socket/tcp_socket_win.cc » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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.h" 5 #include "net/socket/tcp_client_socket.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/profiler/scoped_tracker.h" 9 #include "base/profiler/scoped_tracker.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 result = socket_->Bind(address); 57 result = socket_->Bind(address);
58 if (result != OK) 58 if (result != OK)
59 return result; 59 return result;
60 60
61 bind_address_.reset(new IPEndPoint(address)); 61 bind_address_.reset(new IPEndPoint(address));
62 return OK; 62 return OK;
63 } 63 }
64 64
65 int TCPClientSocket::Connect(const CompletionCallback& callback) { 65 int TCPClientSocket::Connect(const CompletionCallback& callback) {
66 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
67 tracked_objects::ScopedTracker tracking_profile(
68 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 TCPClientSocket::Connect"));
69
70 DCHECK(!callback.is_null()); 66 DCHECK(!callback.is_null());
71 67
72 // If connecting or already connected, then just return OK. 68 // If connecting or already connected, then just return OK.
73 if (socket_->IsValid() && current_address_index_ >= 0) 69 if (socket_->IsValid() && current_address_index_ >= 0)
74 return OK; 70 return OK;
75 71
76 socket_->StartLoggingMultipleConnectAttempts(addresses_); 72 socket_->StartLoggingMultipleConnectAttempts(addresses_);
77 73
78 // We will try to connect to each address in addresses_. Start with the 74 // We will try to connect to each address in addresses_. Start with the
79 // first one in the list. 75 // first one in the list.
(...skipping 29 matching lines...) Expand all
109 NOTREACHED() << "bad state " << state; 105 NOTREACHED() << "bad state " << state;
110 rv = ERR_UNEXPECTED; 106 rv = ERR_UNEXPECTED;
111 break; 107 break;
112 } 108 }
113 } while (rv != ERR_IO_PENDING && next_connect_state_ != CONNECT_STATE_NONE); 109 } while (rv != ERR_IO_PENDING && next_connect_state_ != CONNECT_STATE_NONE);
114 110
115 return rv; 111 return rv;
116 } 112 }
117 113
118 int TCPClientSocket::DoConnect() { 114 int TCPClientSocket::DoConnect() {
119 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
120 tracked_objects::ScopedTracker tracking_profile1(
121 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 TCPClientSocket::DoConnect1"));
122
123 DCHECK_GE(current_address_index_, 0); 115 DCHECK_GE(current_address_index_, 0);
124 DCHECK_LT(current_address_index_, static_cast<int>(addresses_.size())); 116 DCHECK_LT(current_address_index_, static_cast<int>(addresses_.size()));
125 117
126 const IPEndPoint& endpoint = addresses_[current_address_index_]; 118 const IPEndPoint& endpoint = addresses_[current_address_index_];
127 119
128 if (previously_disconnected_) { 120 {
129 use_history_.Reset(); 121 // TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed.
130 previously_disconnected_ = false; 122 tracked_objects::ScopedTracker tracking_profile(
131 } 123 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 TCPClientSocket::DoConnect"));
132 124
133 next_connect_state_ = CONNECT_STATE_CONNECT_COMPLETE; 125 if (previously_disconnected_) {
126 use_history_.Reset();
127 previously_disconnected_ = false;
128 }
134 129
135 if (socket_->IsValid()) { 130 next_connect_state_ = CONNECT_STATE_CONNECT_COMPLETE;
136 DCHECK(bind_address_);
137 } else {
138 int result = OpenSocket(endpoint.GetFamily());
139 if (result != OK)
140 return result;
141 131
142 if (bind_address_) { 132 if (socket_->IsValid()) {
143 result = socket_->Bind(*bind_address_); 133 DCHECK(bind_address_);
144 if (result != OK) { 134 } else {
145 socket_->Close(); 135 int result = OpenSocket(endpoint.GetFamily());
136 if (result != OK)
146 return result; 137 return result;
138
139 if (bind_address_) {
140 result = socket_->Bind(*bind_address_);
141 if (result != OK) {
142 socket_->Close();
143 return result;
144 }
147 } 145 }
148 } 146 }
149 } 147 }
150 148
151 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
152 tracked_objects::ScopedTracker tracking_profile2(
153 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 TCPClientSocket::DoConnect2"));
154
155 // |socket_| is owned by this class and the callback won't be run once 149 // |socket_| is owned by this class and the callback won't be run once
156 // |socket_| is gone. Therefore, it is safe to use base::Unretained() here. 150 // |socket_| is gone. Therefore, it is safe to use base::Unretained() here.
157 return socket_->Connect(endpoint, 151 return socket_->Connect(endpoint,
158 base::Bind(&TCPClientSocket::DidCompleteConnect, 152 base::Bind(&TCPClientSocket::DidCompleteConnect,
159 base::Unretained(this))); 153 base::Unretained(this)));
160 } 154 }
161 155
162 int TCPClientSocket::DoConnectComplete(int result) { 156 int TCPClientSocket::DoConnectComplete(int result) {
163 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed.
164 tracked_objects::ScopedTracker tracking_profile(
165 FROM_HERE_WITH_EXPLICIT_FUNCTION(
166 "436634 TCPClientSocket::DoConnectComplete"));
167
168 if (result == OK) { 157 if (result == OK) {
169 use_history_.set_was_ever_connected(); 158 use_history_.set_was_ever_connected();
170 return OK; // Done! 159 return OK; // Done!
171 } 160 }
172 161
173 // Close whatever partially connected socket we currently have. 162 // Close whatever partially connected socket we currently have.
174 DoDisconnect(); 163 DoDisconnect();
175 164
176 // Try to fall back to the next address in the list. 165 // Try to fall back to the next address in the list.
177 if (current_address_index_ + 1 < static_cast<int>(addresses_.size())) { 166 if (current_address_index_ + 1 < static_cast<int>(addresses_.size())) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 int result = socket_->Open(family); 326 int result = socket_->Open(family);
338 if (result != OK) 327 if (result != OK)
339 return result; 328 return result;
340 329
341 socket_->SetDefaultOptionsForClient(); 330 socket_->SetDefaultOptionsForClient();
342 331
343 return OK; 332 return OK;
344 } 333 }
345 334
346 } // namespace net 335 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_session_cache_openssl.cc ('k') | net/socket/tcp_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698