| 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_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 6 #define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 // Convenience overload of GetURLRequestContext() that returns a | 90 // Convenience overload of GetURLRequestContext() that returns a |
| 91 // ChromeURLRequestContext* rather than a net::URLRequestContext*. | 91 // ChromeURLRequestContext* rather than a net::URLRequestContext*. |
| 92 ChromeURLRequestContext* GetIOContext() { | 92 ChromeURLRequestContext* GetIOContext() { |
| 93 return reinterpret_cast<ChromeURLRequestContext*>(GetURLRequestContext()); | 93 return reinterpret_cast<ChromeURLRequestContext*>(GetURLRequestContext()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Create an instance for use with an 'original' (non-OTR) profile. This is | 96 // Create an instance for use with an 'original' (non-OTR) profile. This is |
| 97 // expected to get called on the UI thread. | 97 // expected to get called on the UI thread. |
| 98 static ChromeURLRequestContextGetter* CreateOriginal( | 98 static ChromeURLRequestContextGetter* CreateOriginal( |
| 99 Profile* profile, const ProfileIOData* profile_io_data); | 99 Profile* profile, |
| 100 const ProfileIOData* profile_io_data, |
| 101 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 102 blob_protocol_handler, |
| 103 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 104 file_system_protocol_handler, |
| 105 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 106 developer_protocol_handler, |
| 107 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 108 chrome_protocol_handler, |
| 109 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 110 chrome_devtools_protocol_handler); |
| 100 | 111 |
| 101 // Create an instance for an original profile for media. This is expected to | 112 // Create an instance for an original profile for media. This is expected to |
| 102 // get called on UI thread. This method takes a profile and reuses the | 113 // get called on UI thread. This method takes a profile and reuses the |
| 103 // 'original' net::URLRequestContext for common files. | 114 // 'original' net::URLRequestContext for common files. |
| 104 static ChromeURLRequestContextGetter* CreateOriginalForMedia( | 115 static ChromeURLRequestContextGetter* CreateOriginalForMedia( |
| 105 Profile* profile, const ProfileIOData* profile_io_data); | 116 Profile* profile, const ProfileIOData* profile_io_data); |
| 106 | 117 |
| 107 // Create an instance for an original profile for extensions. This is expected | 118 // Create an instance for an original profile for extensions. This is expected |
| 108 // to get called on UI thread. | 119 // to get called on UI thread. |
| 109 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( | 120 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( |
| 110 Profile* profile, const ProfileIOData* profile_io_data); | 121 Profile* profile, const ProfileIOData* profile_io_data); |
| 111 | 122 |
| 112 // Create an instance for an original profile for an app with isolated | 123 // Create an instance for an original profile for an app with isolated |
| 113 // storage. This is expected to get called on UI thread. | 124 // storage. This is expected to get called on UI thread. |
| 114 static ChromeURLRequestContextGetter* CreateOriginalForIsolatedApp( | 125 static ChromeURLRequestContextGetter* CreateOriginalForIsolatedApp( |
| 115 Profile* profile, | 126 Profile* profile, |
| 116 const ProfileIOData* profile_io_data, | 127 const ProfileIOData* profile_io_data, |
| 117 const StoragePartitionDescriptor& partition_descriptor, | 128 const StoragePartitionDescriptor& partition_descriptor, |
| 118 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 129 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 119 protocol_handler_interceptor); | 130 protocol_handler_interceptor, |
| 131 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 132 blob_protocol_handler, |
| 133 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 134 file_system_protocol_handler, |
| 135 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 136 developer_protocol_handler, |
| 137 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 138 chrome_protocol_handler, |
| 139 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 140 chrome_devtools_protocol_handler); |
| 120 | 141 |
| 121 // Create an instance for an original profile for media with isolated | 142 // Create an instance for an original profile for media with isolated |
| 122 // storage. This is expected to get called on UI thread. | 143 // storage. This is expected to get called on UI thread. |
| 123 static ChromeURLRequestContextGetter* CreateOriginalForIsolatedMedia( | 144 static ChromeURLRequestContextGetter* CreateOriginalForIsolatedMedia( |
| 124 Profile* profile, | 145 Profile* profile, |
| 125 ChromeURLRequestContextGetter* app_context, | 146 ChromeURLRequestContextGetter* app_context, |
| 126 const ProfileIOData* profile_io_data, | 147 const ProfileIOData* profile_io_data, |
| 127 const StoragePartitionDescriptor& partition_descriptor); | 148 const StoragePartitionDescriptor& partition_descriptor); |
| 128 | 149 |
| 129 // Create an instance for use with an OTR profile. This is expected to get | 150 // Create an instance for use with an OTR profile. This is expected to get |
| 130 // called on the UI thread. | 151 // called on the UI thread. |
| 131 static ChromeURLRequestContextGetter* CreateOffTheRecord( | 152 static ChromeURLRequestContextGetter* CreateOffTheRecord( |
| 132 Profile* profile, const ProfileIOData* profile_io_data); | 153 Profile* profile, |
| 154 const ProfileIOData* profile_io_data, |
| 155 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 156 blob_protocol_handler, |
| 157 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 158 file_system_protocol_handler, |
| 159 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 160 developer_protocol_handler, |
| 161 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 162 chrome_protocol_handler, |
| 163 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 164 chrome_devtools_protocol_handler); |
| 133 | 165 |
| 134 // Create an instance for an OTR profile for extensions. This is expected | 166 // Create an instance for an OTR profile for extensions. This is expected |
| 135 // to get called on UI thread. | 167 // to get called on UI thread. |
| 136 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( | 168 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( |
| 137 Profile* profile, const ProfileIOData* profile_io_data); | 169 Profile* profile, const ProfileIOData* profile_io_data); |
| 138 | 170 |
| 139 // Create an instance for an OTR profile for an app with isolated storage. | 171 // Create an instance for an OTR profile for an app with isolated storage. |
| 140 // This is expected to get called on UI thread. | 172 // This is expected to get called on UI thread. |
| 141 static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp( | 173 static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp( |
| 142 Profile* profile, | 174 Profile* profile, |
| 143 const ProfileIOData* profile_io_data, | 175 const ProfileIOData* profile_io_data, |
| 144 const StoragePartitionDescriptor& partition_descriptor, | 176 const StoragePartitionDescriptor& partition_descriptor, |
| 145 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 177 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 146 protocol_handler_interceptor); | 178 protocol_handler_interceptor, |
| 179 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 180 blob_protocol_handler, |
| 181 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 182 file_system_protocol_handler, |
| 183 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 184 developer_protocol_handler, |
| 185 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 186 chrome_protocol_handler, |
| 187 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 188 chrome_devtools_protocol_handler); |
| 147 | 189 |
| 148 private: | 190 private: |
| 149 virtual ~ChromeURLRequestContextGetter(); | 191 virtual ~ChromeURLRequestContextGetter(); |
| 150 | 192 |
| 151 // Deferred logic for creating a ChromeURLRequestContext. | 193 // Deferred logic for creating a ChromeURLRequestContext. |
| 152 // Access only from the IO thread. | 194 // Access only from the IO thread. |
| 153 scoped_ptr<ChromeURLRequestContextFactory> factory_; | 195 scoped_ptr<ChromeURLRequestContextFactory> factory_; |
| 154 | 196 |
| 155 // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext | 197 // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext |
| 156 // instance that was lazily created by GetURLRequestContext(). | 198 // instance that was lazily created by GetURLRequestContext(). |
| 157 // Access only from the IO thread. | 199 // Access only from the IO thread. |
| 158 base::WeakPtr<ChromeURLRequestContext> url_request_context_; | 200 base::WeakPtr<ChromeURLRequestContext> url_request_context_; |
| 159 | 201 |
| 160 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); | 202 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); |
| 161 }; | 203 }; |
| 162 | 204 |
| 163 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 205 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |