| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "mojo/public/cpp/system/data_pipe.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 struct RedirectInfo; | 15 struct RedirectInfo; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class StreamHandle; | 20 class StreamHandle; |
| 20 struct ResourceResponse; | 21 struct ResourceResponse; |
| 21 | 22 |
| 22 // PlzNavigate: The delegate interface to NavigationURLLoader. | 23 // PlzNavigate: The delegate interface to NavigationURLLoader. |
| 23 class CONTENT_EXPORT NavigationURLLoaderDelegate { | 24 class CONTENT_EXPORT NavigationURLLoaderDelegate { |
| 24 public: | 25 public: |
| 25 // Called when the request is redirected. Call FollowRedirect to continue | 26 // Called when the request is redirected. Call FollowRedirect to continue |
| 26 // processing the request. | 27 // processing the request. |
| 27 virtual void OnRequestRedirected( | 28 virtual void OnRequestRedirected( |
| 28 const net::RedirectInfo& redirect_info, | 29 const net::RedirectInfo& redirect_info, |
| 29 const scoped_refptr<ResourceResponse>& response) = 0; | 30 const scoped_refptr<ResourceResponse>& response) = 0; |
| 30 | 31 |
| 31 // Called when the request receives its response. No further calls will be | 32 // Called when the request receives its response. No further calls will be |
| 32 // made to the delegate. The response body is returned as a stream in | 33 // made to the delegate. The response body is returned as a stream in |
| 33 // |body_stream|. | 34 // |body_stream|. |
| 34 virtual void OnResponseStarted( | 35 virtual void OnResponseStarted( |
| 35 const scoped_refptr<ResourceResponse>& response, | 36 const scoped_refptr<ResourceResponse>& response, |
| 36 scoped_ptr<StreamHandle> body_stream) = 0; | 37 mojo::ScopedDataPipeConsumerHandle data_consumer_handle, |
| 38 int request_id) = 0; |
| 37 | 39 |
| 38 // Called if the request fails before receving a response. |net_error| is a | 40 // Called if the request fails before receving a response. |net_error| is a |
| 39 // network error code for the failure. |has_stale_copy_in_cache| is true if | 41 // network error code for the failure. |has_stale_copy_in_cache| is true if |
| 40 // there is a stale copy of the unreachable page in cache. | 42 // there is a stale copy of the unreachable page in cache. |
| 41 virtual void OnRequestFailed(bool has_stale_copy_in_cache, int net_error) = 0; | 43 virtual void OnRequestFailed(bool has_stale_copy_in_cache, int net_error) = 0; |
| 42 | 44 |
| 43 // Called after the network request has begun on the IO thread at time | 45 // Called after the network request has begun on the IO thread at time |
| 44 // |timestamp|. This is just a thread hop but is used to compare timing | 46 // |timestamp|. This is just a thread hop but is used to compare timing |
| 45 // against the pre-PlzNavigate codepath which didn't start the network request | 47 // against the pre-PlzNavigate codepath which didn't start the network request |
| 46 // until after the renderer was initialized. | 48 // until after the renderer was initialized. |
| 47 virtual void OnRequestStarted(base::TimeTicks timestamp) = 0; | 49 virtual void OnRequestStarted(base::TimeTicks timestamp) = 0; |
| 48 | 50 |
| 49 protected: | 51 protected: |
| 50 NavigationURLLoaderDelegate() {} | 52 NavigationURLLoaderDelegate() {} |
| 51 virtual ~NavigationURLLoaderDelegate() {} | 53 virtual ~NavigationURLLoaderDelegate() {} |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderDelegate); | 56 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderDelegate); |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 } // namespace content | 59 } // namespace content |
| 58 | 60 |
| 59 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_H_ | 61 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_DELEGATE_H_ |
| OLD | NEW |