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_CORE_H_ | |
6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_CORE_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/browser/loader/navigation_url_loader.h" | |
13 | |
14 namespace net { | |
15 class URLRequest; | |
16 struct RedirectInfo; | |
17 } | |
18 | |
19 namespace content { | |
20 | |
21 class BrowserContext; | |
22 class FrameTreeNode; | |
23 class NavigationResourceHandler; | |
24 class ResourceContext; | |
25 class ResourceHandler; | |
26 class ResourceRequestBody; | |
27 class StreamHandle; | |
28 struct ResourceResponse; | |
29 | |
30 // Part of the implementation of NavigationURLLoaderImpl. It is jointly owned by | |
31 // NavigationURLLoaderImpl on the UI thread and NavigationResourceHandler and IO | |
32 // thread. It passes signals across threads between the two objects. | |
mmenke
2014/10/20 18:52:13
This currently doesn't pass messages to the Naviga
davidben
2014/10/22 01:32:37
Done.
| |
33 class NavigationURLLoaderCore | |
34 : public base::RefCountedThreadSafe<NavigationURLLoaderCore> { | |
mmenke
2014/10/20 18:52:13
Do we really need a refcounted class for this? Se
mmenke
2014/10/20 18:55:18
Actually, I need to figure out ownership semantics
davidben
2014/10/22 01:32:37
Reworked so that Core is owned by Impl, but cross-
| |
35 public: | |
36 NavigationURLLoaderCore(); | |
37 | |
38 // Called on the UI thread to start the request. | |
39 void StartRequest(BrowserContext* browser_context, | |
40 int64 frame_tree_node_id, | |
41 const CommonNavigationParams& common_params, | |
42 scoped_ptr<NavigationRequestInfo> request_info, | |
43 ResourceRequestBody* request_body); | |
44 | |
45 // Called on the UI thread to set the delegate. | |
46 void set_delegate(NavigationURLLoader::Delegate* delegate) { | |
47 delegate_ = delegate; | |
48 } | |
49 | |
50 // Called on the UI thread to resume a deferred redirect. | |
51 void FollowRedirect(); | |
52 | |
53 // Called on the UI thread to cancel a request, if it has not completed. | |
54 // | |
55 // Note: once the response headers are received, the request is considered | |
nasko
2014/10/20 13:52:18
nit: No need for an empty line above.
davidben
2014/10/22 01:32:37
This class got reworked.
| |
56 // completed from the perspective of NavigationURLLoader and ownership is | |
57 // transferred to the StreamHandle containing the body. | |
58 void Cancel(); | |
59 | |
60 // Called on the IO thread to set the resource handler. | |
61 void set_resource_handler(NavigationResourceHandler* resource_handler) { | |
62 resource_handler_ = resource_handler; | |
63 } | |
64 | |
65 // Called on the IO thread when the request is redirected. The request will | |
66 // resume processing on the next call to FollowRedirect on the UI thread. | |
67 void RequestRedirectedOnIOThread(const net::RedirectInfo& redirect_info, | |
68 ResourceResponse* response); | |
69 | |
70 // Called on the IO thread when the response started. | |
71 void ResponseStartedOnIOThread(ResourceResponse* response, | |
72 scoped_ptr<StreamHandle> body); | |
73 | |
74 // Called on the IO thread if the request failed before giving a response. | |
75 void RequestFailedOnIOThread(int net_error); | |
76 | |
77 private: | |
78 friend class base::RefCountedThreadSafe<NavigationURLLoaderCore>; | |
79 | |
80 ~NavigationURLLoaderCore(); | |
81 | |
82 void StartRequestOnIOThread(ResourceContext* resource_context, | |
83 int64 frame_tree_node_id, | |
84 const CommonNavigationParams& common_params, | |
85 scoped_ptr<NavigationRequestInfo> request_info, | |
86 ResourceRequestBody* request_body); | |
87 void FollowRedirectOnIOThread(); | |
88 void CancelOnIOThread(); | |
89 | |
90 void CallOnRequestRedirected(const net::RedirectInfo& redirect_info, | |
91 ResourceResponse* response); | |
92 void CallOnResponseStarted(ResourceResponse* response, | |
93 scoped_ptr<StreamHandle> body); | |
94 void CallOnRequestFailed(int net_error); | |
95 | |
96 NavigationURLLoader::Delegate* delegate_; | |
97 NavigationResourceHandler* resource_handler_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderCore); | |
100 }; | |
101 | |
102 } // namespace content | |
103 | |
104 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_ | |
OLD | NEW |