OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
11 | 11 |
12 #ifndef CHROME_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ | 12 #ifndef CHROME_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ |
13 #define CHROME_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ | 13 #define CHROME_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ |
14 #pragma once | 14 #pragma once |
15 | 15 |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "chrome/browser/browser_thread.h" | 18 #include "chrome/browser/browser_thread.h" |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 class IOBuffer; | 21 class IOBuffer; |
22 } | 22 class URLRequestStatus; |
| 23 } // namespace net |
23 | 24 |
24 struct ResourceResponse; | 25 struct ResourceResponse; |
25 class GURL; | 26 class GURL; |
26 class URLRequestStatus; | |
27 | 27 |
28 // The resource dispatcher host uses this interface to push load events to the | 28 // The resource dispatcher host uses this interface to push load events to the |
29 // renderer, allowing for differences in the types of IPC messages generated. | 29 // renderer, allowing for differences in the types of IPC messages generated. |
30 // See the implementations of this interface defined below. | 30 // See the implementations of this interface defined below. |
31 class ResourceHandler | 31 class ResourceHandler |
32 : public base::RefCountedThreadSafe< | 32 : public base::RefCountedThreadSafe< |
33 ResourceHandler, BrowserThread::DeleteOnIOThread> { | 33 ResourceHandler, BrowserThread::DeleteOnIOThread> { |
34 public: | 34 public: |
35 // Called as upload progress is made. | 35 // Called as upload progress is made. |
36 virtual bool OnUploadProgress(int request_id, | 36 virtual bool OnUploadProgress(int request_id, |
(...skipping 29 matching lines...) Expand all Loading... |
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 net::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 net::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 |