| 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 #ifndef CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 6 #define CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "chrome/common/ref_counted_util.h" | 12 #include "base/ref_counted_memory.h" |
| 13 | 13 |
| 14 class DictionaryValue; | 14 class DictionaryValue; |
| 15 class FilePath; | 15 class FilePath; |
| 16 class GURL; | 16 class GURL; |
| 17 class MessageLoop; | 17 class MessageLoop; |
| 18 class URLRequest; | 18 class URLRequest; |
| 19 class URLRequestChromeJob; | 19 class URLRequestChromeJob; |
| 20 class URLRequestJob; | 20 class URLRequestJob; |
| 21 | 21 |
| 22 // To serve dynamic data off of chrome: URLs, implement the | 22 // To serve dynamic data off of chrome: URLs, implement the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 51 // not be satisfied. | 51 // not be satisfied. |
| 52 virtual void StartDataRequest(const std::string& path, int request_id) = 0; | 52 virtual void StartDataRequest(const std::string& path, int request_id) = 0; |
| 53 | 53 |
| 54 // Return the mimetype that should be sent with this response, or empty | 54 // Return the mimetype that should be sent with this response, or empty |
| 55 // string to specify no mime type. | 55 // string to specify no mime type. |
| 56 virtual std::string GetMimeType(const std::string& path) const = 0; | 56 virtual std::string GetMimeType(const std::string& path) const = 0; |
| 57 | 57 |
| 58 // Report that a request has resulted in the data |bytes|. | 58 // Report that a request has resulted in the data |bytes|. |
| 59 // If the request can't be satisfied, pass NULL for |bytes| to indicate | 59 // If the request can't be satisfied, pass NULL for |bytes| to indicate |
| 60 // the request is over. | 60 // the request is over. |
| 61 void SendResponse(int request_id, RefCountedBytes* bytes); | 61 void SendResponse(int request_id, RefCountedMemory* bytes); |
| 62 | 62 |
| 63 // Returns the MessageLoop on which the DataSource wishes to have | 63 // Returns the MessageLoop on which the DataSource wishes to have |
| 64 // StartDataRequest called to handle the request for |path|. If the | 64 // StartDataRequest called to handle the request for |path|. If the |
| 65 // DataSource does not care which thread StartDataRequest is called on, | 65 // DataSource does not care which thread StartDataRequest is called on, |
| 66 // this should return NULL. The default implementation always returns | 66 // this should return NULL. The default implementation always returns |
| 67 // message_loop_, which generally results in processing on the UI thread. | 67 // message_loop_, which generally results in processing on the UI thread. |
| 68 // It may be beneficial to return NULL for requests that are safe to handle | 68 // It may be beneficial to return NULL for requests that are safe to handle |
| 69 // directly on the IO thread. This can improve performance by satisfying | 69 // directly on the IO thread. This can improve performance by satisfying |
| 70 // such requests more rapidly when there is a large amount of UI thread | 70 // such requests more rapidly when there is a large amount of UI thread |
| 71 // contention. | 71 // contention. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Remove a request from the list of pending requests. | 124 // Remove a request from the list of pending requests. |
| 125 void RemoveRequest(URLRequestChromeJob* job); | 125 void RemoveRequest(URLRequestChromeJob* job); |
| 126 | 126 |
| 127 // Returns true if the job exists in |pending_requests_|. False otherwise. | 127 // Returns true if the job exists in |pending_requests_|. False otherwise. |
| 128 // Called by ~URLRequestChromeJob to verify that |pending_requests_| is kept | 128 // Called by ~URLRequestChromeJob to verify that |pending_requests_| is kept |
| 129 // up to date. | 129 // up to date. |
| 130 bool HasPendingJob(URLRequestChromeJob* job) const; | 130 bool HasPendingJob(URLRequestChromeJob* job) const; |
| 131 | 131 |
| 132 // Sent by Request::SendResponse. | 132 // Sent by Request::SendResponse. |
| 133 void DataAvailable(RequestID request_id, | 133 void DataAvailable(RequestID request_id, |
| 134 scoped_refptr<RefCountedBytes> bytes); | 134 scoped_refptr<RefCountedMemory> bytes); |
| 135 | 135 |
| 136 // File sources of data, keyed by source name (e.g. "inspector"). | 136 // File sources of data, keyed by source name (e.g. "inspector"). |
| 137 typedef std::map<std::string, FilePath> FileSourceMap; | 137 typedef std::map<std::string, FilePath> FileSourceMap; |
| 138 FileSourceMap file_sources_; | 138 FileSourceMap file_sources_; |
| 139 | 139 |
| 140 // Custom sources of data, keyed by source path (e.g. "favicon"). | 140 // Custom sources of data, keyed by source path (e.g. "favicon"). |
| 141 typedef std::map<std::string, scoped_refptr<DataSource> > DataSourceMap; | 141 typedef std::map<std::string, scoped_refptr<DataSource> > DataSourceMap; |
| 142 DataSourceMap data_sources_; | 142 DataSourceMap data_sources_; |
| 143 | 143 |
| 144 // All pending URLRequestChromeJobs, keyed by ID of the request. | 144 // All pending URLRequestChromeJobs, keyed by ID of the request. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 162 extern ChromeURLDataManager chrome_url_data_manager; | 162 extern ChromeURLDataManager chrome_url_data_manager; |
| 163 | 163 |
| 164 // Register our special URL handler under our special URL scheme. | 164 // Register our special URL handler under our special URL scheme. |
| 165 // Must be done once at startup. | 165 // Must be done once at startup. |
| 166 void RegisterURLRequestChromeJob(); | 166 void RegisterURLRequestChromeJob(); |
| 167 | 167 |
| 168 // Undoes the registration done by RegisterURLRequestChromeJob. | 168 // Undoes the registration done by RegisterURLRequestChromeJob. |
| 169 void UnregisterURLRequestChromeJob(); | 169 void UnregisterURLRequestChromeJob(); |
| 170 | 170 |
| 171 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 171 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
| OLD | NEW |