OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_ |
| 6 #define CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include "base/callback_forward.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "content/common/url_loader.mojom.h" |
| 13 #include "ipc/ipc_message.h" |
| 14 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 15 #include "mojo/public/cpp/system/data_pipe.h" |
| 16 |
| 17 namespace base { |
| 18 class SingleThreadTaskRunner; |
| 19 } // namespace base |
| 20 |
| 21 namespace mojo { |
| 22 class AssociatedGroup; |
| 23 } // namespace mojo |
| 24 |
| 25 namespace net { |
| 26 struct RedirectInfo; |
| 27 } // namespace net |
| 28 |
| 29 namespace content { |
| 30 class ResourceDispatcher; |
| 31 class URLResponseBodyConsumer; |
| 32 struct ResourceRequestCompletionStatus; |
| 33 struct ResourceResponseHead; |
| 34 |
| 35 class CONTENT_EXPORT URLLoaderClientImpl final : public mojom::URLLoaderClient { |
| 36 public: |
| 37 URLLoaderClientImpl(int request_id, |
| 38 ResourceDispatcher* resource_dispatcher, |
| 39 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 40 ~URLLoaderClientImpl() override; |
| 41 |
| 42 void Bind(mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info, |
| 43 mojo::AssociatedGroup* associated_group); |
| 44 |
| 45 // mojom::URLLoaderClient implementation |
| 46 void OnReceiveResponse(const ResourceResponseHead& response_head, |
| 47 mojom::DownloadedTempFilePtr downloaded_file) override; |
| 48 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
| 49 const ResourceResponseHead& response_head) override; |
| 50 void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override; |
| 51 void OnTransferSizeUpdated(int32_t transfer_size_diff) override; |
| 52 void OnStartLoadingResponseBody( |
| 53 mojo::ScopedDataPipeConsumerHandle body) override; |
| 54 void OnComplete(const ResourceRequestCompletionStatus& status) override; |
| 55 |
| 56 private: |
| 57 void Dispatch(const IPC::Message& message); |
| 58 |
| 59 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_; |
| 60 scoped_refptr<URLResponseBodyConsumer> body_consumer_; |
| 61 mojom::DownloadedTempFilePtr downloaded_file_; |
| 62 const int request_id_; |
| 63 bool has_received_response_ = false; |
| 64 ResourceDispatcher* const resource_dispatcher_; |
| 65 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 66 }; |
| 67 |
| 68 } // namespace content |
| 69 |
| 70 #endif // CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_ |
OLD | NEW |