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 12 matching lines...) Expand all Loading... |
23 // A TestURLLoaderClient records URLLoaderClient function calls. It also calls | 23 // A TestURLLoaderClient records URLLoaderClient function calls. It also calls |
24 // the closure set via set_quit_closure if set, in order to make it possible to | 24 // the closure set via set_quit_closure if set, in order to make it possible to |
25 // create a base::RunLoop, set its quit closure to this client and then run the | 25 // create a base::RunLoop, set its quit closure to this client and then run the |
26 // RunLoop. | 26 // RunLoop. |
27 class TestURLLoaderClient final : public mojom::URLLoaderClient { | 27 class TestURLLoaderClient final : public mojom::URLLoaderClient { |
28 public: | 28 public: |
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 const base::Optional<net::SSLInfo>& ssl_info, |
33 mojom::DownloadedTempFilePtr downloaded_file) override; | 34 mojom::DownloadedTempFilePtr downloaded_file) override; |
34 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, | 35 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
35 const ResourceResponseHead& response_head) override; | 36 const ResourceResponseHead& response_head) override; |
36 void OnDataDownloaded(int64_t data_length, int64_t encoded_length) override; | 37 void OnDataDownloaded(int64_t data_length, int64_t encoded_length) override; |
37 void OnReceiveCachedMetadata(const std::vector<uint8_t>& data) override; | 38 void OnReceiveCachedMetadata(const std::vector<uint8_t>& data) override; |
38 void OnTransferSizeUpdated(int32_t transfer_size_diff) override; | 39 void OnTransferSizeUpdated(int32_t transfer_size_diff) override; |
39 void OnUploadProgress(int64_t current_position, | 40 void OnUploadProgress(int64_t current_position, |
40 int64_t total_size, | 41 int64_t total_size, |
41 const base::Closure& ack_callback) override; | 42 const base::Closure& ack_callback) override; |
42 void OnStartLoadingResponseBody( | 43 void OnStartLoadingResponseBody( |
43 mojo::ScopedDataPipeConsumerHandle body) override; | 44 mojo::ScopedDataPipeConsumerHandle body) override; |
44 void OnComplete(const ResourceRequestCompletionStatus& status) override; | 45 void OnComplete(const ResourceRequestCompletionStatus& status) override; |
45 | 46 |
46 bool has_received_response() const { return has_received_response_; } | 47 bool has_received_response() const { return has_received_response_; } |
47 bool has_received_redirect() const { return has_received_redirect_; } | 48 bool has_received_redirect() const { return has_received_redirect_; } |
48 bool has_data_downloaded() const { return has_data_downloaded_; } | 49 bool has_data_downloaded() const { return has_data_downloaded_; } |
49 bool has_received_upload_progress() const { | 50 bool has_received_upload_progress() const { |
50 return has_received_upload_progress_; | 51 return has_received_upload_progress_; |
51 } | 52 } |
52 bool has_received_cached_metadata() const { | 53 bool has_received_cached_metadata() const { |
53 return has_received_cached_metadata_; | 54 return has_received_cached_metadata_; |
54 } | 55 } |
55 bool has_received_completion() const { return has_received_completion_; } | 56 bool has_received_completion() const { return has_received_completion_; } |
56 const ResourceResponseHead& response_head() const { return response_head_; } | 57 const ResourceResponseHead& response_head() const { return response_head_; } |
| 58 const base::Optional<net::SSLInfo>& ssl_info() const { return ssl_info_; } |
57 const net::RedirectInfo& redirect_info() const { return redirect_info_; } | 59 const net::RedirectInfo& redirect_info() const { return redirect_info_; } |
58 const std::string& cached_metadata() const { | 60 const std::string& cached_metadata() const { |
59 return cached_metadata_; | 61 return cached_metadata_; |
60 } | 62 } |
61 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } | 63 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } |
62 const ResourceRequestCompletionStatus& completion_status() const { | 64 const ResourceRequestCompletionStatus& completion_status() const { |
63 return completion_status_; | 65 return completion_status_; |
64 } | 66 } |
65 int64_t download_data_length() const { return download_data_length_; } | 67 int64_t download_data_length() const { return download_data_length_; } |
66 int64_t encoded_download_data_length() const { | 68 int64_t encoded_download_data_length() const { |
(...skipping 16 matching lines...) Expand all Loading... |
83 void RunUntilResponseReceived(); | 85 void RunUntilResponseReceived(); |
84 void RunUntilRedirectReceived(); | 86 void RunUntilRedirectReceived(); |
85 void RunUntilDataDownloaded(); | 87 void RunUntilDataDownloaded(); |
86 void RunUntilCachedMetadataReceived(); | 88 void RunUntilCachedMetadataReceived(); |
87 void RunUntilResponseBodyArrived(); | 89 void RunUntilResponseBodyArrived(); |
88 void RunUntilComplete(); | 90 void RunUntilComplete(); |
89 | 91 |
90 private: | 92 private: |
91 mojo::Binding<mojom::URLLoaderClient> binding_; | 93 mojo::Binding<mojom::URLLoaderClient> binding_; |
92 ResourceResponseHead response_head_; | 94 ResourceResponseHead response_head_; |
| 95 base::Optional<net::SSLInfo> ssl_info_; |
93 net::RedirectInfo redirect_info_; | 96 net::RedirectInfo redirect_info_; |
94 std::string cached_metadata_; | 97 std::string cached_metadata_; |
95 mojo::ScopedDataPipeConsumerHandle response_body_; | 98 mojo::ScopedDataPipeConsumerHandle response_body_; |
96 ResourceRequestCompletionStatus completion_status_; | 99 ResourceRequestCompletionStatus completion_status_; |
97 bool has_received_response_ = false; | 100 bool has_received_response_ = false; |
98 bool has_received_redirect_ = false; | 101 bool has_received_redirect_ = false; |
99 bool has_data_downloaded_ = false; | 102 bool has_data_downloaded_ = false; |
100 bool has_received_upload_progress_ = false; | 103 bool has_received_upload_progress_ = false; |
101 bool has_received_cached_metadata_ = false; | 104 bool has_received_cached_metadata_ = false; |
102 bool has_received_completion_ = false; | 105 bool has_received_completion_ = false; |
103 base::Closure quit_closure_for_on_receive_response_; | 106 base::Closure quit_closure_for_on_receive_response_; |
104 base::Closure quit_closure_for_on_receive_redirect_; | 107 base::Closure quit_closure_for_on_receive_redirect_; |
105 base::Closure quit_closure_for_on_data_downloaded_; | 108 base::Closure quit_closure_for_on_data_downloaded_; |
106 base::Closure quit_closure_for_on_receive_cached_metadata_; | 109 base::Closure quit_closure_for_on_receive_cached_metadata_; |
107 base::Closure quit_closure_for_on_start_loading_response_body_; | 110 base::Closure quit_closure_for_on_start_loading_response_body_; |
108 base::Closure quit_closure_for_on_complete_; | 111 base::Closure quit_closure_for_on_complete_; |
109 mojom::URLLoaderFactoryPtr url_loader_factory_; | 112 mojom::URLLoaderFactoryPtr url_loader_factory_; |
110 int64_t download_data_length_ = 0; | 113 int64_t download_data_length_ = 0; |
111 int64_t encoded_download_data_length_ = 0; | 114 int64_t encoded_download_data_length_ = 0; |
112 int64_t body_transfer_size_ = 0; | 115 int64_t body_transfer_size_ = 0; |
113 int64_t current_upload_position_ = 0; | 116 int64_t current_upload_position_ = 0; |
114 int64_t total_upload_size_ = 0; | 117 int64_t total_upload_size_ = 0; |
115 | 118 |
116 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient); | 119 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient); |
117 }; | 120 }; |
118 | 121 |
119 } // namespace content | 122 } // namespace content |
120 | 123 |
121 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ | 124 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ |
OLD | NEW |