| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (context_->cancel_on_receive_data) { | 97 if (context_->cancel_on_receive_data) { |
| 98 dispatcher_->Cancel(context_->request_id); | 98 dispatcher_->Cancel(context_->request_id); |
| 99 context_->cancelled = true; | 99 context_->cancelled = true; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 void OnCompletedRequest(int error_code, | 103 void OnCompletedRequest(int error_code, |
| 104 bool was_ignored_by_handler, | 104 bool was_ignored_by_handler, |
| 105 bool stale_copy_in_cache, | 105 bool stale_copy_in_cache, |
| 106 const base::TimeTicks& completion_time, | 106 const base::TimeTicks& completion_time, |
| 107 int64_t total_transfer_size) override { | 107 int64_t total_transfer_size, |
| 108 int64_t encoded_body_size) override { |
| 108 if (context_->cancelled) | 109 if (context_->cancelled) |
| 109 return; | 110 return; |
| 110 EXPECT_TRUE(context_->received_response); | 111 EXPECT_TRUE(context_->received_response); |
| 111 EXPECT_FALSE(context_->complete); | 112 EXPECT_FALSE(context_->complete); |
| 112 context_->complete = true; | 113 context_->complete = true; |
| 113 } | 114 } |
| 114 | 115 |
| 115 struct Context { | 116 struct Context { |
| 116 // True if should follow redirects, false if should cancel them. | 117 // True if should follow redirects, false if should cancel them. |
| 117 bool follow_redirects = true; | 118 bool follow_redirects = true; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 void OnDownloadedData(int len, int encoded_data_length) override {} | 538 void OnDownloadedData(int len, int encoded_data_length) override {} |
| 538 | 539 |
| 539 void OnReceivedData(std::unique_ptr<ReceivedData> data) override { | 540 void OnReceivedData(std::unique_ptr<ReceivedData> data) override { |
| 540 data_.append(data->payload(), data->length()); | 541 data_.append(data->payload(), data->length()); |
| 541 } | 542 } |
| 542 | 543 |
| 543 void OnCompletedRequest(int error_code, | 544 void OnCompletedRequest(int error_code, |
| 544 bool was_ignored_by_handler, | 545 bool was_ignored_by_handler, |
| 545 bool stale_copy_in_cache, | 546 bool stale_copy_in_cache, |
| 546 const base::TimeTicks& completion_time, | 547 const base::TimeTicks& completion_time, |
| 547 int64_t total_transfer_size) override { | 548 int64_t total_transfer_size, |
| 549 int64_t encoded_body_size) override { |
| 548 original_peer_->OnReceivedResponse(response_info_); | 550 original_peer_->OnReceivedResponse(response_info_); |
| 549 if (!data_.empty()) { | 551 if (!data_.empty()) { |
| 550 original_peer_->OnReceivedData(base::MakeUnique<FixedReceivedData>( | 552 original_peer_->OnReceivedData(base::MakeUnique<FixedReceivedData>( |
| 551 data_.data(), data_.size(), -1, data_.size())); | 553 data_.data(), data_.size(), -1)); |
| 552 } | 554 } |
| 553 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, | 555 original_peer_->OnCompletedRequest( |
| 554 stale_copy_in_cache, completion_time, | 556 error_code, was_ignored_by_handler, stale_copy_in_cache, |
| 555 total_transfer_size); | 557 completion_time, total_transfer_size, encoded_body_size); |
| 556 } | 558 } |
| 557 | 559 |
| 558 private: | 560 private: |
| 559 std::unique_ptr<RequestPeer> original_peer_; | 561 std::unique_ptr<RequestPeer> original_peer_; |
| 560 ResourceResponseInfo response_info_; | 562 ResourceResponseInfo response_info_; |
| 561 std::string data_; | 563 std::string data_; |
| 562 | 564 |
| 563 DISALLOW_COPY_AND_ASSIGN(WrapperPeer); | 565 DISALLOW_COPY_AND_ASSIGN(WrapperPeer); |
| 564 }; | 566 }; |
| 565 | 567 |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 ResourceResponseHead response_head; | 1039 ResourceResponseHead response_head; |
| 1038 | 1040 |
| 1039 PerformTest(response_head); | 1041 PerformTest(response_head); |
| 1040 | 1042 |
| 1041 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); | 1043 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); |
| 1042 EXPECT_EQ(base::TimeTicks(), | 1044 EXPECT_EQ(base::TimeTicks(), |
| 1043 response_info().load_timing.connect_timing.dns_start); | 1045 response_info().load_timing.connect_timing.dns_start); |
| 1044 } | 1046 } |
| 1045 | 1047 |
| 1046 } // namespace content | 1048 } // namespace content |
| OLD | NEW |