| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_NAVIGATION_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "content/browser/loader/resource_handler.h" | 12 #include "content/browser/loader/layered_resource_handler.h" |
| 13 #include "content/browser/loader/stream_writer.h" | 13 #include "content/public/browser/stream_handle.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 class SSLInfo; | 16 class SSLInfo; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class NavigationURLLoaderImplCore; | 20 class NavigationURLLoaderImplCore; |
| 21 class ResourceController; | 21 class ResourceController; |
| 22 class ResourceDispatcherHostDelegate; | 22 class ResourceDispatcherHostDelegate; |
| 23 struct SSLStatus; | 23 struct SSLStatus; |
| 24 | 24 |
| 25 // PlzNavigate: The leaf ResourceHandler used with NavigationURLLoaderImplCore. | 25 // PlzNavigate: The ResourceHandler used with NavigationURLLoaderImplCore to |
| 26 class NavigationResourceHandler : public ResourceHandler { | 26 // control the flow of navigation requests. |
| 27 class NavigationResourceHandler : public LayeredResourceHandler { |
| 27 public: | 28 public: |
| 28 static void GetSSLStatusForRequest(const net::SSLInfo& ssl_info, | 29 static void GetSSLStatusForRequest(const net::SSLInfo& ssl_info, |
| 29 SSLStatus* ssl_status); | 30 SSLStatus* ssl_status); |
| 30 | 31 |
| 31 NavigationResourceHandler( | 32 NavigationResourceHandler( |
| 32 net::URLRequest* request, | 33 net::URLRequest* request, |
| 34 std::unique_ptr<ResourceHandler> next_handler, |
| 33 NavigationURLLoaderImplCore* core, | 35 NavigationURLLoaderImplCore* core, |
| 34 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate); | 36 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, |
| 37 std::unique_ptr<StreamHandle> stream_handle); |
| 35 ~NavigationResourceHandler() override; | 38 ~NavigationResourceHandler() override; |
| 36 | 39 |
| 37 // Called by the loader the cancel the request. | 40 // Called by the loader the cancel the request. |
| 38 void Cancel(); | 41 void Cancel(); |
| 39 | 42 |
| 40 // Called to the loader to resume a paused redirect. | 43 // Called to the loader to resume a paused redirect. |
| 41 void FollowRedirect(); | 44 void FollowRedirect(); |
| 42 | 45 |
| 43 // Called to proceed with the response. | 46 // Called to proceed with the response. |
| 44 void ProceedWithResponse(); | 47 void ProceedWithResponse(); |
| 45 | 48 |
| 46 // ResourceHandler implementation. | 49 // LayeredResourceHandler implementation. |
| 47 void OnRequestRedirected( | 50 void OnRequestRedirected( |
| 48 const net::RedirectInfo& redirect_info, | 51 const net::RedirectInfo& redirect_info, |
| 49 ResourceResponse* response, | 52 ResourceResponse* response, |
| 50 std::unique_ptr<ResourceController> controller) override; | 53 std::unique_ptr<ResourceController> controller) override; |
| 51 void OnResponseStarted( | 54 void OnResponseStarted( |
| 52 ResourceResponse* response, | 55 ResourceResponse* response, |
| 53 std::unique_ptr<ResourceController> controller) override; | 56 std::unique_ptr<ResourceController> controller) override; |
| 54 void OnWillStart(const GURL& url, | |
| 55 std::unique_ptr<ResourceController> controller) override; | |
| 56 void OnWillRead(scoped_refptr<net::IOBuffer>* buf, | |
| 57 int* buf_size, | |
| 58 std::unique_ptr<ResourceController> controller) override; | |
| 59 void OnReadCompleted(int bytes_read, | |
| 60 std::unique_ptr<ResourceController> controller) override; | |
| 61 void OnResponseCompleted( | 57 void OnResponseCompleted( |
| 62 const net::URLRequestStatus& status, | 58 const net::URLRequestStatus& status, |
| 63 std::unique_ptr<ResourceController> controller) override; | 59 std::unique_ptr<ResourceController> controller) override; |
| 64 void OnDataDownloaded(int bytes_downloaded) override; | |
| 65 | 60 |
| 66 private: | 61 private: |
| 67 // Clears |core_| and its reference to the resource handler. After calling | 62 // Clears |core_| and its reference to the resource handler. After calling |
| 68 // this, the lifetime of the request is no longer managed by the | 63 // this, the lifetime of the request is no longer managed by the |
| 69 // NavigationURLLoader. | 64 // NavigationURLLoader. |
| 70 void DetachFromCore(); | 65 void DetachFromCore(); |
| 71 | 66 |
| 67 // Used to buffer the response and redirect info while waiting for UI thread |
| 68 // checks to execute. |
| 69 scoped_refptr<ResourceResponse> response_; |
| 70 std::unique_ptr<net::RedirectInfo> redirect_info_; |
| 71 |
| 72 // NavigationResourceHandler has joint ownership of the | 72 // NavigationResourceHandler has joint ownership of the |
| 73 // NavigationURLLoaderImplCore with the NavigationURLLoaderImpl. | 73 // NavigationURLLoaderImplCore with the NavigationURLLoaderImpl. |
| 74 scoped_refptr<NavigationURLLoaderImplCore> core_; | 74 scoped_refptr<NavigationURLLoaderImplCore> core_; |
| 75 StreamWriter writer_; | 75 std::unique_ptr<StreamHandle> stream_handle_; |
| 76 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate_; | 76 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(NavigationResourceHandler); | 78 DISALLOW_COPY_AND_ASSIGN(NavigationResourceHandler); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace content | 81 } // namespace content |
| 82 | 82 |
| 83 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ | 83 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ |
| OLD | NEW |