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 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class TestURLLoaderClient final : public mojom::URLLoaderClient { | 26 class TestURLLoaderClient final : public mojom::URLLoaderClient { |
27 public: | 27 public: |
28 TestURLLoaderClient(); | 28 TestURLLoaderClient(); |
29 ~TestURLLoaderClient() override; | 29 ~TestURLLoaderClient() override; |
30 | 30 |
31 void OnReceiveResponse(const ResourceResponseHead& response_head, | 31 void OnReceiveResponse(const ResourceResponseHead& response_head, |
32 mojom::DownloadedTempFilePtr downloaded_file) override; | 32 mojom::DownloadedTempFilePtr downloaded_file) override; |
33 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, | 33 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
34 const ResourceResponseHead& response_head) override; | 34 const ResourceResponseHead& response_head) override; |
35 void OnDataDownloaded(int64_t data_length, int64_t encoded_length) override; | 35 void OnDataDownloaded(int64_t data_length, int64_t encoded_length) override; |
| 36 void OnTransferSizeUpdated(int64_t transfer_size_diff) override; |
36 void OnStartLoadingResponseBody( | 37 void OnStartLoadingResponseBody( |
37 mojo::ScopedDataPipeConsumerHandle body) override; | 38 mojo::ScopedDataPipeConsumerHandle body) override; |
38 void OnComplete(const ResourceRequestCompletionStatus& status) override; | 39 void OnComplete(const ResourceRequestCompletionStatus& status) override; |
39 | 40 |
40 bool has_received_response() const { return has_received_response_; } | 41 bool has_received_response() const { return has_received_response_; } |
41 bool has_received_redirect() const { return has_received_redirect_; } | 42 bool has_received_redirect() const { return has_received_redirect_; } |
42 bool has_data_downloaded() const { return has_data_downloaded_; } | 43 bool has_data_downloaded() const { return has_data_downloaded_; } |
43 bool has_received_completion() const { return has_received_completion_; } | 44 bool has_received_completion() const { return has_received_completion_; } |
44 const ResourceResponseHead& response_head() const { return response_head_; } | 45 const ResourceResponseHead& response_head() const { return response_head_; } |
45 const net::RedirectInfo& redirect_info() const { return redirect_info_; } | 46 const net::RedirectInfo& redirect_info() const { return redirect_info_; } |
46 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } | 47 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } |
47 const ResourceRequestCompletionStatus& completion_status() const { | 48 const ResourceRequestCompletionStatus& completion_status() const { |
48 return completion_status_; | 49 return completion_status_; |
49 } | 50 } |
50 int64_t download_data_length() const { return download_data_length_; } | 51 int64_t download_data_length() const { return download_data_length_; } |
51 int64_t encoded_download_data_length() const { | 52 int64_t encoded_download_data_length() const { |
52 return encoded_download_data_length_; | 53 return encoded_download_data_length_; |
53 } | 54 } |
| 55 int64_t body_transfer_size() const { return body_transfer_size_; } |
54 | 56 |
55 void ClearHasReceivedRedirect(); | 57 void ClearHasReceivedRedirect(); |
56 // Creates an AssociatedPtrInfo, binds it to |*this| and returns it. The | 58 // Creates an AssociatedPtrInfo, binds it to |*this| and returns it. The |
57 // returned PtrInfo is marked as remote, i.e., expected to be passed to the | 59 // returned PtrInfo is marked as remote, i.e., expected to be passed to the |
58 // remote endpoint. | 60 // remote endpoint. |
59 mojom::URLLoaderClientAssociatedPtrInfo CreateRemoteAssociatedPtrInfo( | 61 mojom::URLLoaderClientAssociatedPtrInfo CreateRemoteAssociatedPtrInfo( |
60 mojo::AssociatedGroup* associated_group); | 62 mojo::AssociatedGroup* associated_group); |
61 | 63 |
62 void Unbind(); | 64 void Unbind(); |
63 | 65 |
(...skipping 14 matching lines...) Expand all Loading... |
78 bool has_data_downloaded_ = false; | 80 bool has_data_downloaded_ = false; |
79 bool has_received_completion_ = false; | 81 bool has_received_completion_ = false; |
80 base::Closure quit_closure_for_on_receive_response_; | 82 base::Closure quit_closure_for_on_receive_response_; |
81 base::Closure quit_closure_for_on_receive_redirect_; | 83 base::Closure quit_closure_for_on_receive_redirect_; |
82 base::Closure quit_closure_for_on_data_downloaded_; | 84 base::Closure quit_closure_for_on_data_downloaded_; |
83 base::Closure quit_closure_for_on_start_loading_response_body_; | 85 base::Closure quit_closure_for_on_start_loading_response_body_; |
84 base::Closure quit_closure_for_on_complete_; | 86 base::Closure quit_closure_for_on_complete_; |
85 mojom::URLLoaderFactoryPtr url_loader_factory_; | 87 mojom::URLLoaderFactoryPtr url_loader_factory_; |
86 int64_t download_data_length_ = 0; | 88 int64_t download_data_length_ = 0; |
87 int64_t encoded_download_data_length_ = 0; | 89 int64_t encoded_download_data_length_ = 0; |
| 90 int64_t body_transfer_size_ = 0; |
88 | 91 |
89 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient); | 92 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient); |
90 }; | 93 }; |
91 | 94 |
92 } // namespace content | 95 } // namespace content |
93 | 96 |
94 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ | 97 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ |
OLD | NEW |