OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This is the browser side of the resource dispatcher, it receives requests | 5 // This is the browser side of the resource dispatcher, it receives requests |
6 // from the RenderProcessHosts, and dispatches them to URLRequests. It then | 6 // from the RenderProcessHosts, and dispatches them to URLRequests. It then |
7 // fowards the messages from the URLRequests back to the correct process for | 7 // fowards the messages from the URLRequests back to the correct process for |
8 // handling. | 8 // handling. |
9 // | 9 // |
10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
11 | 11 |
12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ | 12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ |
13 #define CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ | 13 #define CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ |
14 | 14 |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/sequenced_task_runner_helpers.h" | 18 #include "base/sequenced_task_runner_helpers.h" |
19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
21 | 21 |
22 class GURL; | 22 class GURL; |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 class IOBuffer; | 25 class IOBuffer; |
| 26 struct RedirectInfo; |
26 class URLRequest; | 27 class URLRequest; |
27 class URLRequestStatus; | 28 class URLRequestStatus; |
28 } // namespace net | 29 } // namespace net |
29 | 30 |
30 namespace content { | 31 namespace content { |
31 class ResourceController; | 32 class ResourceController; |
32 class ResourceMessageFilter; | 33 class ResourceMessageFilter; |
33 class ResourceRequestInfoImpl; | 34 class ResourceRequestInfoImpl; |
34 struct ResourceResponse; | 35 struct ResourceResponse; |
35 | 36 |
36 // The resource dispatcher host uses this interface to process network events | 37 // The resource dispatcher host uses this interface to process network events |
37 // for an URLRequest instance. A ResourceHandler's lifetime is bound to its | 38 // for an URLRequest instance. A ResourceHandler's lifetime is bound to its |
38 // associated URLRequest. | 39 // associated URLRequest. |
39 class CONTENT_EXPORT ResourceHandler | 40 class CONTENT_EXPORT ResourceHandler |
40 : public NON_EXPORTED_BASE(base::NonThreadSafe) { | 41 : public NON_EXPORTED_BASE(base::NonThreadSafe) { |
41 public: | 42 public: |
42 virtual ~ResourceHandler() {} | 43 virtual ~ResourceHandler() {} |
43 | 44 |
44 // Sets the controller for this handler. | 45 // Sets the controller for this handler. |
45 virtual void SetController(ResourceController* controller); | 46 virtual void SetController(ResourceController* controller); |
46 | 47 |
47 // Called as upload progress is made. The return value is ignored. | 48 // Called as upload progress is made. The return value is ignored. |
48 virtual bool OnUploadProgress(uint64 position, uint64 size) = 0; | 49 virtual bool OnUploadProgress(uint64 position, uint64 size) = 0; |
49 | 50 |
50 // The request was redirected to a new URL. |*defer| has an initial value of | 51 // The request was redirected to a new URL. |*defer| has an initial value of |
51 // false. Set |*defer| to true to defer the redirect. The redirect may be | 52 // false. Set |*defer| to true to defer the redirect. The redirect may be |
52 // followed later on via ResourceDispatcherHost::FollowDeferredRedirect. If | 53 // followed later on via ResourceDispatcherHost::FollowDeferredRedirect. If |
53 // the handler returns false, then the request is cancelled. | 54 // the handler returns false, then the request is cancelled. |
54 virtual bool OnRequestRedirected(const GURL& url, | 55 virtual bool OnRequestRedirected(const net::RedirectInfo& redirect_info, |
55 ResourceResponse* response, | 56 ResourceResponse* response, |
56 bool* defer) = 0; | 57 bool* defer) = 0; |
57 | 58 |
58 // Response headers and meta data are available. If the handler returns | 59 // Response headers and meta data are available. If the handler returns |
59 // false, then the request is cancelled. Set |*defer| to true to defer | 60 // false, then the request is cancelled. Set |*defer| to true to defer |
60 // processing of the response. Call ResourceDispatcherHostImpl:: | 61 // processing of the response. Call ResourceDispatcherHostImpl:: |
61 // ResumeDeferredRequest to continue processing the response. | 62 // ResumeDeferredRequest to continue processing the response. |
62 virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) = 0; | 63 virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) = 0; |
63 | 64 |
64 // Called before the net::URLRequest (whose url is |url|) is to be started. | 65 // Called before the net::URLRequest (whose url is |url|) is to be started. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 ResourceMessageFilter* GetFilter() const; | 123 ResourceMessageFilter* GetFilter() const; |
123 | 124 |
124 private: | 125 private: |
125 ResourceController* controller_; | 126 ResourceController* controller_; |
126 net::URLRequest* request_; | 127 net::URLRequest* request_; |
127 }; | 128 }; |
128 | 129 |
129 } // namespace content | 130 } // namespace content |
130 | 131 |
131 #endif // CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ | 132 #endif // CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ |
OLD | NEW |