| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Data will be read for the response. Upon success, this method places the | 99 // Data will be read for the response. Upon success, this method places the |
| 100 // size and address of the buffer where the data is to be written in its | 100 // size and address of the buffer where the data is to be written in its |
| 101 // out-params. This call will be followed by either OnReadCompleted (on | 101 // out-params. This call will be followed by either OnReadCompleted (on |
| 102 // successful read or EOF) or OnResponseCompleted (on error). If | 102 // successful read or EOF) or OnResponseCompleted (on error). If |
| 103 // OnReadCompleted is called, the buffer may be recycled. Otherwise, it may | 103 // OnReadCompleted is called, the buffer may be recycled. Otherwise, it may |
| 104 // not be recycled and may potentially outlive the handler. | 104 // not be recycled and may potentially outlive the handler. |
| 105 // | 105 // |
| 106 // Unlike other methods, may be called synchronously on Resume, for | 106 // Unlike other methods, may be called synchronously on Resume, for |
| 107 // performance reasons. | 107 // performance reasons. |
| 108 // | 108 // |
| 109 // If the handler returns false, then the request is cancelled. Otherwise, | 109 // The request will not continue until one of |controller|'s resume or |
| 110 // once data is available, OnReadCompleted will be called. | 110 // cancellation methods is invoked. |
| 111 // TODO(mmenke): Make this method use a ResourceController, and allow it to | 111 virtual void OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 112 // succeed asynchronously. | 112 int* buf_size, |
| 113 virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 113 std::unique_ptr<ResourceController> controller) = 0; |
| 114 int* buf_size) = 0; | |
| 115 | 114 |
| 116 // Data (*bytes_read bytes) was written into the buffer provided by | 115 // Data (*bytes_read bytes) was written into the buffer provided by |
| 117 // OnWillRead. The request will not continue until one of |controller|'s | 116 // OnWillRead. The request will not continue until one of |controller|'s |
| 118 // resume or cancellation methods is invoked. A zero |bytes_read| signals | 117 // resume or cancellation methods is invoked. A zero |bytes_read| signals |
| 119 // that no further data will be received. | 118 // that no further data will be received. |
| 120 virtual void OnReadCompleted( | 119 virtual void OnReadCompleted( |
| 121 int bytes_read, | 120 int bytes_read, |
| 122 std::unique_ptr<ResourceController> controller) = 0; | 121 std::unique_ptr<ResourceController> controller) = 0; |
| 123 | 122 |
| 124 // The response is complete. The final response status is given. The request | 123 // The response is complete. The final response status is given. The request |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 net::URLRequest* request_; | 175 net::URLRequest* request_; |
| 177 Delegate* delegate_; | 176 Delegate* delegate_; |
| 178 std::unique_ptr<ResourceController> controller_; | 177 std::unique_ptr<ResourceController> controller_; |
| 179 | 178 |
| 180 DISALLOW_COPY_AND_ASSIGN(ResourceHandler); | 179 DISALLOW_COPY_AND_ASSIGN(ResourceHandler); |
| 181 }; | 180 }; |
| 182 | 181 |
| 183 } // namespace content | 182 } // namespace content |
| 184 | 183 |
| 185 #endif // CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ | 184 #endif // CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ |
| OLD | NEW |