OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/http/http_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/profiler/scoped_profile.h" | 10 #include "base/profiler/scoped_tracker.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
15 #include "net/base/upload_data_stream.h" | 15 #include "net/base/upload_data_stream.h" |
16 #include "net/http/http_chunked_decoder.h" | 16 #include "net/http/http_chunked_decoder.h" |
17 #include "net/http/http_request_headers.h" | 17 #include "net/http/http_request_headers.h" |
18 #include "net/http/http_request_info.h" | 18 #include "net/http/http_request_info.h" |
19 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
20 #include "net/http/http_util.h" | 20 #include "net/http/http_util.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 io_state_ = STATE_READ_BODY; | 351 io_state_ = STATE_READ_BODY; |
352 | 352 |
353 int result = DoLoop(OK); | 353 int result = DoLoop(OK); |
354 if (result == ERR_IO_PENDING) | 354 if (result == ERR_IO_PENDING) |
355 callback_ = callback; | 355 callback_ = callback; |
356 | 356 |
357 return result; | 357 return result; |
358 } | 358 } |
359 | 359 |
360 void HttpStreamParser::OnIOComplete(int result) { | 360 void HttpStreamParser::OnIOComplete(int result) { |
361 // TODO(vadimt): Remove ScopedProfile below once crbug.com/418183 is fixed. | 361 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
362 tracked_objects::ScopedProfile tracking_profile( | 362 tracked_objects::ScopedTracker tracking_profile( |
363 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 363 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
364 "418183 DidCompleteReadWrite => HttpStreamParser::OnIOComplete")); | 364 "418183 DidCompleteReadWrite => HttpStreamParser::OnIOComplete")); |
365 | 365 |
366 result = DoLoop(result); | 366 result = DoLoop(result); |
367 | 367 |
368 // The client callback can do anything, including destroying this class, | 368 // The client callback can do anything, including destroying this class, |
369 // so any pending callback must be issued after everything else is done. | 369 // so any pending callback must be issued after everything else is done. |
370 if (result != ERR_IO_PENDING && !callback_.is_null()) { | 370 if (result != ERR_IO_PENDING && !callback_.is_null()) { |
371 // TODO(vadimt): Remove ScopedProfile below once crbug.com/424359 is fixed. | 371 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424359 is fixed. |
372 tracked_objects::ScopedProfile tracking_profile( | 372 tracked_objects::ScopedTracker tracking_profile( |
373 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 373 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
374 "424359 HttpStreamParser::OnIOComplete callback")); | 374 "424359 HttpStreamParser::OnIOComplete callback")); |
375 | 375 |
376 CompletionCallback c = callback_; | 376 CompletionCallback c = callback_; |
377 callback_.Reset(); | 377 callback_.Reset(); |
378 c.Run(result); | 378 c.Run(result); |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 int HttpStreamParser::DoLoop(int result) { | 382 int HttpStreamParser::DoLoop(int result) { |
383 // TODO(vadimt): Remove ScopedProfile below once crbug.com/424359 is fixed. | 383 // TODO(vadimt): Remove ScopedTracker below once crbug.com/424359 is fixed. |
384 tracked_objects::ScopedProfile tracking_profile( | 384 tracked_objects::ScopedTracker tracking_profile( |
385 FROM_HERE_WITH_EXPLICIT_FUNCTION("424359 HttpStreamParser::DoLoop")); | 385 FROM_HERE_WITH_EXPLICIT_FUNCTION("424359 HttpStreamParser::DoLoop")); |
386 | 386 |
387 do { | 387 do { |
388 DCHECK_NE(ERR_IO_PENDING, result); | 388 DCHECK_NE(ERR_IO_PENDING, result); |
389 DCHECK_NE(STATE_DONE, io_state_); | 389 DCHECK_NE(STATE_DONE, io_state_); |
390 DCHECK_NE(STATE_NONE, io_state_); | 390 DCHECK_NE(STATE_NONE, io_state_); |
391 State state = io_state_; | 391 State state = io_state_; |
392 io_state_ = STATE_NONE; | 392 io_state_ = STATE_NONE; |
393 switch (state) { | 393 switch (state) { |
394 case STATE_SEND_HEADERS: | 394 case STATE_SEND_HEADERS: |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 request_body->IsInMemory() && | 1060 request_body->IsInMemory() && |
1061 request_body->size() > 0) { | 1061 request_body->size() > 0) { |
1062 size_t merged_size = request_headers.size() + request_body->size(); | 1062 size_t merged_size = request_headers.size() + request_body->size(); |
1063 if (merged_size <= kMaxMergedHeaderAndBodySize) | 1063 if (merged_size <= kMaxMergedHeaderAndBodySize) |
1064 return true; | 1064 return true; |
1065 } | 1065 } |
1066 return false; | 1066 return false; |
1067 } | 1067 } |
1068 | 1068 |
1069 } // namespace net | 1069 } // namespace net |
OLD | NEW |