OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ |
6 #define CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ | 6 #define CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 ~TestURLLoaderClient() override; | 30 ~TestURLLoaderClient() override; |
31 | 31 |
32 void OnReceiveResponse( | 32 void OnReceiveResponse( |
33 const ResourceResponseHead& response_head, | 33 const ResourceResponseHead& response_head, |
34 mojom::DownloadedTempFileAssociatedPtrInfo downloaded_file) override; | 34 mojom::DownloadedTempFileAssociatedPtrInfo downloaded_file) override; |
35 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, | 35 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
36 const ResourceResponseHead& response_head) override; | 36 const ResourceResponseHead& response_head) override; |
37 void OnDataDownloaded(int64_t data_length, int64_t encoded_length) override; | 37 void OnDataDownloaded(int64_t data_length, int64_t encoded_length) override; |
38 void OnReceiveCachedMetadata(const std::vector<uint8_t>& data) override; | 38 void OnReceiveCachedMetadata(const std::vector<uint8_t>& data) override; |
39 void OnTransferSizeUpdated(int32_t transfer_size_diff) override; | 39 void OnTransferSizeUpdated(int32_t transfer_size_diff) override; |
| 40 void OnUploadProgress(int64_t current_position, |
| 41 int64_t total_size, |
| 42 const base::Closure& ack_callback) override; |
40 void OnStartLoadingResponseBody( | 43 void OnStartLoadingResponseBody( |
41 mojo::ScopedDataPipeConsumerHandle body) override; | 44 mojo::ScopedDataPipeConsumerHandle body) override; |
42 void OnComplete(const ResourceRequestCompletionStatus& status) override; | 45 void OnComplete(const ResourceRequestCompletionStatus& status) override; |
43 | 46 |
44 bool has_received_response() const { return has_received_response_; } | 47 bool has_received_response() const { return has_received_response_; } |
45 bool has_received_redirect() const { return has_received_redirect_; } | 48 bool has_received_redirect() const { return has_received_redirect_; } |
46 bool has_data_downloaded() const { return has_data_downloaded_; } | 49 bool has_data_downloaded() const { return has_data_downloaded_; } |
| 50 bool has_received_upload_progress() const { |
| 51 return has_received_upload_progress_; |
| 52 } |
47 bool has_received_cached_metadata() const { | 53 bool has_received_cached_metadata() const { |
48 return has_received_cached_metadata_; | 54 return has_received_cached_metadata_; |
49 } | 55 } |
50 bool has_received_completion() const { return has_received_completion_; } | 56 bool has_received_completion() const { return has_received_completion_; } |
51 const ResourceResponseHead& response_head() const { return response_head_; } | 57 const ResourceResponseHead& response_head() const { return response_head_; } |
52 const net::RedirectInfo& redirect_info() const { return redirect_info_; } | 58 const net::RedirectInfo& redirect_info() const { return redirect_info_; } |
53 const std::string& cached_metadata() const { | 59 const std::string& cached_metadata() const { |
54 return cached_metadata_; | 60 return cached_metadata_; |
55 } | 61 } |
56 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } | 62 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } |
57 const ResourceRequestCompletionStatus& completion_status() const { | 63 const ResourceRequestCompletionStatus& completion_status() const { |
58 return completion_status_; | 64 return completion_status_; |
59 } | 65 } |
60 int64_t download_data_length() const { return download_data_length_; } | 66 int64_t download_data_length() const { return download_data_length_; } |
61 int64_t encoded_download_data_length() const { | 67 int64_t encoded_download_data_length() const { |
62 return encoded_download_data_length_; | 68 return encoded_download_data_length_; |
63 } | 69 } |
64 int64_t body_transfer_size() const { return body_transfer_size_; } | 70 int64_t body_transfer_size() const { return body_transfer_size_; } |
| 71 int64_t current_upload_position() const { return current_upload_position_; } |
| 72 int64_t total_upload_size() const { return total_upload_size_; } |
| 73 |
| 74 void reset_has_received_upload_progress() { |
| 75 has_received_upload_progress_ = false; |
| 76 } |
65 | 77 |
66 void ClearHasReceivedRedirect(); | 78 void ClearHasReceivedRedirect(); |
67 // Creates an AssociatedPtrInfo, binds it to |*this| and returns it. The | 79 // Creates an AssociatedPtrInfo, binds it to |*this| and returns it. The |
68 // returned PtrInfo is marked as remote, i.e., expected to be passed to the | 80 // returned PtrInfo is marked as remote, i.e., expected to be passed to the |
69 // remote endpoint. | 81 // remote endpoint. |
70 mojom::URLLoaderClientAssociatedPtrInfo CreateRemoteAssociatedPtrInfo( | 82 mojom::URLLoaderClientAssociatedPtrInfo CreateRemoteAssociatedPtrInfo( |
71 mojo::AssociatedGroup* associated_group); | 83 mojo::AssociatedGroup* associated_group); |
72 | 84 |
73 void Unbind(); | 85 void Unbind(); |
74 | 86 |
75 void RunUntilResponseReceived(); | 87 void RunUntilResponseReceived(); |
76 void RunUntilRedirectReceived(); | 88 void RunUntilRedirectReceived(); |
77 void RunUntilDataDownloaded(); | 89 void RunUntilDataDownloaded(); |
78 void RunUntilCachedMetadataReceived(); | 90 void RunUntilCachedMetadataReceived(); |
79 void RunUntilResponseBodyArrived(); | 91 void RunUntilResponseBodyArrived(); |
80 void RunUntilComplete(); | 92 void RunUntilComplete(); |
81 | 93 |
82 private: | 94 private: |
83 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_; | 95 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_; |
84 ResourceResponseHead response_head_; | 96 ResourceResponseHead response_head_; |
85 net::RedirectInfo redirect_info_; | 97 net::RedirectInfo redirect_info_; |
86 std::string cached_metadata_; | 98 std::string cached_metadata_; |
87 mojo::ScopedDataPipeConsumerHandle response_body_; | 99 mojo::ScopedDataPipeConsumerHandle response_body_; |
88 ResourceRequestCompletionStatus completion_status_; | 100 ResourceRequestCompletionStatus completion_status_; |
89 bool has_received_response_ = false; | 101 bool has_received_response_ = false; |
90 bool has_received_redirect_ = false; | 102 bool has_received_redirect_ = false; |
91 bool has_data_downloaded_ = false; | 103 bool has_data_downloaded_ = false; |
| 104 bool has_received_upload_progress_ = false; |
92 bool has_received_cached_metadata_ = false; | 105 bool has_received_cached_metadata_ = false; |
93 bool has_received_completion_ = false; | 106 bool has_received_completion_ = false; |
94 base::Closure quit_closure_for_on_receive_response_; | 107 base::Closure quit_closure_for_on_receive_response_; |
95 base::Closure quit_closure_for_on_receive_redirect_; | 108 base::Closure quit_closure_for_on_receive_redirect_; |
96 base::Closure quit_closure_for_on_data_downloaded_; | 109 base::Closure quit_closure_for_on_data_downloaded_; |
97 base::Closure quit_closure_for_on_receive_cached_metadata_; | 110 base::Closure quit_closure_for_on_receive_cached_metadata_; |
98 base::Closure quit_closure_for_on_start_loading_response_body_; | 111 base::Closure quit_closure_for_on_start_loading_response_body_; |
99 base::Closure quit_closure_for_on_complete_; | 112 base::Closure quit_closure_for_on_complete_; |
100 mojom::URLLoaderFactoryPtr url_loader_factory_; | 113 mojom::URLLoaderFactoryPtr url_loader_factory_; |
101 int64_t download_data_length_ = 0; | 114 int64_t download_data_length_ = 0; |
102 int64_t encoded_download_data_length_ = 0; | 115 int64_t encoded_download_data_length_ = 0; |
103 int64_t body_transfer_size_ = 0; | 116 int64_t body_transfer_size_ = 0; |
| 117 int64_t current_upload_position_ = 0; |
| 118 int64_t total_upload_size_ = 0; |
104 | 119 |
105 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient); | 120 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient); |
106 }; | 121 }; |
107 | 122 |
108 } // namespace content | 123 } // namespace content |
109 | 124 |
110 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ | 125 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ |
OLD | NEW |