OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/common/content_export.h" |
| 13 |
| 14 namespace net { |
| 15 struct RedirectInfo; |
| 16 } |
| 17 |
| 18 namespace content { |
| 19 |
| 20 class BrowserContext; |
| 21 class NavigationURLLoaderFactory; |
| 22 class StreamHandle; |
| 23 class ResourceRequestBody; |
| 24 struct NavigationRequestInfo; |
| 25 struct ResourceResponse; |
| 26 |
| 27 // PlzNavigate: The navigation logic's UI thread entry point into the resource |
| 28 // loading stack. It exposes an interface to control the request prior to |
| 29 // receiving the response. If the NavigationURLLoader is destroyed before |
| 30 // OnResponseStarted is called, the request is aborted. |
| 31 class CONTENT_EXPORT NavigationURLLoader { |
| 32 public: |
| 33 class Delegate { |
| 34 public: |
| 35 virtual ~Delegate() {} |
| 36 |
| 37 // Called when the request is redirected. Call FollowRedirect to continue |
| 38 // processing the request. Apart from the reference count on |response|, |
| 39 // they must not be modified on the UI thread. |
| 40 virtual void OnRequestRedirected(const net::RedirectInfo& redirect_info, |
| 41 ResourceResponse* response) = 0; |
| 42 |
| 43 // Called when the request receives its response. No further calls will be |
| 44 // made to the delegate. The response body is returned as a stream in |
| 45 // |body|. |
| 46 virtual void OnResponseStarted(ResourceResponse* response, |
| 47 scoped_ptr<StreamHandle> body) = 0; |
| 48 |
| 49 // Called if the request fails before receving a response. |net_error| is a |
| 50 // network error code for the failure. |
| 51 virtual void OnRequestFailed(int net_error) = 0; |
| 52 }; |
| 53 |
| 54 // Creates a NavigationURLLoader. The caller is responsible for ensuring that |
| 55 // |delegate| outlives the loader. |request_body| must not be accessed on the |
| 56 // UI thread after this point. |
| 57 static NavigationURLLoader* Create(BrowserContext* browser_context, |
| 58 int64 frame_tree_node_id, |
| 59 const NavigationRequestInfo& request_info, |
| 60 ResourceRequestBody* request_body, |
| 61 Delegate* delegate); |
| 62 |
| 63 // For testing purposes; sets the factory for use in testing. |
| 64 static void SetFactoryForTesting(NavigationURLLoaderFactory* factory); |
| 65 |
| 66 virtual ~NavigationURLLoader() {} |
| 67 |
| 68 // Called in response to OnRequestRedirected to continue processing the |
| 69 // request. |
| 70 virtual void FollowRedirect() = 0; |
| 71 }; |
| 72 |
| 73 } // namespace content |
| 74 |
| 75 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_ |
OLD | NEW |