| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ | 5 #ifndef IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ |
| 6 #define IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ | 6 #define IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 static void InstallProtocolHandlers( | 84 static void InstallProtocolHandlers( |
| 85 net::URLRequestJobFactoryImpl* job_factory, | 85 net::URLRequestJobFactoryImpl* job_factory, |
| 86 ProtocolHandlerMap* protocol_handlers); | 86 ProtocolHandlerMap* protocol_handlers); |
| 87 | 87 |
| 88 // Initializes the ChromeBrowserStateIOData object and primes the | 88 // Initializes the ChromeBrowserStateIOData object and primes the |
| 89 // RequestContext generation. Must be called prior to any of the Get*() | 89 // RequestContext generation. Must be called prior to any of the Get*() |
| 90 // methods other than GetResouceContext or GetMetricsEnabledStateOnIOThread. | 90 // methods other than GetResouceContext or GetMetricsEnabledStateOnIOThread. |
| 91 void Init(ProtocolHandlerMap* protocol_handlers) const; | 91 void Init(ProtocolHandlerMap* protocol_handlers) const; |
| 92 | 92 |
| 93 net::URLRequestContext* GetMainRequestContext() const; | 93 net::URLRequestContext* GetMainRequestContext() const; |
| 94 net::URLRequestContext* GetIsolatedAppRequestContext( | |
| 95 net::URLRequestContext* main_context, | |
| 96 const base::FilePath& partition_path) const; | |
| 97 | 94 |
| 98 // These are useful when the Chrome layer is called from the content layer | 95 // These are useful when the Chrome layer is called from the content layer |
| 99 // with a content::ResourceContext, and they want access to Chrome data for | 96 // with a content::ResourceContext, and they want access to Chrome data for |
| 100 // that browser state. | 97 // that browser state. |
| 101 content_settings::CookieSettings* GetCookieSettings() const; | 98 content_settings::CookieSettings* GetCookieSettings() const; |
| 102 HostContentSettingsMap* GetHostContentSettingsMap() const; | 99 HostContentSettingsMap* GetHostContentSettingsMap() const; |
| 103 | 100 |
| 104 StringPrefMember* google_services_account_id() const { | 101 StringPrefMember* google_services_account_id() const { |
| 105 return &google_services_user_account_id_; | 102 return &google_services_user_account_id_; |
| 106 } | 103 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 129 bool GetMetricsEnabledStateOnIOThread() const; | 126 bool GetMetricsEnabledStateOnIOThread() const; |
| 130 | 127 |
| 131 bool IsDataReductionProxyEnabled() const; | 128 bool IsDataReductionProxyEnabled() const; |
| 132 | 129 |
| 133 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data() | 130 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data() |
| 134 const { | 131 const { |
| 135 return data_reduction_proxy_io_data_.get(); | 132 return data_reduction_proxy_io_data_.get(); |
| 136 } | 133 } |
| 137 | 134 |
| 138 protected: | 135 protected: |
| 139 // A URLRequestContext for apps that owns its cookie store and HTTP factory, | |
| 140 // to ensure they are deleted. | |
| 141 class AppRequestContext : public net::URLRequestContext { | |
| 142 public: | |
| 143 AppRequestContext(); | |
| 144 | |
| 145 void SetCookieStore(net::CookieStore* cookie_store); | |
| 146 void SetHttpTransactionFactory( | |
| 147 scoped_ptr<net::HttpTransactionFactory> http_factory); | |
| 148 void SetJobFactory(scoped_ptr<net::URLRequestJobFactory> job_factory); | |
| 149 | |
| 150 private: | |
| 151 ~AppRequestContext() override; | |
| 152 | |
| 153 scoped_refptr<net::CookieStore> cookie_store_; | |
| 154 scoped_ptr<net::HttpTransactionFactory> http_factory_; | |
| 155 scoped_ptr<net::URLRequestJobFactory> job_factory_; | |
| 156 }; | |
| 157 | |
| 158 // Created on the UI thread, read on the IO thread during | 136 // Created on the UI thread, read on the IO thread during |
| 159 // ChromeBrowserStateIOData lazy initialization. | 137 // ChromeBrowserStateIOData lazy initialization. |
| 160 struct ProfileParams { | 138 struct ProfileParams { |
| 161 ProfileParams(); | 139 ProfileParams(); |
| 162 ~ProfileParams(); | 140 ~ProfileParams(); |
| 163 | 141 |
| 164 base::FilePath path; | 142 base::FilePath path; |
| 165 IOSChromeIOThread* io_thread; | 143 IOSChromeIOThread* io_thread; |
| 166 scoped_refptr<content_settings::CookieSettings> cookie_settings; | 144 scoped_refptr<content_settings::CookieSettings> cookie_settings; |
| 167 scoped_refptr<HostContentSettingsMap> host_content_settings_map; | 145 scoped_refptr<HostContentSettingsMap> host_content_settings_map; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Virtual interface for subtypes to implement: | 220 // Virtual interface for subtypes to implement: |
| 243 // -------------------------------------------- | 221 // -------------------------------------------- |
| 244 | 222 |
| 245 // Does the actual initialization of the ChromeBrowserStateIOData subtype. | 223 // Does the actual initialization of the ChromeBrowserStateIOData subtype. |
| 246 // Subtypes should use the static helper functions above to implement this. | 224 // Subtypes should use the static helper functions above to implement this. |
| 247 virtual void InitializeInternal( | 225 virtual void InitializeInternal( |
| 248 scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate, | 226 scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate, |
| 249 ProfileParams* profile_params, | 227 ProfileParams* profile_params, |
| 250 ProtocolHandlerMap* protocol_handlers) const = 0; | 228 ProtocolHandlerMap* protocol_handlers) const = 0; |
| 251 | 229 |
| 252 // Does an on-demand initialization of a RequestContext for the given | |
| 253 // isolated app. | |
| 254 virtual net::URLRequestContext* InitializeAppRequestContext( | |
| 255 net::URLRequestContext* main_context) const = 0; | |
| 256 | |
| 257 // These functions are used to transfer ownership of the lazily initialized | |
| 258 // context from ChromeBrowserStateIOData to the URLRequestContextGetter. | |
| 259 virtual net::URLRequestContext* AcquireIsolatedAppRequestContext( | |
| 260 net::URLRequestContext* main_context) const = 0; | |
| 261 | |
| 262 // The order *DOES* matter for the majority of these member variables, so | 230 // The order *DOES* matter for the majority of these member variables, so |
| 263 // don't move them around unless you know what you're doing! | 231 // don't move them around unless you know what you're doing! |
| 264 // General rules: | 232 // General rules: |
| 265 // * ResourceContext references the URLRequestContexts, so | 233 // * ResourceContext references the URLRequestContexts, so |
| 266 // URLRequestContexts must outlive ResourceContext, hence ResourceContext | 234 // URLRequestContexts must outlive ResourceContext, hence ResourceContext |
| 267 // should be destroyed first. | 235 // should be destroyed first. |
| 268 // * URLRequestContexts reference a whole bunch of members, so | 236 // * URLRequestContexts reference a whole bunch of members, so |
| 269 // URLRequestContext needs to be destroyed before them. | 237 // URLRequestContext needs to be destroyed before them. |
| 270 // * Therefore, ResourceContext should be listed last, and then the | 238 // * Therefore, ResourceContext should be listed last, and then the |
| 271 // URLRequestContexts, and then the URLRequestContext members. | 239 // URLRequestContexts, and then the URLRequestContext members. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 300 mutable scoped_ptr<net::TransportSecurityState> transport_security_state_; | 268 mutable scoped_ptr<net::TransportSecurityState> transport_security_state_; |
| 301 mutable scoped_ptr<net::CTVerifier> cert_transparency_verifier_; | 269 mutable scoped_ptr<net::CTVerifier> cert_transparency_verifier_; |
| 302 mutable scoped_ptr<net::HttpServerProperties> http_server_properties_; | 270 mutable scoped_ptr<net::HttpServerProperties> http_server_properties_; |
| 303 mutable scoped_ptr<net::TransportSecurityPersister> | 271 mutable scoped_ptr<net::TransportSecurityPersister> |
| 304 transport_security_persister_; | 272 transport_security_persister_; |
| 305 mutable scoped_ptr<net::CertificateReportSender> certificate_report_sender_; | 273 mutable scoped_ptr<net::CertificateReportSender> certificate_report_sender_; |
| 306 | 274 |
| 307 // These are only valid in between LazyInitialize() and their accessor being | 275 // These are only valid in between LazyInitialize() and their accessor being |
| 308 // called. | 276 // called. |
| 309 mutable scoped_ptr<net::URLRequestContext> main_request_context_; | 277 mutable scoped_ptr<net::URLRequestContext> main_request_context_; |
| 310 // One URLRequestContext per isolated app for main and media requests. | |
| 311 mutable URLRequestContextMap app_request_context_map_; | |
| 312 | 278 |
| 313 mutable scoped_refptr<content_settings::CookieSettings> cookie_settings_; | 279 mutable scoped_refptr<content_settings::CookieSettings> cookie_settings_; |
| 314 | 280 |
| 315 mutable scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 281 mutable scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 316 | 282 |
| 317 mutable scoped_ptr<IOSChromeHttpUserAgentSettings> | 283 mutable scoped_ptr<IOSChromeHttpUserAgentSettings> |
| 318 chrome_http_user_agent_settings_; | 284 chrome_http_user_agent_settings_; |
| 319 | 285 |
| 320 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 286 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
| 321 bool initialized_on_UI_thread_; | 287 bool initialized_on_UI_thread_; |
| 322 | 288 |
| 323 const ios::ChromeBrowserStateType browser_state_type_; | 289 const ios::ChromeBrowserStateType browser_state_type_; |
| 324 | 290 |
| 325 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserStateIOData); | 291 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserStateIOData); |
| 326 }; | 292 }; |
| 327 | 293 |
| 328 #endif // IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ | 294 #endif // IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ |
| OLD | NEW |