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