| 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/url_request/url_fetcher_core.h" | 5 #include "net/url_request/url_fetcher_core.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 341 } |
| 342 | 342 |
| 343 const URLRequestStatus& URLFetcherCore::GetStatus() const { | 343 const URLRequestStatus& URLFetcherCore::GetStatus() const { |
| 344 return status_; | 344 return status_; |
| 345 } | 345 } |
| 346 | 346 |
| 347 int URLFetcherCore::GetResponseCode() const { | 347 int URLFetcherCore::GetResponseCode() const { |
| 348 return response_code_; | 348 return response_code_; |
| 349 } | 349 } |
| 350 | 350 |
| 351 const ResponseCookies& URLFetcherCore::GetCookies() const { | |
| 352 return cookies_; | |
| 353 } | |
| 354 | |
| 355 void URLFetcherCore::ReceivedContentWasMalformed() { | 351 void URLFetcherCore::ReceivedContentWasMalformed() { |
| 356 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 352 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
| 357 if (network_task_runner_.get()) { | 353 if (network_task_runner_.get()) { |
| 358 network_task_runner_->PostTask( | 354 network_task_runner_->PostTask( |
| 359 FROM_HERE, base::Bind(&URLFetcherCore::NotifyMalformedContent, this)); | 355 FROM_HERE, base::Bind(&URLFetcherCore::NotifyMalformedContent, this)); |
| 360 } | 356 } |
| 361 } | 357 } |
| 362 | 358 |
| 363 bool URLFetcherCore::GetResponseAsString( | 359 bool URLFetcherCore::GetResponseAsString( |
| 364 std::string* out_response_string) const { | 360 std::string* out_response_string) const { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 461 |
| 466 const int result = | 462 const int result = |
| 467 WriteBuffer(new DrainableIOBuffer(buffer_.get(), bytes_read)); | 463 WriteBuffer(new DrainableIOBuffer(buffer_.get(), bytes_read)); |
| 468 if (result < 0) { | 464 if (result < 0) { |
| 469 // Write failed or waiting for write completion. | 465 // Write failed or waiting for write completion. |
| 470 return; | 466 return; |
| 471 } | 467 } |
| 472 } while (request_->Read(buffer_.get(), kBufferSize, &bytes_read)); | 468 } while (request_->Read(buffer_.get(), kBufferSize, &bytes_read)); |
| 473 | 469 |
| 474 const URLRequestStatus status = request_->status(); | 470 const URLRequestStatus status = request_->status(); |
| 475 if (status.is_success()) | |
| 476 request_->GetResponseCookies(&cookies_); | |
| 477 | 471 |
| 478 // See comments re: HEAD requests in ReadResponse(). | 472 // See comments re: HEAD requests in ReadResponse(). |
| 479 if (!status.is_io_pending() || request_type_ == URLFetcher::HEAD) { | 473 if (!status.is_io_pending() || request_type_ == URLFetcher::HEAD) { |
| 480 status_ = status; | 474 status_ = status; |
| 481 received_response_content_length_ = | 475 received_response_content_length_ = |
| 482 request_->received_response_content_length(); | 476 request_->received_response_content_length(); |
| 483 total_received_bytes_ += request_->GetTotalReceivedBytes(); | 477 total_received_bytes_ += request_->GetTotalReceivedBytes(); |
| 484 ReleaseRequest(); | 478 ReleaseRequest(); |
| 485 | 479 |
| 486 // No more data to write. | 480 // No more data to write. |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 } | 949 } |
| 956 | 950 |
| 957 void URLFetcherCore::AssertHasNoUploadData() const { | 951 void URLFetcherCore::AssertHasNoUploadData() const { |
| 958 DCHECK(!upload_content_set_); | 952 DCHECK(!upload_content_set_); |
| 959 DCHECK(upload_content_.empty()); | 953 DCHECK(upload_content_.empty()); |
| 960 DCHECK(upload_file_path_.empty()); | 954 DCHECK(upload_file_path_.empty()); |
| 961 DCHECK(upload_stream_factory_.is_null()); | 955 DCHECK(upload_stream_factory_.is_null()); |
| 962 } | 956 } |
| 963 | 957 |
| 964 } // namespace net | 958 } // namespace net |
| OLD | NEW |