| 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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
| 5 #include <string> | 8 #include <string> |
| 6 #include <vector> | 9 #include <vector> |
| 7 | 10 |
| 8 #include "base/macros.h" | 11 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 11 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 12 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
| 13 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 14 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 received_response_(false), | 51 received_response_(false), |
| 49 total_encoded_data_length_(0), | 52 total_encoded_data_length_(0), |
| 50 total_downloaded_data_length_(0), | 53 total_downloaded_data_length_(0), |
| 51 complete_(false), | 54 complete_(false), |
| 52 dispatcher_(dispatcher), | 55 dispatcher_(dispatcher), |
| 53 request_id_(0) { | 56 request_id_(0) { |
| 54 } | 57 } |
| 55 | 58 |
| 56 void set_request_id(int request_id) { request_id_ = request_id; } | 59 void set_request_id(int request_id) { request_id_ = request_id; } |
| 57 | 60 |
| 58 void OnUploadProgress(uint64 position, uint64 size) override {} | 61 void OnUploadProgress(uint64_t position, uint64_t size) override {} |
| 59 | 62 |
| 60 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 63 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
| 61 const ResourceResponseInfo& info) override { | 64 const ResourceResponseInfo& info) override { |
| 62 ++seen_redirects_; | 65 ++seen_redirects_; |
| 63 if (defer_on_redirect_) | 66 if (defer_on_redirect_) |
| 64 dispatcher_->SetDefersLoading(request_id_, true); | 67 dispatcher_->SetDefersLoading(request_id_, true); |
| 65 return follow_redirects_; | 68 return follow_redirects_; |
| 66 } | 69 } |
| 67 | 70 |
| 68 void OnReceivedResponse(const ResourceResponseInfo& info) override { | 71 void OnReceivedResponse(const ResourceResponseInfo& info) override { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 82 EXPECT_FALSE(complete_); | 85 EXPECT_FALSE(complete_); |
| 83 data_.append(data->payload(), data->length()); | 86 data_.append(data->payload(), data->length()); |
| 84 total_encoded_data_length_ += data->encoded_length(); | 87 total_encoded_data_length_ += data->encoded_length(); |
| 85 } | 88 } |
| 86 | 89 |
| 87 void OnCompletedRequest(int error_code, | 90 void OnCompletedRequest(int error_code, |
| 88 bool was_ignored_by_handler, | 91 bool was_ignored_by_handler, |
| 89 bool stale_copy_in_cache, | 92 bool stale_copy_in_cache, |
| 90 const std::string& security_info, | 93 const std::string& security_info, |
| 91 const base::TimeTicks& completion_time, | 94 const base::TimeTicks& completion_time, |
| 92 int64 total_transfer_size) override { | 95 int64_t total_transfer_size) override { |
| 93 EXPECT_TRUE(received_response_); | 96 EXPECT_TRUE(received_response_); |
| 94 EXPECT_FALSE(complete_); | 97 EXPECT_FALSE(complete_); |
| 95 complete_ = true; | 98 complete_ = true; |
| 96 } | 99 } |
| 97 | 100 |
| 98 void OnReceivedCompletedResponse(const ResourceResponseInfo& info, | 101 void OnReceivedCompletedResponse(const ResourceResponseInfo& info, |
| 99 scoped_ptr<ReceivedData> data, | 102 scoped_ptr<ReceivedData> data, |
| 100 int error_code, | 103 int error_code, |
| 101 bool was_ignored_by_handler, | 104 bool was_ignored_by_handler, |
| 102 bool stale_copy_in_cache, | 105 bool stale_copy_in_cache, |
| 103 const std::string& security_info, | 106 const std::string& security_info, |
| 104 const base::TimeTicks& completion_time, | 107 const base::TimeTicks& completion_time, |
| 105 int64 total_transfer_size) override { | 108 int64_t total_transfer_size) override { |
| 106 bool cancel_on_receive_response = cancel_on_receive_response_; | 109 bool cancel_on_receive_response = cancel_on_receive_response_; |
| 107 OnReceivedResponse(info); | 110 OnReceivedResponse(info); |
| 108 if (cancel_on_receive_response) | 111 if (cancel_on_receive_response) |
| 109 return; | 112 return; |
| 110 if (data) | 113 if (data) |
| 111 OnReceivedData(data.Pass()); | 114 OnReceivedData(data.Pass()); |
| 112 OnCompletedRequest(error_code, was_ignored_by_handler, stale_copy_in_cache, | 115 OnCompletedRequest(error_code, was_ignored_by_handler, stale_copy_in_cache, |
| 113 security_info, completion_time, total_transfer_size); | 116 security_info, completion_time, total_transfer_size); |
| 114 } | 117 } |
| 115 | 118 |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 void PerformTest(const ResourceResponseHead& response_head) { | 735 void PerformTest(const ResourceResponseHead& response_head) { |
| 733 scoped_ptr<RequestInfo> request_info(CreateRequestInfo(false)); | 736 scoped_ptr<RequestInfo> request_info(CreateRequestInfo(false)); |
| 734 TestRequestPeer peer(dispatcher()); | 737 TestRequestPeer peer(dispatcher()); |
| 735 dispatcher()->StartAsync(*request_info.get(), NULL, &peer); | 738 dispatcher()->StartAsync(*request_info.get(), NULL, &peer); |
| 736 | 739 |
| 737 dispatcher()->OnMessageReceived( | 740 dispatcher()->OnMessageReceived( |
| 738 ResourceMsg_ReceivedResponse(0, response_head)); | 741 ResourceMsg_ReceivedResponse(0, response_head)); |
| 739 } | 742 } |
| 740 | 743 |
| 741 // RequestPeer methods. | 744 // RequestPeer methods. |
| 742 void OnUploadProgress(uint64 position, uint64 size) override {} | 745 void OnUploadProgress(uint64_t position, uint64_t size) override {} |
| 743 | 746 |
| 744 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 747 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
| 745 const ResourceResponseInfo& info) override { | 748 const ResourceResponseInfo& info) override { |
| 746 return true; | 749 return true; |
| 747 } | 750 } |
| 748 | 751 |
| 749 void OnReceivedResponse(const ResourceResponseInfo& info) override { | 752 void OnReceivedResponse(const ResourceResponseInfo& info) override { |
| 750 response_info_ = info; | 753 response_info_ = info; |
| 751 } | 754 } |
| 752 | 755 |
| 753 void OnDownloadedData(int len, int encoded_data_length) override {} | 756 void OnDownloadedData(int len, int encoded_data_length) override {} |
| 754 | 757 |
| 755 void OnReceivedData(scoped_ptr<ReceivedData> data) override {} | 758 void OnReceivedData(scoped_ptr<ReceivedData> data) override {} |
| 756 | 759 |
| 757 void OnCompletedRequest(int error_code, | 760 void OnCompletedRequest(int error_code, |
| 758 bool was_ignored_by_handler, | 761 bool was_ignored_by_handler, |
| 759 bool stale_copy_in_cache, | 762 bool stale_copy_in_cache, |
| 760 const std::string& security_info, | 763 const std::string& security_info, |
| 761 const base::TimeTicks& completion_time, | 764 const base::TimeTicks& completion_time, |
| 762 int64 total_transfer_size) override {} | 765 int64_t total_transfer_size) override {} |
| 763 | 766 |
| 764 void OnReceivedCompletedResponse(const ResourceResponseInfo& info, | 767 void OnReceivedCompletedResponse(const ResourceResponseInfo& info, |
| 765 scoped_ptr<ReceivedData> data, | 768 scoped_ptr<ReceivedData> data, |
| 766 int error_code, | 769 int error_code, |
| 767 bool was_ignored_by_handler, | 770 bool was_ignored_by_handler, |
| 768 bool stale_copy_in_cache, | 771 bool stale_copy_in_cache, |
| 769 const std::string& security_info, | 772 const std::string& security_info, |
| 770 const base::TimeTicks& completion_time, | 773 const base::TimeTicks& completion_time, |
| 771 int64 total_transfer_size) override {} | 774 int64_t total_transfer_size) override {} |
| 772 | 775 |
| 773 const ResourceResponseInfo& response_info() const { return response_info_; } | 776 const ResourceResponseInfo& response_info() const { return response_info_; } |
| 774 | 777 |
| 775 private: | 778 private: |
| 776 ResourceResponseInfo response_info_; | 779 ResourceResponseInfo response_info_; |
| 777 }; | 780 }; |
| 778 | 781 |
| 779 // TODO(simonjam): Enable this when 10829031 lands. | 782 // TODO(simonjam): Enable this when 10829031 lands. |
| 780 TEST_F(TimeConversionTest, DISABLED_ProperlyInitialized) { | 783 TEST_F(TimeConversionTest, DISABLED_ProperlyInitialized) { |
| 781 ResourceResponseHead response_head; | 784 ResourceResponseHead response_head; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 812 ResourceResponseHead response_head; | 815 ResourceResponseHead response_head; |
| 813 | 816 |
| 814 PerformTest(response_head); | 817 PerformTest(response_head); |
| 815 | 818 |
| 816 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); | 819 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); |
| 817 EXPECT_EQ(base::TimeTicks(), | 820 EXPECT_EQ(base::TimeTicks(), |
| 818 response_info().load_timing.connect_timing.dns_start); | 821 response_info().load_timing.connect_timing.dns_start); |
| 819 } | 822 } |
| 820 | 823 |
| 821 } // namespace content | 824 } // namespace content |
| OLD | NEW |