| 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 "content/child/resource_dispatcher.h" | 5 #include "content/child/resource_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 context_->total_downloaded_data_length += len; | 85 context_->total_downloaded_data_length += len; |
| 86 context_->total_encoded_data_length += encoded_data_length; | 86 context_->total_encoded_data_length += encoded_data_length; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void OnReceivedData(std::unique_ptr<ReceivedData> data) override { | 89 void OnReceivedData(std::unique_ptr<ReceivedData> data) override { |
| 90 if (context_->cancelled) | 90 if (context_->cancelled) |
| 91 return; | 91 return; |
| 92 EXPECT_TRUE(context_->received_response); | 92 EXPECT_TRUE(context_->received_response); |
| 93 EXPECT_FALSE(context_->complete); | 93 EXPECT_FALSE(context_->complete); |
| 94 context_->data.append(data->payload(), data->length()); | 94 context_->data.append(data->payload(), data->length()); |
| 95 context_->total_encoded_data_length += data->encoded_data_length(); | |
| 96 | 95 |
| 97 if (context_->cancel_on_receive_data) { | 96 if (context_->cancel_on_receive_data) { |
| 98 dispatcher_->Cancel(context_->request_id); | 97 dispatcher_->Cancel(context_->request_id); |
| 99 context_->cancelled = true; | 98 context_->cancelled = true; |
| 100 } | 99 } |
| 101 } | 100 } |
| 102 | 101 |
| 102 void OnTransferSizeUpdated(int transfer_size_diff) override { |
| 103 if (context_->cancelled) |
| 104 return; |
| 105 context_->total_encoded_data_length += transfer_size_diff; |
| 106 } |
| 107 |
| 103 void OnCompletedRequest(int error_code, | 108 void OnCompletedRequest(int error_code, |
| 104 bool was_ignored_by_handler, | 109 bool was_ignored_by_handler, |
| 105 bool stale_copy_in_cache, | 110 bool stale_copy_in_cache, |
| 106 const base::TimeTicks& completion_time, | 111 const base::TimeTicks& completion_time, |
| 107 int64_t total_transfer_size, | 112 int64_t total_transfer_size, |
| 108 int64_t encoded_body_size) override { | 113 int64_t encoded_body_size) override { |
| 109 if (context_->cancelled) | 114 if (context_->cancelled) |
| 110 return; | 115 return; |
| 111 EXPECT_TRUE(context_->received_response); | 116 EXPECT_TRUE(context_->received_response); |
| 112 EXPECT_FALSE(context_->complete); | 117 EXPECT_FALSE(context_->complete); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 538 |
| 534 void OnReceivedResponse(const ResourceResponseInfo& info) override { | 539 void OnReceivedResponse(const ResourceResponseInfo& info) override { |
| 535 response_info_ = info; | 540 response_info_ = info; |
| 536 } | 541 } |
| 537 | 542 |
| 538 void OnDownloadedData(int len, int encoded_data_length) override {} | 543 void OnDownloadedData(int len, int encoded_data_length) override {} |
| 539 | 544 |
| 540 void OnReceivedData(std::unique_ptr<ReceivedData> data) override { | 545 void OnReceivedData(std::unique_ptr<ReceivedData> data) override { |
| 541 data_.append(data->payload(), data->length()); | 546 data_.append(data->payload(), data->length()); |
| 542 } | 547 } |
| 548 void OnTransferSizeUpdated(int transfer_size_diff) override {} |
| 543 | 549 |
| 544 void OnCompletedRequest(int error_code, | 550 void OnCompletedRequest(int error_code, |
| 545 bool was_ignored_by_handler, | 551 bool was_ignored_by_handler, |
| 546 bool stale_copy_in_cache, | 552 bool stale_copy_in_cache, |
| 547 const base::TimeTicks& completion_time, | 553 const base::TimeTicks& completion_time, |
| 548 int64_t total_transfer_size, | 554 int64_t total_transfer_size, |
| 549 int64_t encoded_body_size) override { | 555 int64_t encoded_body_size) override { |
| 550 original_peer_->OnReceivedResponse(response_info_); | 556 original_peer_->OnReceivedResponse(response_info_); |
| 551 if (!data_.empty()) { | 557 if (!data_.empty()) { |
| 552 original_peer_->OnReceivedData(base::MakeUnique<FixedReceivedData>( | 558 original_peer_->OnReceivedData( |
| 553 data_.data(), data_.size(), -1)); | 559 base::MakeUnique<FixedReceivedData>(data_.data(), data_.size())); |
| 554 } | 560 } |
| 555 original_peer_->OnCompletedRequest( | 561 original_peer_->OnCompletedRequest( |
| 556 error_code, was_ignored_by_handler, stale_copy_in_cache, | 562 error_code, was_ignored_by_handler, stale_copy_in_cache, |
| 557 completion_time, total_transfer_size, encoded_body_size); | 563 completion_time, total_transfer_size, encoded_body_size); |
| 558 } | 564 } |
| 559 | 565 |
| 560 private: | 566 private: |
| 561 std::unique_ptr<RequestPeer> original_peer_; | 567 std::unique_ptr<RequestPeer> original_peer_; |
| 562 ResourceResponseInfo response_info_; | 568 ResourceResponseInfo response_info_; |
| 563 std::string data_; | 569 std::string data_; |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 ResourceResponseHead response_head; | 1045 ResourceResponseHead response_head; |
| 1040 | 1046 |
| 1041 PerformTest(response_head); | 1047 PerformTest(response_head); |
| 1042 | 1048 |
| 1043 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); | 1049 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); |
| 1044 EXPECT_EQ(base::TimeTicks(), | 1050 EXPECT_EQ(base::TimeTicks(), |
| 1045 response_info().load_timing.connect_timing.dns_start); | 1051 response_info().load_timing.connect_timing.dns_start); |
| 1046 } | 1052 } |
| 1047 | 1053 |
| 1048 } // namespace content | 1054 } // namespace content |
| OLD | NEW |