| 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_URL_LOADER_DELEGATE_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_H_ |
| 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_H_ | 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_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/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "mojo/public/cpp/system/data_pipe.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 struct RedirectInfo; | 16 struct RedirectInfo; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 class NavigationData; | 21 class NavigationData; |
| 21 class StreamHandle; | 22 class StreamHandle; |
| 22 struct GlobalRequestID; | 23 struct GlobalRequestID; |
| 23 struct ResourceResponse; | 24 struct ResourceResponse; |
| 24 struct SSLStatus; | 25 struct SSLStatus; |
| 25 | 26 |
| 26 // PlzNavigate: The delegate interface to NavigationURLLoader. | 27 // PlzNavigate: The delegate interface to NavigationURLLoader. |
| 27 class CONTENT_EXPORT NavigationURLLoaderDelegate { | 28 class CONTENT_EXPORT NavigationURLLoaderDelegate { |
| 28 public: | 29 public: |
| 29 // Called when the request is redirected. Call FollowRedirect to continue | 30 // Called when the request is redirected. Call FollowRedirect to continue |
| 30 // processing the request. | 31 // processing the request. |
| 31 virtual void OnRequestRedirected( | 32 virtual void OnRequestRedirected( |
| 32 const net::RedirectInfo& redirect_info, | 33 const net::RedirectInfo& redirect_info, |
| 33 const scoped_refptr<ResourceResponse>& response) = 0; | 34 const scoped_refptr<ResourceResponse>& response) = 0; |
| 34 | 35 |
| 35 // Called when the request receives its response. No further calls will be | 36 // Called when the request receives its response. No further calls will be |
| 36 // made to the delegate. The response body is returned as a stream in | 37 // made to the delegate. The response body is returned as a stream in |
| 37 // |body_stream|. |navigation_data| is passed to the NavigationHandle. | 38 // |body_stream|. |navigation_data| is passed to the NavigationHandle. |
| 39 // If --enable-network-service, then |consumer_handle| will be used, |
| 40 // otherwise |body_stream|. Only one of these will ever be non-null. |
| 38 virtual void OnResponseStarted( | 41 virtual void OnResponseStarted( |
| 39 const scoped_refptr<ResourceResponse>& response, | 42 const scoped_refptr<ResourceResponse>& response, |
| 40 std::unique_ptr<StreamHandle> body_stream, | 43 std::unique_ptr<StreamHandle> body_stream, |
| 44 mojo::ScopedDataPipeConsumerHandle consumer_handle, |
| 41 const SSLStatus& ssl_status, | 45 const SSLStatus& ssl_status, |
| 42 std::unique_ptr<NavigationData> navigation_data, | 46 std::unique_ptr<NavigationData> navigation_data, |
| 43 const GlobalRequestID& request_id, | 47 const GlobalRequestID& request_id, |
| 44 bool is_download, | 48 bool is_download, |
| 45 bool is_stream) = 0; | 49 bool is_stream) = 0; |
| 46 | 50 |
| 47 // Called if the request fails before receving a response. |net_error| is a | 51 // Called if the request fails before receving a response. |net_error| is a |
| 48 // network error code for the failure. |has_stale_copy_in_cache| is true if | 52 // network error code for the failure. |has_stale_copy_in_cache| is true if |
| 49 // there is a stale copy of the unreachable page in cache. | 53 // there is a stale copy of the unreachable page in cache. |
| 50 virtual void OnRequestFailed(bool has_stale_copy_in_cache, int net_error) = 0; | 54 virtual void OnRequestFailed(bool has_stale_copy_in_cache, int net_error) = 0; |
| 51 | 55 |
| 52 // Called after the network request has begun on the IO thread at time | 56 // Called after the network request has begun on the IO thread at time |
| 53 // |timestamp|. This is just a thread hop but is used to compare timing | 57 // |timestamp|. This is just a thread hop but is used to compare timing |
| 54 // against the pre-PlzNavigate codepath which didn't start the network request | 58 // against the pre-PlzNavigate codepath which didn't start the network request |
| 55 // until after the renderer was initialized. | 59 // until after the renderer was initialized. |
| 56 virtual void OnRequestStarted(base::TimeTicks timestamp) = 0; | 60 virtual void OnRequestStarted(base::TimeTicks timestamp) = 0; |
| 57 | 61 |
| 58 protected: | 62 protected: |
| 59 NavigationURLLoaderDelegate() {} | 63 NavigationURLLoaderDelegate() {} |
| 60 virtual ~NavigationURLLoaderDelegate() {} | 64 virtual ~NavigationURLLoaderDelegate() {} |
| 61 | 65 |
| 62 private: | 66 private: |
| 63 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderDelegate); |
| 64 }; | 68 }; |
| 65 | 69 |
| 66 } // namespace content | 70 } // namespace content |
| 67 | 71 |
| 68 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_H_ | 72 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_H_ |
| OLD | NEW |