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 CONTENT_BROWSER_WEBUI_URL_DATA_MANAGER_BACKEND_H_ | 5 #ifndef CONTENT_BROWSER_WEBUI_URL_DATA_MANAGER_BACKEND_H_ |
6 #define CONTENT_BROWSER_WEBUI_URL_DATA_MANAGER_BACKEND_H_ | 6 #define CONTENT_BROWSER_WEBUI_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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
15 #include "content/browser/webui/url_data_manager.h" | 15 #include "content/browser/webui/url_data_manager.h" |
16 #include "net/url_request/url_request_job_factory.h" | 16 #include "net/url_request/url_request_job_factory.h" |
17 | 17 |
18 class ChromeURLDataManagerBackend; | |
19 class GURL; | 18 class GURL; |
20 class URLRequestChromeJob; | |
21 | 19 |
22 namespace base { | 20 namespace base { |
23 class RefCountedMemory; | 21 class RefCountedMemory; |
24 } | 22 } |
25 | 23 |
26 namespace net { | 24 namespace content { |
27 class URLRequest; | 25 class URLDataManagerBackend; |
28 class URLRequestJob; | 26 class URLDataSourceImpl; |
29 } | 27 class URLRequestChromeJob; |
30 | 28 |
31 // ChromeURLDataManagerBackend is used internally by ChromeURLDataManager on the | 29 // URLDataManagerBackend is used internally by ChromeURLDataManager on the IO |
32 // IO thread. In most cases you can use the API in ChromeURLDataManager and | 30 // thread. In most cases you can use the API in ChromeURLDataManager and ignore |
33 // ignore this class. ChromeURLDataManagerBackend is owned by | 31 // this class. URLDataManagerBackend is owned by ResourceContext. |
34 // ChromeURLRequestContext. | 32 class URLDataManagerBackend : public base::SupportsUserData::Data { |
35 class ChromeURLDataManagerBackend : public base::SupportsUserData::Data { | |
36 public: | 33 public: |
37 typedef int RequestID; | 34 typedef int RequestID; |
38 | 35 |
39 ChromeURLDataManagerBackend(); | 36 URLDataManagerBackend(); |
40 virtual ~ChromeURLDataManagerBackend(); | 37 virtual ~URLDataManagerBackend(); |
41 | 38 |
42 // Invoked to create the protocol handler for chrome://. |is_incognito| should | 39 // Invoked to create the protocol handler for chrome://. |is_incognito| should |
43 // be set for incognito profiles. | 40 // be set for incognito profiles. |
44 static net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler( | 41 static net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler( |
45 ChromeURLDataManagerBackend* backend, | 42 URLDataManagerBackend* backend, |
46 bool is_incognito); | 43 bool is_incognito); |
47 | 44 |
48 // Adds a DataSource to the collection of data sources. | 45 // Adds a DataSource to the collection of data sources. |
49 void AddDataSource(URLDataSourceImpl* source); | 46 void AddDataSource(URLDataSourceImpl* source); |
50 | 47 |
51 // DataSource invokes this. Sends the data to the URLRequest. | 48 // DataSource invokes this. Sends the data to the URLRequest. |
52 void DataAvailable(RequestID request_id, base::RefCountedMemory* bytes); | 49 void DataAvailable(RequestID request_id, base::RefCountedMemory* bytes); |
53 | 50 |
54 static net::URLRequestJob* Factory(net::URLRequest* request, | 51 static net::URLRequestJob* Factory(net::URLRequest* request, |
55 const std::string& scheme); | 52 const std::string& scheme); |
(...skipping 29 matching lines...) Expand all Loading... |
85 DataSourceMap data_sources_; | 82 DataSourceMap data_sources_; |
86 | 83 |
87 // All pending URLRequestChromeJobs, keyed by ID of the request. | 84 // All pending URLRequestChromeJobs, keyed by ID of the request. |
88 // URLRequestChromeJob calls into this object when it's constructed and | 85 // URLRequestChromeJob calls into this object when it's constructed and |
89 // destructed to ensure that the pointers in this map remain valid. | 86 // destructed to ensure that the pointers in this map remain valid. |
90 PendingRequestMap pending_requests_; | 87 PendingRequestMap pending_requests_; |
91 | 88 |
92 // The ID we'll use for the next request we receive. | 89 // The ID we'll use for the next request we receive. |
93 RequestID next_request_id_; | 90 RequestID next_request_id_; |
94 | 91 |
95 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManagerBackend); | 92 DISALLOW_COPY_AND_ASSIGN(URLDataManagerBackend); |
96 }; | 93 }; |
97 | 94 |
98 // Creates protocol handler for chrome-devtools://. |is_incognito| should be | 95 // Creates protocol handler for chrome-devtools://. |is_incognito| should be |
99 // set for incognito profiles. | 96 // set for incognito profiles. |
100 net::URLRequestJobFactory::ProtocolHandler* | 97 net::URLRequestJobFactory::ProtocolHandler* |
101 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend, | 98 CreateDevToolsProtocolHandler(URLDataManagerBackend* backend, |
102 bool is_incognito); | 99 bool is_incognito); |
103 | 100 |
| 101 } // namespace content |
| 102 |
104 #endif // CONTENT_BROWSER_WEBUI_URL_DATA_MANAGER_BACKEND_H_ | 103 #endif // CONTENT_BROWSER_WEBUI_URL_DATA_MANAGER_BACKEND_H_ |
OLD | NEW |