| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // delay the request from starting by setting |*defer = true|. A deferred | 69 // delay the request from starting by setting |*defer = true|. A deferred |
| 70 // request will not have called net::URLRequest::Start(), and will not resume | 70 // request will not have called net::URLRequest::Start(), and will not resume |
| 71 // until someone calls ResourceDispatcherHost::StartDeferredRequest(). | 71 // until someone calls ResourceDispatcherHost::StartDeferredRequest(). |
| 72 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) = 0; | 72 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) = 0; |
| 73 | 73 |
| 74 // Data will be read for the response. Upon success, this method places the | 74 // Data will be read for the response. Upon success, this method places the |
| 75 // size and address of the buffer where the data is to be written in its | 75 // size and address of the buffer where the data is to be written in its |
| 76 // out-params. This call will be followed by either OnReadCompleted or | 76 // out-params. This call will be followed by either OnReadCompleted or |
| 77 // OnResponseCompleted, at which point the buffer may be recycled. | 77 // OnResponseCompleted, at which point the buffer may be recycled. |
| 78 // | 78 // |
| 79 // If this method returns false, then the request will not be read. This is | 79 // If the handler returns false, then the request is cancelled. Otherwise, |
| 80 // normally used in conjunction with ResourceDispatcherHost::PauseRequest to | 80 // once data is available, OnReadCompleted will be called. |
| 81 // pause the processing of the request. When the request is later resumed, | |
| 82 // OnWillRead will be called again. | |
| 83 virtual bool OnWillRead(int request_id, | 81 virtual bool OnWillRead(int request_id, |
| 84 net::IOBuffer** buf, | 82 net::IOBuffer** buf, |
| 85 int* buf_size, | 83 int* buf_size, |
| 86 int min_size) = 0; | 84 int min_size) = 0; |
| 87 | 85 |
| 88 // Data (*bytes_read bytes) was written into the buffer provided by | 86 // Data (*bytes_read bytes) was written into the buffer provided by |
| 89 // OnWillRead. A return value of false cancels the request, true continues | 87 // OnWillRead. A return value of false cancels the request, true continues |
| 90 // reading data. Set |*defer| to true to defer reading more response data. | 88 // reading data. Set |*defer| to true to defer reading more response data. |
| 91 // Call ResourceDispatcherHostImpl::ResumeDeferredRequest to continue reading | 89 // Call ResourceDispatcherHostImpl::ResumeDeferredRequest to continue reading |
| 92 // response data. | 90 // response data. |
| 93 virtual bool OnReadCompleted(int request_id, int* bytes_read, | 91 virtual bool OnReadCompleted(int request_id, int bytes_read, |
| 94 bool* defer) = 0; | 92 bool* defer) = 0; |
| 95 | 93 |
| 96 // The response is complete. The final response status is given. Returns | 94 // The response is complete. The final response status is given. Returns |
| 97 // false if the handler is deferring the call to a later time. Otherwise, | 95 // false if the handler is deferring the call to a later time. Otherwise, |
| 98 // the request will be destroyed upon return. | 96 // the request will be destroyed upon return. |
| 99 virtual bool OnResponseCompleted(int request_id, | 97 virtual bool OnResponseCompleted(int request_id, |
| 100 const net::URLRequestStatus& status, | 98 const net::URLRequestStatus& status, |
| 101 const std::string& security_info) = 0; | 99 const std::string& security_info) = 0; |
| 102 | 100 |
| 103 // This notification is synthesized by the RedirectToFileResourceHandler | 101 // This notification is synthesized by the RedirectToFileResourceHandler |
| 104 // to indicate progress of 'download_to_file' requests. OnReadCompleted | 102 // to indicate progress of 'download_to_file' requests. OnReadCompleted |
| 105 // calls are consumed by the RedirectToFileResourceHandler and replaced | 103 // calls are consumed by the RedirectToFileResourceHandler and replaced |
| 106 // with OnDataDownloaded calls. | 104 // with OnDataDownloaded calls. |
| 107 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) {} | 105 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) {} |
| 108 | 106 |
| 109 protected: | 107 protected: |
| 110 ResourceHandler() : controller_(NULL) {} | 108 ResourceHandler() : controller_(NULL) {} |
| 111 ResourceController* controller() { return controller_; } | 109 ResourceController* controller() { return controller_; } |
| 112 | 110 |
| 113 private: | 111 private: |
| 114 ResourceController* controller_; | 112 ResourceController* controller_; |
| 115 }; | 113 }; |
| 116 | 114 |
| 117 } // namespace content | 115 } // namespace content |
| 118 | 116 |
| 119 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ | 117 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ |
| OLD | NEW |