| 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 // Constructs URLLoaderImpl. The created instance must be owned by the |
| 28 // caller until Start() method is called. Once Start() is called this |
| 29 // self-destructs itself on connection close. |
| 27 URLLoaderImpl(NetworkContext* context, | 30 URLLoaderImpl(NetworkContext* context, |
| 28 mojom::URLLoaderAssociatedRequest url_loader_request, | |
| 29 int32_t options, | 31 int32_t options, |
| 30 const ResourceRequest& request, | 32 const ResourceRequest& request); |
| 31 mojom::URLLoaderClientPtr url_loader_client); | |
| 32 ~URLLoaderImpl() override; | 33 ~URLLoaderImpl() override; |
| 33 | 34 |
| 34 // Called when the associated NetworkContext is going away. | 35 // Called when the associated NetworkContext is going away. |
| 35 void Cleanup(); | 36 void Cleanup(); |
| 36 | 37 |
| 37 // mojom::URLLoader implementation: | 38 // mojom::URLLoader implementation: |
| 39 void Start(mojom::URLLoaderAssociatedRequest url_loader_request, |
| 40 mojom::URLLoaderClientPtr url_loader_client) override; |
| 38 void FollowRedirect() override; | 41 void FollowRedirect() override; |
| 39 void SetPriority(net::RequestPriority priority, | 42 void SetPriority(net::RequestPriority priority, |
| 40 int32_t intra_priority_value) override; | 43 int32_t intra_priority_value) override; |
| 41 | 44 |
| 42 // net::URLRequest::Delegate methods: | 45 // net::URLRequest::Delegate methods: |
| 43 void OnReceivedRedirect(net::URLRequest* url_request, | 46 void OnReceivedRedirect(net::URLRequest* url_request, |
| 44 const net::RedirectInfo& redirect_info, | 47 const net::RedirectInfo& redirect_info, |
| 45 bool* defer_redirect) override; | 48 bool* defer_redirect) override; |
| 46 void OnResponseStarted(net::URLRequest* url_request, int net_error) override; | 49 void OnResponseStarted(net::URLRequest* url_request, int net_error) override; |
| 47 void OnReadCompleted(net::URLRequest* url_request, int bytes_read) override; | 50 void OnReadCompleted(net::URLRequest* url_request, int bytes_read) override; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 70 mojo::SimpleWatcher peer_closed_handle_watcher_; | 73 mojo::SimpleWatcher peer_closed_handle_watcher_; |
| 71 | 74 |
| 72 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; | 75 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; |
| 73 | 76 |
| 74 DISALLOW_COPY_AND_ASSIGN(URLLoaderImpl); | 77 DISALLOW_COPY_AND_ASSIGN(URLLoaderImpl); |
| 75 }; | 78 }; |
| 76 | 79 |
| 77 } // namespace content | 80 } // namespace content |
| 78 | 81 |
| 79 #endif // CONTENT_NETWORK_URL_LOADER_IMPL_H_ | 82 #endif // CONTENT_NETWORK_URL_LOADER_IMPL_H_ |
| OLD | NEW |