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

Side by Side Diff: net/spdy/spdy_network_transaction.cc

Issue 848006: Generalize the net module's LoadLog facility from a passive container, to an event stream (NetLog). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Split up RequestTracker into ConnectJobTracker+RequestTracker+RequestTrackerBase, address comments Created 10 years, 9 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/spdy/spdy_network_transaction.h ('k') | net/spdy/spdy_network_transaction_unittest.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/spdy/spdy_network_transaction.h" 5 #include "net/spdy/spdy_network_transaction.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/stats_counters.h" 10 #include "base/stats_counters.h"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 39
40 SpdyNetworkTransaction::~SpdyNetworkTransaction() { 40 SpdyNetworkTransaction::~SpdyNetworkTransaction() {
41 LOG(INFO) << "SpdyNetworkTransaction dead. " << this; 41 LOG(INFO) << "SpdyNetworkTransaction dead. " << this;
42 if (stream_.get()) 42 if (stream_.get())
43 stream_->Cancel(); 43 stream_->Cancel();
44 } 44 }
45 45
46 int SpdyNetworkTransaction::Start(const HttpRequestInfo* request_info, 46 int SpdyNetworkTransaction::Start(const HttpRequestInfo* request_info,
47 CompletionCallback* callback, 47 CompletionCallback* callback,
48 LoadLog* load_log) { 48 const BoundNetLog& net_log) {
49 CHECK(request_info); 49 CHECK(request_info);
50 CHECK(callback); 50 CHECK(callback);
51 51
52 SIMPLE_STATS_COUNTER("SpdyNetworkTransaction.Count"); 52 SIMPLE_STATS_COUNTER("SpdyNetworkTransaction.Count");
53 53
54 load_log_ = load_log; 54 net_log_ = net_log;
55 request_ = request_info; 55 request_ = request_info;
56 start_time_ = base::TimeTicks::Now(); 56 start_time_ = base::TimeTicks::Now();
57 57
58 next_state_ = STATE_INIT_CONNECTION; 58 next_state_ = STATE_INIT_CONNECTION;
59 int rv = DoLoop(OK); 59 int rv = DoLoop(OK);
60 if (rv == ERR_IO_PENDING) 60 if (rv == ERR_IO_PENDING)
61 user_callback_ = callback; 61 user_callback_ = callback;
62 return rv; 62 return rv;
63 } 63 }
64 64
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (!request_) 152 if (!request_)
153 return 0; 153 return 0;
154 154
155 int rv = result; 155 int rv = result;
156 do { 156 do {
157 State state = next_state_; 157 State state = next_state_;
158 next_state_ = STATE_NONE; 158 next_state_ = STATE_NONE;
159 switch (state) { 159 switch (state) {
160 case STATE_INIT_CONNECTION: 160 case STATE_INIT_CONNECTION:
161 DCHECK_EQ(OK, rv); 161 DCHECK_EQ(OK, rv);
162 LoadLog::BeginEvent(load_log_, 162 net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION);
163 LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION);
164 rv = DoInitConnection(); 163 rv = DoInitConnection();
165 break; 164 break;
166 case STATE_INIT_CONNECTION_COMPLETE: 165 case STATE_INIT_CONNECTION_COMPLETE:
167 LoadLog::EndEvent(load_log_, 166 net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION);
168 LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION);
169 rv = DoInitConnectionComplete(rv); 167 rv = DoInitConnectionComplete(rv);
170 break; 168 break;
171 case STATE_SEND_REQUEST: 169 case STATE_SEND_REQUEST:
172 DCHECK_EQ(OK, rv); 170 DCHECK_EQ(OK, rv);
173 LoadLog::BeginEvent(load_log_, 171 net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
174 LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
175 rv = DoSendRequest(); 172 rv = DoSendRequest();
176 break; 173 break;
177 case STATE_SEND_REQUEST_COMPLETE: 174 case STATE_SEND_REQUEST_COMPLETE:
178 LoadLog::EndEvent(load_log_, 175 net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
179 LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
180 rv = DoSendRequestComplete(rv); 176 rv = DoSendRequestComplete(rv);
181 break; 177 break;
182 case STATE_READ_HEADERS: 178 case STATE_READ_HEADERS:
183 DCHECK_EQ(OK, rv); 179 DCHECK_EQ(OK, rv);
184 LoadLog::BeginEvent(load_log_, 180 net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
185 LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
186 rv = DoReadHeaders(); 181 rv = DoReadHeaders();
187 break; 182 break;
188 case STATE_READ_HEADERS_COMPLETE: 183 case STATE_READ_HEADERS_COMPLETE:
189 LoadLog::EndEvent(load_log_, 184 net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
190 LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
191 rv = DoReadHeadersComplete(rv); 185 rv = DoReadHeadersComplete(rv);
192 break; 186 break;
193 case STATE_READ_BODY: 187 case STATE_READ_BODY:
194 DCHECK_EQ(OK, rv); 188 DCHECK_EQ(OK, rv);
195 LoadLog::BeginEvent(load_log_, 189 net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_BODY);
196 LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY);
197 rv = DoReadBody(); 190 rv = DoReadBody();
198 break; 191 break;
199 case STATE_READ_BODY_COMPLETE: 192 case STATE_READ_BODY_COMPLETE:
200 LoadLog::EndEvent(load_log_, 193 net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_BODY);
201 LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY);
202 rv = DoReadBodyComplete(rv); 194 rv = DoReadBodyComplete(rv);
203 break; 195 break;
204 case STATE_NONE: 196 case STATE_NONE:
205 rv = ERR_FAILED; 197 rv = ERR_FAILED;
206 break; 198 break;
207 default: 199 default:
208 NOTREACHED() << "bad state"; 200 NOTREACHED() << "bad state";
209 rv = ERR_FAILED; 201 rv = ERR_FAILED;
210 break; 202 break;
211 } 203 }
(...skipping 21 matching lines...) Expand all
233 connection_group.append(host); 225 connection_group.append(host);
234 226
235 TCPSocketParams tcp_params(host, port, request_->priority, request_->referrer, 227 TCPSocketParams tcp_params(host, port, request_->priority, request_->referrer,
236 false); 228 false);
237 HostPortPair host_port_pair(host, port); 229 HostPortPair host_port_pair(host, port);
238 230
239 spdy_ = session_->spdy_session_pool()->Get(host_port_pair, session_); 231 spdy_ = session_->spdy_session_pool()->Get(host_port_pair, session_);
240 DCHECK(spdy_); 232 DCHECK(spdy_);
241 233
242 return spdy_->Connect( 234 return spdy_->Connect(
243 connection_group, tcp_params, request_->priority, load_log_); 235 connection_group, tcp_params, request_->priority, net_log_);
244 } 236 }
245 237
246 int SpdyNetworkTransaction::DoInitConnectionComplete(int result) { 238 int SpdyNetworkTransaction::DoInitConnectionComplete(int result) {
247 if (result < 0) 239 if (result < 0)
248 return result; 240 return result;
249 241
250 next_state_ = STATE_SEND_REQUEST; 242 next_state_ = STATE_SEND_REQUEST;
251 return OK; 243 return OK;
252 } 244 }
253 245
254 int SpdyNetworkTransaction::DoSendRequest() { 246 int SpdyNetworkTransaction::DoSendRequest() {
255 next_state_ = STATE_SEND_REQUEST_COMPLETE; 247 next_state_ = STATE_SEND_REQUEST_COMPLETE;
256 CHECK(!stream_.get()); 248 CHECK(!stream_.get());
257 UploadDataStream* upload_data = request_->upload_data ? 249 UploadDataStream* upload_data = request_->upload_data ?
258 new UploadDataStream(request_->upload_data) : NULL; 250 new UploadDataStream(request_->upload_data) : NULL;
259 stream_ = spdy_->GetOrCreateStream(*request_, upload_data, load_log_.get()); 251 stream_ = spdy_->GetOrCreateStream(*request_, upload_data, net_log_);
260 // Release the reference to |spdy_| since we don't need it anymore. 252 // Release the reference to |spdy_| since we don't need it anymore.
261 spdy_ = NULL; 253 spdy_ = NULL;
262 return stream_->SendRequest(upload_data, &response_, &io_callback_); 254 return stream_->SendRequest(upload_data, &response_, &io_callback_);
263 } 255 }
264 256
265 int SpdyNetworkTransaction::DoSendRequestComplete(int result) { 257 int SpdyNetworkTransaction::DoSendRequestComplete(int result) {
266 if (result < 0) 258 if (result < 0)
267 return result; 259 return result;
268 260
269 next_state_ = STATE_READ_HEADERS; 261 next_state_ = STATE_READ_HEADERS;
(...skipping 21 matching lines...) Expand all
291 user_buffer_ = NULL; 283 user_buffer_ = NULL;
292 user_buffer_len_ = 0; 284 user_buffer_len_ = 0;
293 285
294 if (result <= 0) 286 if (result <= 0)
295 stream_ = NULL; 287 stream_ = NULL;
296 288
297 return result; 289 return result;
298 } 290 }
299 291
300 } // namespace net 292 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction.h ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698