| 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> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "content/browser/loader/resource_handler.h" | 11 #include "content/browser/loader/resource_handler.h" |
| 10 #include "content/browser/loader/stream_writer.h" | 12 #include "content/browser/loader/stream_writer.h" |
| 11 | 13 |
| 12 namespace net { | 14 namespace net { |
| 13 class SSLInfo; | 15 class SSLInfo; |
| 14 } | 16 } |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 class NavigationURLLoaderImplCore; | 19 class NavigationURLLoaderImplCore; |
| 20 class ResourceController; |
| 18 class ResourceDispatcherHostDelegate; | 21 class ResourceDispatcherHostDelegate; |
| 19 struct SSLStatus; | 22 struct SSLStatus; |
| 20 | 23 |
| 21 // PlzNavigate: The leaf ResourceHandler used with NavigationURLLoaderImplCore. | 24 // PlzNavigate: The leaf ResourceHandler used with NavigationURLLoaderImplCore. |
| 22 class NavigationResourceHandler : public ResourceHandler { | 25 class NavigationResourceHandler : public ResourceHandler { |
| 23 public: | 26 public: |
| 24 static void GetSSLStatusForRequest(const GURL& url, | 27 static void GetSSLStatusForRequest(const GURL& url, |
| 25 const net::SSLInfo& ssl_info, | 28 const net::SSLInfo& ssl_info, |
| 26 int child_id, | 29 int child_id, |
| 27 SSLStatus* ssl_status); | 30 SSLStatus* ssl_status); |
| 28 | 31 |
| 29 NavigationResourceHandler( | 32 NavigationResourceHandler( |
| 30 net::URLRequest* request, | 33 net::URLRequest* request, |
| 31 NavigationURLLoaderImplCore* core, | 34 NavigationURLLoaderImplCore* core, |
| 32 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate); | 35 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate); |
| 33 ~NavigationResourceHandler() override; | 36 ~NavigationResourceHandler() override; |
| 34 | 37 |
| 35 // Called by the loader the cancel the request. | 38 // Called by the loader the cancel the request. |
| 36 void Cancel(); | 39 void Cancel(); |
| 37 | 40 |
| 38 // Called to the loader to resume a paused redirect. | 41 // Called to the loader to resume a paused redirect. |
| 39 void FollowRedirect(); | 42 void FollowRedirect(); |
| 40 | 43 |
| 41 // Called to proceed with the response. | 44 // Called to proceed with the response. |
| 42 void ProceedWithResponse(); | 45 void ProceedWithResponse(); |
| 43 | 46 |
| 44 // ResourceHandler implementation. | 47 // ResourceHandler implementation. |
| 45 void SetController(ResourceController* controller) override; | 48 void OnRequestRedirected( |
| 46 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 49 const net::RedirectInfo& redirect_info, |
| 47 ResourceResponse* response, | 50 ResourceResponse* response, |
| 48 bool* defer) override; | 51 std::unique_ptr<ResourceController> controller) override; |
| 49 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 52 void OnResponseStarted( |
| 50 bool OnWillStart(const GURL& url, bool* defer) override; | 53 ResourceResponse* response, |
| 54 std::unique_ptr<ResourceController> controller) override; |
| 55 void OnWillStart(const GURL& url, |
| 56 std::unique_ptr<ResourceController> controller) override; |
| 51 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 57 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 52 int* buf_size, | 58 int* buf_size, |
| 53 int min_size) override; | 59 int min_size) override; |
| 54 bool OnReadCompleted(int bytes_read, bool* defer) override; | 60 void OnReadCompleted(int bytes_read, |
| 55 void OnResponseCompleted(const net::URLRequestStatus& status, | 61 std::unique_ptr<ResourceController> controller) override; |
| 56 bool* defer) override; | 62 void OnResponseCompleted( |
| 63 const net::URLRequestStatus& status, |
| 64 std::unique_ptr<ResourceController> controller) override; |
| 57 void OnDataDownloaded(int bytes_downloaded) override; | 65 void OnDataDownloaded(int bytes_downloaded) override; |
| 58 | 66 |
| 59 private: | 67 private: |
| 60 // Clears |core_| and its reference to the resource handler. After calling | 68 // Clears |core_| and its reference to the resource handler. After calling |
| 61 // this, the lifetime of the request is no longer tied to |core_|. | 69 // this, the lifetime of the request is no longer tied to |core_|. |
| 62 void DetachFromCore(); | 70 void DetachFromCore(); |
| 63 | 71 |
| 64 NavigationURLLoaderImplCore* core_; | 72 NavigationURLLoaderImplCore* core_; |
| 65 StreamWriter writer_; | 73 StreamWriter writer_; |
| 66 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate_; | 74 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate_; |
| 67 | 75 |
| 68 DISALLOW_COPY_AND_ASSIGN(NavigationResourceHandler); | 76 DISALLOW_COPY_AND_ASSIGN(NavigationResourceHandler); |
| 69 }; | 77 }; |
| 70 | 78 |
| 71 } // namespace content | 79 } // namespace content |
| 72 | 80 |
| 73 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ | 81 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_HANDLER_H_ |
| OLD | NEW |