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 CommonNavigationParams; | |
25 struct NavigationRequestInfo; | |
26 struct ResourceResponse; | |
27 | |
28 // PlzNavigate: The navigation logic's UI thread entry point into the resource | |
29 // loading stack. It exposes an interface to control the request prior to | |
30 // receiving the response. If the NavigationURLLoader is destroyed before | |
31 // OnResponseStarted is called, the request is aborted. | |
32 class CONTENT_EXPORT NavigationURLLoader { | |
33 public: | |
34 class CONTENT_EXPORT Delegate { | |
mmenke
2014/10/22 15:32:58
I believe that there's a preference to make delega
davidben
2014/10/22 20:58:04
Done. (Another file? Fine.)
| |
35 public: | |
36 // Called when the request is redirected. Call FollowRedirect to continue | |
37 // processing the request. | |
38 virtual void OnRequestRedirected(const net::RedirectInfo& redirect_info, | |
39 ResourceResponse* response) = 0; | |
40 | |
41 // Called when the request receives its response. No further calls will be | |
42 // made to the delegate. The response body is returned as a stream in | |
43 // |body|. | |
44 virtual void OnResponseStarted(ResourceResponse* response, | |
45 scoped_ptr<StreamHandle> body) = 0; | |
46 | |
47 // Called if the request fails before receving a response. |net_error| is a | |
48 // network error code for the failure. | |
49 virtual void OnRequestFailed(int net_error) = 0; | |
50 | |
51 protected: | |
52 Delegate() {} | |
53 virtual ~Delegate() {} | |
54 | |
55 private: | |
56 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
57 }; | |
58 | |
59 // Creates a NavigationURLLoader. The caller is responsible for ensuring that | |
60 // |delegate| outlives the loader. |request_body| must not be accessed on the | |
61 // UI thread after this point. | |
62 // | |
63 // TODO(davidben): When navigation is disentangled from the loader, the | |
64 // request parameters should not come in as a navigation-specific | |
65 // structure. Information like has_user_gesture and | |
66 // should_replace_current_entry shouldn't be needed at this layer. | |
67 static scoped_ptr<NavigationURLLoader> Create( | |
68 BrowserContext* browser_context, | |
69 int64 frame_tree_node_id, | |
70 const CommonNavigationParams& common_params, | |
71 scoped_ptr<NavigationRequestInfo> request_info, | |
72 ResourceRequestBody* request_body, | |
73 Delegate* delegate); | |
74 | |
75 // For testing purposes; sets the factory for use in testing. | |
76 static void SetFactoryForTesting(NavigationURLLoaderFactory* factory); | |
77 | |
78 virtual ~NavigationURLLoader() {} | |
79 | |
80 // Called in response to OnRequestRedirected to continue processing the | |
81 // request. | |
82 virtual void FollowRedirect() = 0; | |
83 | |
84 protected: | |
mmenke
2014/10/22 15:32:58
nit: +1 indent, here and below.
davidben
2014/10/22 20:58:04
Done. Huh, I wonder why emacs is failing me here..
| |
85 NavigationURLLoader() {} | |
86 | |
87 private: | |
88 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoader); | |
89 }; | |
90 | |
91 } // namespace content | |
92 | |
93 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_ | |
OLD | NEW |