| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // The request will not continue until one of |controller|'s resume or | 94 // The request will not continue until one of |controller|'s resume or |
| 95 // cancellation methods is invoked. | 95 // cancellation methods is invoked. |
| 96 virtual void OnWillStart(const GURL& url, | 96 virtual void OnWillStart(const GURL& url, |
| 97 std::unique_ptr<ResourceController> controller) = 0; | 97 std::unique_ptr<ResourceController> controller) = 0; |
| 98 | 98 |
| 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. If |min_size| is | 104 // not be recycled and may potentially outlive the handler. |
| 105 // not -1, it is the minimum size of the returned buffer. | |
| 106 // | 105 // |
| 107 // Unlike other methods, may be called synchronously on Resume, for | 106 // Unlike other methods, may be called synchronously on Resume, for |
| 108 // performance reasons. | 107 // performance reasons. |
| 109 // | 108 // |
| 110 // If the handler returns false, then the request is cancelled. Otherwise, | 109 // If the handler returns false, then the request is cancelled. Otherwise, |
| 111 // once data is available, OnReadCompleted will be called. | 110 // once data is available, OnReadCompleted will be called. |
| 112 // TODO(mmenke): Make this method use a ResourceController, and allow it to | 111 // TODO(mmenke): Make this method use a ResourceController, and allow it to |
| 113 // succeed asynchronously. | 112 // succeed asynchronously. |
| 114 virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 113 virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 115 int* buf_size, | 114 int* buf_size) = 0; |
| 116 int min_size) = 0; | |
| 117 | 115 |
| 118 // Data (*bytes_read bytes) was written into the buffer provided by | 116 // Data (*bytes_read bytes) was written into the buffer provided by |
| 119 // OnWillRead. The request will not continue until one of |controller|'s | 117 // OnWillRead. The request will not continue until one of |controller|'s |
| 120 // resume or cancellation methods is invoked. A zero |bytes_read| signals | 118 // resume or cancellation methods is invoked. A zero |bytes_read| signals |
| 121 // that no further data will be received. | 119 // that no further data will be received. |
| 122 virtual void OnReadCompleted( | 120 virtual void OnReadCompleted( |
| 123 int bytes_read, | 121 int bytes_read, |
| 124 std::unique_ptr<ResourceController> controller) = 0; | 122 std::unique_ptr<ResourceController> controller) = 0; |
| 125 | 123 |
| 126 // The response is complete. The final response status is given. The request | 124 // 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... |
| 178 net::URLRequest* request_; | 176 net::URLRequest* request_; |
| 179 Delegate* delegate_; | 177 Delegate* delegate_; |
| 180 std::unique_ptr<ResourceController> controller_; | 178 std::unique_ptr<ResourceController> controller_; |
| 181 | 179 |
| 182 DISALLOW_COPY_AND_ASSIGN(ResourceHandler); | 180 DISALLOW_COPY_AND_ASSIGN(ResourceHandler); |
| 183 }; | 181 }; |
| 184 | 182 |
| 185 } // namespace content | 183 } // namespace content |
| 186 | 184 |
| 187 #endif // CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ | 185 #endif // CONTENT_BROWSER_LOADER_RESOURCE_HANDLER_H_ |
| OLD | NEW |