Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: content/browser/loader/test_url_loader_client.h

Issue 2503813002: Fix and refactor downloaded file handling in the loading stack (Closed)
Patch Set: -Release Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "content/common/resource_request_completion_status.h" 12 #include "content/common/resource_request_completion_status.h"
13 #include "content/common/url_loader.mojom.h" 13 #include "content/common/url_loader.mojom.h"
14 #include "content/common/url_loader_factory.mojom.h" 14 #include "content/common/url_loader_factory.mojom.h"
15 #include "content/public/common/resource_response.h" 15 #include "content/public/common/resource_response.h"
16 #include "mojo/public/c/system/data_pipe.h" 16 #include "mojo/public/c/system/data_pipe.h"
17 #include "mojo/public/cpp/bindings/associated_binding.h" 17 #include "mojo/public/cpp/bindings/associated_binding.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 // A TestURLLoaderClient records URLLoaderClient function calls. It also calls 21 // A TestURLLoaderClient records URLLoaderClient function calls. It also calls
22 // the closure set via set_quit_closure if set, in order to make it possible to 22 // the closure set via set_quit_closure if set, in order to make it possible to
23 // create a base::RunLoop, set its quit closure to this client and then run the 23 // create a base::RunLoop, set its quit closure to this client and then run the
24 // RunLoop. 24 // RunLoop.
25 class TestURLLoaderClient final : public mojom::URLLoaderClient { 25 class TestURLLoaderClient final : public mojom::URLLoaderClient {
26 public: 26 public:
27 TestURLLoaderClient(); 27 TestURLLoaderClient();
28 ~TestURLLoaderClient() override; 28 ~TestURLLoaderClient() override;
29 29
30 void OnReceiveResponse(const ResourceResponseHead& response_head) override; 30 void OnReceiveResponse(const ResourceResponseHead& response_head,
31 mojom::DownloadedTempFilePtr downloaded_file) override;
31 void OnDataDownloaded(int64_t data_length, int64_t encoded_length) override; 32 void OnDataDownloaded(int64_t data_length, int64_t encoded_length) override;
32 void OnStartLoadingResponseBody( 33 void OnStartLoadingResponseBody(
33 mojo::ScopedDataPipeConsumerHandle body) override; 34 mojo::ScopedDataPipeConsumerHandle body) override;
34 void OnComplete(const ResourceRequestCompletionStatus& status) override; 35 void OnComplete(const ResourceRequestCompletionStatus& status) override;
35 36
36 bool has_received_response() const { return has_received_response_; } 37 bool has_received_response() const { return has_received_response_; }
37 bool has_data_downloaded() const { return has_data_downloaded_; } 38 bool has_data_downloaded() const { return has_data_downloaded_; }
38 bool has_received_completion() const { return has_received_completion_; } 39 bool has_received_completion() const { return has_received_completion_; }
39 const ResourceResponseHead& response_head() const { return response_head_; } 40 const ResourceResponseHead& response_head() const { return response_head_; }
40 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); } 41 mojo::DataPipeConsumerHandle response_body() { return response_body_.get(); }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 mojom::URLLoaderFactoryPtr url_loader_factory_; 75 mojom::URLLoaderFactoryPtr url_loader_factory_;
75 int64_t download_data_length_ = 0; 76 int64_t download_data_length_ = 0;
76 int64_t encoded_download_data_length_ = 0; 77 int64_t encoded_download_data_length_ = 0;
77 78
78 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient); 79 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient);
79 }; 80 };
80 81
81 } // namespace content 82 } // namespace content
82 83
83 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_ 84 #endif // CONTENT_BROWSER_LOADER_TEST_URL_LOADER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698