Chromium Code Reviews| 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 | |
|
nasko
2014/09/24 21:15:34
What happens if FollowRedirect is not called? What
davidben
2014/10/03 16:27:52
If FollowRedirect isn't called, the request just s
| |
| 38 // processing the request. Apart from the reference count on |response|, | |
| 39 // they must not be modified on the UI thread. | |
|
nasko
2014/09/24 21:15:34
nit: What is "they"?
davidben
2014/10/03 16:27:52
Removed the comment. It makes a copy of the Resour
| |
| 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 | |
|
nasko
2014/09/24 21:15:34
Do we need to notify the delegate if the request r
davidben
2014/10/03 16:27:52
If it results in a download, we'll get OnRequestFa
| |
| 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; | |
|
mmenke
2014/09/23 17:22:45
private:
DISALLOW_COPY_AND_ASSIGN?
Suppose it's
davidben
2014/10/03 16:27:52
Done, but it requires adding a default ctor somewh
| |
| 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 // | |
| 58 // TODO(davidben): When navigation is disentangled from the loader, the | |
| 59 // request parameters should not come in as a navigation-specific | |
| 60 // structure. Information like has_user_gesture and | |
| 61 // should_replace_current_entry shouldn't be needed at this layer. | |
| 62 static NavigationURLLoader* Create(BrowserContext* browser_context, | |
| 63 int64 frame_tree_node_id, | |
| 64 const NavigationRequestInfo& request_info, | |
| 65 ResourceRequestBody* request_body, | |
| 66 Delegate* delegate); | |
| 67 | |
| 68 // For testing purposes; sets the factory for use in testing. | |
| 69 static void SetFactoryForTesting(NavigationURLLoaderFactory* factory); | |
| 70 | |
| 71 virtual ~NavigationURLLoader() {} | |
| 72 | |
| 73 // Called in response to OnRequestRedirected to continue processing the | |
| 74 // request. | |
| 75 virtual void FollowRedirect() = 0; | |
|
mmenke
2014/09/23 17:22:45
private:
DISALLOW_COPY_AND_ASSIGN?
davidben
2014/10/03 16:27:52
Done, but it requires adding a default ctor somewh
| |
| 76 }; | |
| 77 | |
| 78 } // namespace content | |
| 79 | |
| 80 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_ | |
| OLD | NEW |