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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 // The request was redirected to a new URL. |*defer| has an initial value of | 45 // The request was redirected to a new URL. |*defer| has an initial value of |
46 // false. Set |*defer| to true to defer the redirect. The redirect may be | 46 // false. Set |*defer| to true to defer the redirect. The redirect may be |
47 // followed later on via ResourceDispatcherHost::FollowDeferredRedirect. If | 47 // followed later on via ResourceDispatcherHost::FollowDeferredRedirect. If |
48 // the handler returns false, then the request is cancelled. | 48 // the handler returns false, then the request is cancelled. |
49 virtual bool OnRequestRedirected(int request_id, const GURL& url, | 49 virtual bool OnRequestRedirected(int request_id, const GURL& url, |
50 content::ResourceResponse* response, | 50 content::ResourceResponse* response, |
51 bool* defer) = 0; | 51 bool* defer) = 0; |
52 | 52 |
53 // Response headers and meta data are available. If the handler returns | 53 // Response headers and meta data are available. If the handler returns |
54 // false, then the request is cancelled. | 54 // false, then the request is cancelled. Set |*defer| to true to defer |
| 55 // processing of the response. Call ResourceDispatcherHostImpl:: |
| 56 // ResumeDeferredRequest to continue processing the response. |
55 virtual bool OnResponseStarted(int request_id, | 57 virtual bool OnResponseStarted(int request_id, |
56 content::ResourceResponse* response) = 0; | 58 content::ResourceResponse* response, |
| 59 bool* defer) = 0; |
57 | 60 |
58 // Called before the net::URLRequest for |request_id| (whose url is |url|) is | 61 // Called before the net::URLRequest for |request_id| (whose url is |url|) is |
59 // to be started. If the handler returns false, then the request is | 62 // to be started. If the handler returns false, then the request is |
60 // cancelled. Otherwise if the return value is true, the ResourceHandler can | 63 // cancelled. Otherwise if the return value is true, the ResourceHandler can |
61 // delay the request from starting by setting |*defer = true|. A deferred | 64 // delay the request from starting by setting |*defer = true|. A deferred |
62 // request will not have called net::URLRequest::Start(), and will not resume | 65 // request will not have called net::URLRequest::Start(), and will not resume |
63 // until someone calls ResourceDispatcherHost::StartDeferredRequest(). | 66 // until someone calls ResourceDispatcherHost::StartDeferredRequest(). |
64 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) = 0; | 67 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) = 0; |
65 | 68 |
66 // Data will be read for the response. Upon success, this method places the | 69 // Data will be read for the response. Upon success, this method places the |
67 // size and address of the buffer where the data is to be written in its | 70 // size and address of the buffer where the data is to be written in its |
68 // out-params. This call will be followed by either OnReadCompleted or | 71 // out-params. This call will be followed by either OnReadCompleted or |
69 // OnResponseCompleted, at which point the buffer may be recycled. | 72 // OnResponseCompleted, at which point the buffer may be recycled. |
70 // | 73 // |
71 // If this method returns false, then the request will not be read. This is | 74 // If this method returns false, then the request will not be read. This is |
72 // normally used in conjunction with ResourceDispatcherHost::PauseRequest to | 75 // normally used in conjunction with ResourceDispatcherHost::PauseRequest to |
73 // pause the processing of the request. When the request is later resumed, | 76 // pause the processing of the request. When the request is later resumed, |
74 // OnWillRead will be called again. | 77 // OnWillRead will be called again. |
75 virtual bool OnWillRead(int request_id, | 78 virtual bool OnWillRead(int request_id, |
76 net::IOBuffer** buf, | 79 net::IOBuffer** buf, |
77 int* buf_size, | 80 int* buf_size, |
78 int min_size) = 0; | 81 int min_size) = 0; |
79 | 82 |
80 // Data (*bytes_read bytes) was written into the buffer provided by | 83 // Data (*bytes_read bytes) was written into the buffer provided by |
81 // OnWillRead. A return value of false cancels the request, true continues | 84 // OnWillRead. A return value of false cancels the request, true continues |
82 // reading data. | 85 // reading data. Set |*defer| to true to defer reading more response data. |
83 virtual bool OnReadCompleted(int request_id, int* bytes_read) = 0; | 86 // Call ResourceDispatcherHostImpl::ResumeDeferredRequest to continue reading |
| 87 // response data. |
| 88 virtual bool OnReadCompleted(int request_id, int* bytes_read, |
| 89 bool* defer) = 0; |
84 | 90 |
85 // The response is complete. The final response status is given. Returns | 91 // The response is complete. The final response status is given. Returns |
86 // false if the handler is deferring the call to a later time. Otherwise, | 92 // false if the handler is deferring the call to a later time. Otherwise, |
87 // the request will be destroyed upon return. | 93 // the request will be destroyed upon return. |
88 virtual bool OnResponseCompleted(int request_id, | 94 virtual bool OnResponseCompleted(int request_id, |
89 const net::URLRequestStatus& status, | 95 const net::URLRequestStatus& status, |
90 const std::string& security_info) = 0; | 96 const std::string& security_info) = 0; |
91 | 97 |
92 // Signals that the request is closed (i.e. about to be deleted). This is a | 98 // Signals that the request is closed (i.e. about to be deleted). This is a |
93 // signal that the associated net::URLRequest isn't valid anymore. | 99 // signal that the associated net::URLRequest isn't valid anymore. |
94 virtual void OnRequestClosed() = 0; | 100 virtual void OnRequestClosed() = 0; |
95 | 101 |
96 // This notification is synthesized by the RedirectToFileResourceHandler | 102 // This notification is synthesized by the RedirectToFileResourceHandler |
97 // to indicate progress of 'download_to_file' requests. OnReadCompleted | 103 // to indicate progress of 'download_to_file' requests. OnReadCompleted |
98 // calls are consumed by the RedirectToFileResourceHandler and replaced | 104 // calls are consumed by the RedirectToFileResourceHandler and replaced |
99 // with OnDataDownloaded calls. | 105 // with OnDataDownloaded calls. |
100 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) {} | 106 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) {} |
101 | 107 |
102 protected: | 108 protected: |
103 friend class content::BrowserThread; | 109 friend class content::BrowserThread; |
104 friend class base::RefCountedThreadSafe< | 110 friend class base::RefCountedThreadSafe< |
105 ResourceHandler, content::BrowserThread::DeleteOnIOThread>; | 111 ResourceHandler, content::BrowserThread::DeleteOnIOThread>; |
106 friend class base::DeleteHelper<ResourceHandler>; | 112 friend class base::DeleteHelper<ResourceHandler>; |
107 | 113 |
108 virtual ~ResourceHandler() {} | 114 virtual ~ResourceHandler() {} |
109 }; | 115 }; |
110 | 116 |
111 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ | 117 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ |
OLD | NEW |