OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_NETWORK_URL_LOADER_IMPL_H_ | 5 #ifndef CONTENT_NETWORK_URL_LOADER_IMPL_H_ |
6 #define CONTENT_NETWORK_URL_LOADER_IMPL_H_ | 6 #define CONTENT_NETWORK_URL_LOADER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "content/common/url_loader.mojom.h" | 14 #include "content/common/url_loader.mojom.h" |
15 #include "mojo/public/cpp/bindings/associated_binding.h" | 15 #include "mojo/public/cpp/bindings/associated_binding.h" |
16 #include "mojo/public/cpp/system/simple_watcher.h" | 16 #include "mojo/public/cpp/system/simple_watcher.h" |
17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 class NetworkContext; | 21 class NetworkContext; |
22 class NetToMojoPendingBuffer; | 22 class NetToMojoPendingBuffer; |
23 | 23 |
24 class CONTENT_EXPORT URLLoaderImpl : public mojom::URLLoader, | 24 class CONTENT_EXPORT URLLoaderImpl : public mojom::URLLoader, |
25 public net::URLRequest::Delegate { | 25 public net::URLRequest::Delegate { |
26 public: | 26 public: |
27 URLLoaderImpl(NetworkContext* context, | 27 URLLoaderImpl(NetworkContext* context, |
28 mojom::URLLoaderAssociatedRequest url_loader_request, | 28 mojom::URLLoaderAssociatedRequest url_loader_request, |
| 29 int32_t options, |
29 const ResourceRequest& request, | 30 const ResourceRequest& request, |
30 mojom::URLLoaderClientPtr url_loader_client); | 31 mojom::URLLoaderClientPtr url_loader_client); |
31 ~URLLoaderImpl() override; | 32 ~URLLoaderImpl() override; |
32 | 33 |
33 // Called when the associated NetworkContext is going away. | 34 // Called when the associated NetworkContext is going away. |
34 void Cleanup(); | 35 void Cleanup(); |
35 | 36 |
36 // mojom::URLLoader implementation: | 37 // mojom::URLLoader implementation: |
37 void FollowRedirect() override; | 38 void FollowRedirect() override; |
38 void SetPriority(net::RequestPriority priority, | 39 void SetPriority(net::RequestPriority priority, |
(...skipping 10 matching lines...) Expand all Loading... |
49 void ReadMore(); | 50 void ReadMore(); |
50 void DidRead(uint32_t num_bytes, bool completed_synchronously); | 51 void DidRead(uint32_t num_bytes, bool completed_synchronously); |
51 void NotifyCompleted(int error_code); | 52 void NotifyCompleted(int error_code); |
52 void SendDataPipeIfNecessary(); | 53 void SendDataPipeIfNecessary(); |
53 void OnConnectionError(); | 54 void OnConnectionError(); |
54 void OnResponseBodyStreamClosed(MojoResult result); | 55 void OnResponseBodyStreamClosed(MojoResult result); |
55 void OnResponseBodyStreamReady(MojoResult result); | 56 void OnResponseBodyStreamReady(MojoResult result); |
56 void DeleteIfNeeded(); | 57 void DeleteIfNeeded(); |
57 | 58 |
58 NetworkContext* context_; | 59 NetworkContext* context_; |
| 60 int32_t options_; |
59 bool connected_; | 61 bool connected_; |
60 std::unique_ptr<net::URLRequest> url_request_; | 62 std::unique_ptr<net::URLRequest> url_request_; |
61 mojo::AssociatedBinding<mojom::URLLoader> binding_; | 63 mojo::AssociatedBinding<mojom::URLLoader> binding_; |
62 mojom::URLLoaderClientPtr url_loader_client_; | 64 mojom::URLLoaderClientPtr url_loader_client_; |
63 | 65 |
64 mojo::ScopedDataPipeProducerHandle response_body_stream_; | 66 mojo::ScopedDataPipeProducerHandle response_body_stream_; |
65 mojo::ScopedDataPipeConsumerHandle response_body_consumer_handle_; | 67 mojo::ScopedDataPipeConsumerHandle response_body_consumer_handle_; |
66 scoped_refptr<NetToMojoPendingBuffer> pending_write_; | 68 scoped_refptr<NetToMojoPendingBuffer> pending_write_; |
67 mojo::SimpleWatcher writable_handle_watcher_; | 69 mojo::SimpleWatcher writable_handle_watcher_; |
68 mojo::SimpleWatcher peer_closed_handle_watcher_; | 70 mojo::SimpleWatcher peer_closed_handle_watcher_; |
69 | 71 |
70 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; | 72 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; |
71 | 73 |
72 DISALLOW_COPY_AND_ASSIGN(URLLoaderImpl); | 74 DISALLOW_COPY_AND_ASSIGN(URLLoaderImpl); |
73 }; | 75 }; |
74 | 76 |
75 } // namespace content | 77 } // namespace content |
76 | 78 |
77 #endif // CONTENT_NETWORK_URL_LOADER_IMPL_H_ | 79 #endif // CONTENT_NETWORK_URL_LOADER_IMPL_H_ |
OLD | NEW |