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/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "content/browser/loader/navigation_url_loader.h" | |
12 | |
13 namespace net { | |
14 class URLRequest; | |
15 struct RedirectInfo; | |
16 } | |
17 | |
18 namespace content { | |
19 | |
20 class BrowserContext; | |
21 class FrameTreeNode; | |
22 class NavigationResourceHandler; | |
23 class ResourceContext; | |
24 class ResourceHandler; | |
25 class ResourceRequestBody; | |
26 class StreamHandle; | |
27 struct ResourceResponse; | |
28 | |
29 // Part of the implementation of NavigationURLLoaderImpl. This bridges between | |
30 // the IO and UI thread. | |
31 class NavigationURLLoaderCore | |
clamy
2014/09/12 20:51:25
Why do we have a NavigationURLLoaderImpl and a Nav
davidben
2014/09/19 18:30:50
NavigationURLLoaderImpl is uniquely owned by the U
| |
32 : public base::RefCountedThreadSafe<NavigationURLLoaderCore> { | |
33 public: | |
34 NavigationURLLoaderCore(NavigationURLLoader::Delegate* delegate); | |
35 | |
36 // Called on the UI thread to start the request. | |
37 void StartRequest(BrowserContext* browser_context, | |
38 int64 frame_tree_node_id, | |
39 const NavigationRequestInfo& request_info, | |
40 ResourceRequestBody* request_body); | |
41 | |
42 // Called on the UI thread to resume a deferred redirect. | |
43 void Resume(); | |
44 | |
45 // Called on the UI thread to cancel a request, if it has not completed. No | |
46 // further calls will be made on |delegate_|. Note: if the response has been | |
47 // received, the request is considered completed from the perspective of | |
48 // NavigationURLLoader and ownership is transferred to the StreamHandle | |
49 // containing the body. | |
50 void Cancel(); | |
51 | |
52 // Called on the IO thread to set the resource handler. | |
53 void set_resource_handler(NavigationResourceHandler* resource_handler) { | |
54 resource_handler_ = resource_handler; | |
55 } | |
56 | |
57 // Called on the IO thread when the request is redirected. The request will | |
58 // resume processing on the next call to Resume. | |
59 void RequestRedirectedOnIOThread(const net::RedirectInfo& redirect_info, | |
60 ResourceResponse* response); | |
61 | |
62 // Called on the IO thread when the response started. No further calls will be | |
63 // made on |resource_handler_|. | |
64 void ResponseStartedOnIOThread(ResourceResponse* response, | |
65 scoped_ptr<StreamHandle> body); | |
66 | |
67 // Called on the IO thread if the request failed before giving a response. No | |
68 // further calls will be made on |resource_handler_|. | |
69 void RequestFailedOnIOThread(int net_error); | |
70 | |
71 private: | |
72 friend class base::RefCountedThreadSafe<NavigationURLLoaderCore>; | |
73 | |
74 ~NavigationURLLoaderCore(); | |
75 | |
76 void StartRequestOnIOThread(ResourceContext* resource_context, | |
77 int64 frame_tree_node_id, | |
78 const NavigationRequestInfo& request_info, | |
79 ResourceRequestBody* request_body); | |
80 void ResumeOnIOThread(); | |
81 void CancelOnIOThread(); | |
82 | |
83 void CallOnRequestRedirected(const net::RedirectInfo& redirect_info, | |
84 ResourceResponse* response); | |
85 void CallOnResponseStarted(ResourceResponse* response, | |
86 scoped_ptr<StreamHandle> body); | |
87 void CallOnRequestFailed(int net_error); | |
88 | |
89 NavigationURLLoader::Delegate* delegate_; | |
90 NavigationResourceHandler* resource_handler_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderCore); | |
93 }; | |
94 | |
95 } // namespace content | |
96 | |
97 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_ | |
OLD | NEW |