| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 // Subclass of net::URLRequestContext which can be used to store extra | 41 // Subclass of net::URLRequestContext which can be used to store extra |
| 42 // information for requests. | 42 // information for requests. |
| 43 // | 43 // |
| 44 // All methods of this class must be called from the IO thread, | 44 // All methods of this class must be called from the IO thread, |
| 45 // including the constructor and destructor. | 45 // including the constructor and destructor. |
| 46 class ChromeURLRequestContext : public net::URLRequestContext { | 46 class ChromeURLRequestContext : public net::URLRequestContext { |
| 47 public: | 47 public: |
| 48 ChromeURLRequestContext(); | 48 ChromeURLRequestContext(); |
| 49 | 49 |
| 50 // Copies the state from |other| into this context. |
| 51 void CopyFrom(ChromeURLRequestContext* other); |
| 52 |
| 50 // Gets the path to the directory user scripts are stored in. | 53 // Gets the path to the directory user scripts are stored in. |
| 51 FilePath user_script_dir_path() const { | 54 FilePath user_script_dir_path() const { |
| 52 return user_script_dir_path_; | 55 return user_script_dir_path_; |
| 53 } | 56 } |
| 54 | 57 |
| 55 // Gets the appcache service to be used for requests in this context. | 58 // Gets the appcache service to be used for requests in this context. |
| 56 // May be NULL if requests for this context aren't subject to appcaching. | 59 // May be NULL if requests for this context aren't subject to appcaching. |
| 57 ChromeAppCacheService* appcache_service() const { | 60 ChromeAppCacheService* appcache_service() const { |
| 58 return appcache_service_.get(); | 61 return appcache_service_.get(); |
| 59 } | 62 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Callback for when the accept language changes. | 136 // Callback for when the accept language changes. |
| 134 void OnAcceptLanguageChange(const std::string& accept_language); | 137 void OnAcceptLanguageChange(const std::string& accept_language); |
| 135 | 138 |
| 136 // Callback for when the default charset changes. | 139 // Callback for when the default charset changes. |
| 137 void OnDefaultCharsetChange(const std::string& default_charset); | 140 void OnDefaultCharsetChange(const std::string& default_charset); |
| 138 | 141 |
| 139 protected: | 142 protected: |
| 140 virtual ~ChromeURLRequestContext(); | 143 virtual ~ChromeURLRequestContext(); |
| 141 | 144 |
| 142 private: | 145 private: |
| 146 // --------------------------------------------------------------------------- |
| 147 // Important: When adding any new members below, consider whether they need to |
| 148 // be added to CopyFrom. |
| 149 // --------------------------------------------------------------------------- |
| 150 |
| 143 // Path to the directory user scripts are stored in. | 151 // Path to the directory user scripts are stored in. |
| 144 FilePath user_script_dir_path_; | 152 FilePath user_script_dir_path_; |
| 145 | 153 |
| 146 // TODO(willchan): Make these non-refcounted. | 154 // TODO(willchan): Make these non-refcounted. |
| 147 scoped_refptr<ChromeAppCacheService> appcache_service_; | 155 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 148 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 156 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
| 149 scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_; | 157 scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_; |
| 150 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 158 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 151 scoped_refptr<HostZoomMap> host_zoom_map_; | 159 scoped_refptr<HostZoomMap> host_zoom_map_; |
| 152 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; | 160 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
| 153 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 161 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
| 154 // TODO(aa): This should use chrome/common/extensions/extension_set.h. | 162 // TODO(aa): This should use chrome/common/extensions/extension_set.h. |
| 155 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 163 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 156 scoped_refptr<prerender::PrerenderManager> prerender_manager_; | 164 scoped_refptr<prerender::PrerenderManager> prerender_manager_; |
| 157 scoped_ptr<ChromeURLDataManagerBackend> chrome_url_data_manager_backend_; | 165 scoped_ptr<ChromeURLDataManagerBackend> chrome_url_data_manager_backend_; |
| 158 | 166 |
| 159 bool is_incognito_; | 167 bool is_incognito_; |
| 160 | 168 |
| 169 // --------------------------------------------------------------------------- |
| 170 // Important: When adding any new members above, consider whether they need to |
| 171 // be added to CopyFrom. |
| 172 // --------------------------------------------------------------------------- |
| 173 |
| 161 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); | 174 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); |
| 162 }; | 175 }; |
| 163 | 176 |
| 164 // A URLRequestContextGetter subclass used by the browser. This returns a | 177 // A URLRequestContextGetter subclass used by the browser. This returns a |
| 165 // subclass of net::URLRequestContext which can be used to store extra | 178 // subclass of net::URLRequestContext which can be used to store extra |
| 166 // information about requests. | 179 // information about requests. |
| 167 // | 180 // |
| 168 // Most methods are expected to be called on the UI thread, except for | 181 // Most methods are expected to be called on the UI thread, except for |
| 169 // the destructor and GetURLRequestContext(). | 182 // the destructor and GetURLRequestContext(). |
| 170 class ChromeURLRequestContextGetter : public URLRequestContextGetter, | 183 class ChromeURLRequestContextGetter : public URLRequestContextGetter, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // get called on UI thread. This method takes a profile and reuses the | 219 // get called on UI thread. This method takes a profile and reuses the |
| 207 // 'original' net::URLRequestContext for common files. | 220 // 'original' net::URLRequestContext for common files. |
| 208 static ChromeURLRequestContextGetter* CreateOriginalForMedia( | 221 static ChromeURLRequestContextGetter* CreateOriginalForMedia( |
| 209 Profile* profile, const ProfileIOData* profile_io_data); | 222 Profile* profile, const ProfileIOData* profile_io_data); |
| 210 | 223 |
| 211 // Create an instance for an original profile for extensions. This is expected | 224 // Create an instance for an original profile for extensions. This is expected |
| 212 // to get called on UI thread. | 225 // to get called on UI thread. |
| 213 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( | 226 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( |
| 214 Profile* profile, const ProfileIOData* profile_io_data); | 227 Profile* profile, const ProfileIOData* profile_io_data); |
| 215 | 228 |
| 229 // Create an instance for an original profile for an app with isolated |
| 230 // storage. This is expected to get called on UI thread. |
| 231 static ChromeURLRequestContextGetter* CreateOriginalForIsolatedApp( |
| 232 Profile* profile, |
| 233 const ProfileIOData* profile_io_data, |
| 234 const std::string& app_id); |
| 235 |
| 216 // Create an instance for use with an OTR profile. This is expected to get | 236 // Create an instance for use with an OTR profile. This is expected to get |
| 217 // called on the UI thread. | 237 // called on the UI thread. |
| 218 static ChromeURLRequestContextGetter* CreateOffTheRecord( | 238 static ChromeURLRequestContextGetter* CreateOffTheRecord( |
| 219 Profile* profile, const ProfileIOData* profile_io_data); | 239 Profile* profile, const ProfileIOData* profile_io_data); |
| 220 | 240 |
| 221 // Create an instance for an OTR profile for extensions. This is expected | 241 // Create an instance for an OTR profile for extensions. This is expected |
| 222 // to get called on UI thread. | 242 // to get called on UI thread. |
| 223 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( | 243 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( |
| 224 Profile* profile, const ProfileIOData* profile_io_data); | 244 Profile* profile, const ProfileIOData* profile_io_data); |
| 225 | 245 |
| 246 // Create an instance for an OTR profile for an app with isolated storage. |
| 247 // This is expected to get called on UI thread. |
| 248 static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp( |
| 249 Profile* profile, |
| 250 const ProfileIOData* profile_io_data, |
| 251 const std::string& app_id); |
| 252 |
| 226 // Clean up UI thread resources. This is expected to get called on the UI | 253 // Clean up UI thread resources. This is expected to get called on the UI |
| 227 // thread before the instance is deleted on the IO thread. | 254 // thread before the instance is deleted on the IO thread. |
| 228 void CleanupOnUIThread(); | 255 void CleanupOnUIThread(); |
| 229 | 256 |
| 230 // NotificationObserver implementation. | 257 // NotificationObserver implementation. |
| 231 virtual void Observe(NotificationType type, | 258 virtual void Observe(NotificationType type, |
| 232 const NotificationSource& source, | 259 const NotificationSource& source, |
| 233 const NotificationDetails& details); | 260 const NotificationDetails& details); |
| 234 | 261 |
| 235 private: | 262 private: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 262 | 289 |
| 263 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext | 290 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext |
| 264 // instance that was lazilly created by GetURLRequestContext. | 291 // instance that was lazilly created by GetURLRequestContext. |
| 265 // Access only from the IO thread. | 292 // Access only from the IO thread. |
| 266 scoped_refptr<net::URLRequestContext> url_request_context_; | 293 scoped_refptr<net::URLRequestContext> url_request_context_; |
| 267 | 294 |
| 268 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); | 295 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); |
| 269 }; | 296 }; |
| 270 | 297 |
| 271 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 298 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |