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 #ifndef CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_BACKEND_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_BACKEND_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_BACKEND_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 26 matching lines...) Expand all Loading... | |
37 typedef int RequestID; | 37 typedef int RequestID; |
38 | 38 |
39 ChromeURLDataManagerBackend(); | 39 ChromeURLDataManagerBackend(); |
40 ~ChromeURLDataManagerBackend(); | 40 ~ChromeURLDataManagerBackend(); |
41 | 41 |
42 // Invoked to create the protocol handler for chrome://. | 42 // Invoked to create the protocol handler for chrome://. |
43 static net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler( | 43 static net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler( |
44 ChromeURLDataManagerBackend* backend); | 44 ChromeURLDataManagerBackend* backend); |
45 | 45 |
46 // Adds a DataSource to the collection of data sources. | 46 // Adds a DataSource to the collection of data sources. |
47 void AddDataSource(ChromeURLDataManager::DataSource* source); | 47 void AddDataSource(URLDataSource* source); |
48 | 48 |
49 // DataSource invokes this. Sends the data to the URLRequest. | 49 // DataSource invokes this. Sends the data to the URLRequest. |
50 void DataAvailable(RequestID request_id, base::RefCountedMemory* bytes); | 50 void DataAvailable(RequestID request_id, base::RefCountedMemory* bytes); |
51 | 51 |
52 static net::URLRequestJob* Factory(net::URLRequest* request, | 52 static net::URLRequestJob* Factory(net::URLRequest* request, |
53 const std::string& scheme); | 53 const std::string& scheme); |
54 | 54 |
55 private: | 55 private: |
56 friend class URLRequestChromeJob; | 56 friend class URLRequestChromeJob; |
57 | 57 |
58 typedef std::map<std::string, | 58 typedef std::map<std::string, |
59 scoped_refptr<ChromeURLDataManager::DataSource> > DataSourceMap; | 59 scoped_refptr<URLDataSource> > DataSourceMap; |
60 typedef std::map<RequestID, URLRequestChromeJob*> PendingRequestMap; | 60 typedef std::map<RequestID, URLRequestChromeJob*> PendingRequestMap; |
61 | 61 |
62 // Called by the job when it's starting up. | 62 // Called by the job when it's starting up. |
63 // Returns false if |url| is not a URL managed by this object. | 63 // Returns false if |url| is not a URL managed by this object. |
64 bool StartRequest(const GURL& url, URLRequestChromeJob* job); | 64 bool StartRequest(const GURL& url, URLRequestChromeJob* job); |
65 | 65 |
66 static void CallStartRequest(scoped_refptr<URLDataSource>, | |
James Hawkins
2013/01/14 18:53:54
nit: Document method and parameters.
Rationale: m
jam
2013/01/14 19:21:18
Done.
| |
67 const std::string& path, | |
68 bool is_incognito, | |
69 int request_id); | |
70 | |
66 // Remove a request from the list of pending requests. | 71 // Remove a request from the list of pending requests. |
67 void RemoveRequest(URLRequestChromeJob* job); | 72 void RemoveRequest(URLRequestChromeJob* job); |
68 | 73 |
69 // Returns true if the job exists in |pending_requests_|. False otherwise. | 74 // Returns true if the job exists in |pending_requests_|. False otherwise. |
70 // Called by ~URLRequestChromeJob to verify that |pending_requests_| is kept | 75 // Called by ~URLRequestChromeJob to verify that |pending_requests_| is kept |
71 // up to date. | 76 // up to date. |
72 bool HasPendingJob(URLRequestChromeJob* job) const; | 77 bool HasPendingJob(URLRequestChromeJob* job) const; |
73 | 78 |
74 // Custom sources of data, keyed by source path (e.g. "favicon"). | 79 // Custom sources of data, keyed by source path (e.g. "favicon"). |
75 DataSourceMap data_sources_; | 80 DataSourceMap data_sources_; |
76 | 81 |
77 // All pending URLRequestChromeJobs, keyed by ID of the request. | 82 // All pending URLRequestChromeJobs, keyed by ID of the request. |
78 // URLRequestChromeJob calls into this object when it's constructed and | 83 // URLRequestChromeJob calls into this object when it's constructed and |
79 // destructed to ensure that the pointers in this map remain valid. | 84 // destructed to ensure that the pointers in this map remain valid. |
80 PendingRequestMap pending_requests_; | 85 PendingRequestMap pending_requests_; |
81 | 86 |
82 // The ID we'll use for the next request we receive. | 87 // The ID we'll use for the next request we receive. |
83 RequestID next_request_id_; | 88 RequestID next_request_id_; |
84 | 89 |
85 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManagerBackend); | 90 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManagerBackend); |
86 }; | 91 }; |
87 | 92 |
88 net::URLRequestJobFactory::ProtocolHandler* | 93 net::URLRequestJobFactory::ProtocolHandler* |
89 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend, | 94 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend, |
90 net::NetworkDelegate* network_delegate); | 95 net::NetworkDelegate* network_delegate); |
91 | 96 |
92 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_BACKEND_H_ | 97 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_BACKEND_H_ |
OLD | NEW |