OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 30 matching lines...) Expand all Loading... |
41 // false. Set |*defer| to true to defer the redirect. The redirect may be | 41 // false. Set |*defer| to true to defer the redirect. The redirect may be |
42 // followed later on via ResourceDispatcherHost::FollowDeferredRedirect. | 42 // followed later on via ResourceDispatcherHost::FollowDeferredRedirect. |
43 virtual bool OnRequestRedirected(int request_id, const GURL& url, | 43 virtual bool OnRequestRedirected(int request_id, const GURL& url, |
44 ResourceResponse* response, | 44 ResourceResponse* response, |
45 bool* defer) = 0; | 45 bool* defer) = 0; |
46 | 46 |
47 // Response headers and meta data are available. | 47 // Response headers and meta data are available. |
48 virtual bool OnResponseStarted(int request_id, | 48 virtual bool OnResponseStarted(int request_id, |
49 ResourceResponse* response) = 0; | 49 ResourceResponse* response) = 0; |
50 | 50 |
51 // Called before the URLRequest for |request_id| (whose url is |url|) is to be | 51 // Called before the net::URLRequest for |request_id| (whose url is |url|) is |
52 // started. If the handler returns false, then the request is cancelled. | 52 // to be started. If the handler returns false, then the request is cancelled. |
53 // Otherwise if the return value is true, the ResourceHandler can delay the | 53 // Otherwise if the return value is true, the ResourceHandler can delay the |
54 // request from starting by setting |*defer = true|. A deferred request will | 54 // request from starting by setting |*defer = true|. A deferred request will |
55 // not have called URLRequest::Start(), and will not resume until someone | 55 // not have called net::URLRequest::Start(), and will not resume until someone |
56 // calls ResourceDispatcherHost::StartDeferredRequest(). | 56 // calls ResourceDispatcherHost::StartDeferredRequest(). |
57 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) = 0; | 57 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) = 0; |
58 | 58 |
59 // Data will be read for the response. Upon success, this method places the | 59 // Data will be read for the response. Upon success, this method places the |
60 // size and address of the buffer where the data is to be written in its | 60 // size and address of the buffer where the data is to be written in its |
61 // out-params. This call will be followed by either OnReadCompleted or | 61 // out-params. This call will be followed by either OnReadCompleted or |
62 // OnResponseCompleted, at which point the buffer may be recycled. | 62 // OnResponseCompleted, at which point the buffer may be recycled. |
63 virtual bool OnWillRead(int request_id, | 63 virtual bool OnWillRead(int request_id, |
64 net::IOBuffer** buf, | 64 net::IOBuffer** buf, |
65 int* buf_size, | 65 int* buf_size, |
66 int min_size) = 0; | 66 int min_size) = 0; |
67 | 67 |
68 // Data (*bytes_read bytes) was written into the buffer provided by | 68 // Data (*bytes_read bytes) was written into the buffer provided by |
69 // OnWillRead. A return value of false cancels the request, true continues | 69 // OnWillRead. A return value of false cancels the request, true continues |
70 // reading data. | 70 // reading data. |
71 virtual bool OnReadCompleted(int request_id, int* bytes_read) = 0; | 71 virtual bool OnReadCompleted(int request_id, int* bytes_read) = 0; |
72 | 72 |
73 // The response is complete. The final response status is given. | 73 // The response is complete. The final response status is given. |
74 // Returns false if the handler is deferring the call to a later time. | 74 // Returns false if the handler is deferring the call to a later time. |
75 virtual bool OnResponseCompleted(int request_id, | 75 virtual bool OnResponseCompleted(int request_id, |
76 const URLRequestStatus& status, | 76 const URLRequestStatus& status, |
77 const std::string& security_info) = 0; | 77 const std::string& security_info) = 0; |
78 | 78 |
79 // Signals that the request is closed (i.e. finished successfully, cancelled). | 79 // Signals that the request is closed (i.e. finished successfully, cancelled). |
80 // This is a signal that the associated URLRequest isn't valid anymore. | 80 // This is a signal that the associated net::URLRequest isn't valid anymore. |
81 virtual void OnRequestClosed() = 0; | 81 virtual void OnRequestClosed() = 0; |
82 | 82 |
83 // This notification is synthesized by the RedirectToFileResourceHandler | 83 // This notification is synthesized by the RedirectToFileResourceHandler |
84 // to indicate progress of 'download_to_file' requests. OnReadCompleted | 84 // to indicate progress of 'download_to_file' requests. OnReadCompleted |
85 // calls are consumed by the RedirectToFileResourceHandler and replaced | 85 // calls are consumed by the RedirectToFileResourceHandler and replaced |
86 // with OnDataDownloaded calls. | 86 // with OnDataDownloaded calls. |
87 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) {} | 87 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) {} |
88 | 88 |
89 protected: | 89 protected: |
90 friend class BrowserThread; | 90 friend class BrowserThread; |
91 friend class DeleteTask<ResourceHandler>; | 91 friend class DeleteTask<ResourceHandler>; |
92 | 92 |
93 virtual ~ResourceHandler() {} | 93 virtual ~ResourceHandler() {} |
94 }; | 94 }; |
95 | 95 |
96 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ | 96 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ |
OLD | NEW |