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