| 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 #include "chrome/browser/profiles/profile_impl_io_data.h" | 5 #include "chrome/browser/profiles/profile_impl_io_data.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/resource_context.h" | 34 #include "content/public/browser/resource_context.h" |
| 35 #include "content/public/browser/storage_partition.h" | 35 #include "content/public/browser/storage_partition.h" |
| 36 #include "extensions/common/constants.h" | 36 #include "extensions/common/constants.h" |
| 37 #include "net/base/server_bound_cert_service.h" | 37 #include "net/base/server_bound_cert_service.h" |
| 38 #include "net/ftp/ftp_network_layer.h" | 38 #include "net/ftp/ftp_network_layer.h" |
| 39 #include "net/http/http_cache.h" | 39 #include "net/http/http_cache.h" |
| 40 #include "net/url_request/protocol_intercept_job_factory.h" |
| 40 #include "net/url_request/url_request_job_factory_impl.h" | 41 #include "net/url_request/url_request_job_factory_impl.h" |
| 41 #include "webkit/quota/special_storage_policy.h" | 42 #include "webkit/quota/special_storage_policy.h" |
| 42 | 43 |
| 43 using content::BrowserThread; | 44 using content::BrowserThread; |
| 44 | 45 |
| 45 ProfileImplIOData::Handle::Handle(Profile* profile) | 46 ProfileImplIOData::Handle::Handle(Profile* profile) |
| 46 : io_data_(new ProfileImplIOData), | 47 : io_data_(new ProfileImplIOData), |
| 47 profile_(profile), | 48 profile_(profile), |
| 48 initialized_(false) { | 49 initialized_(false) { |
| 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 const FilePath& cookie_path, | 69 const FilePath& cookie_path, |
| 69 const FilePath& server_bound_cert_path, | 70 const FilePath& server_bound_cert_path, |
| 70 const FilePath& cache_path, | 71 const FilePath& cache_path, |
| 71 int cache_max_size, | 72 int cache_max_size, |
| 72 const FilePath& media_cache_path, | 73 const FilePath& media_cache_path, |
| 73 int media_cache_max_size, | 74 int media_cache_max_size, |
| 74 const FilePath& extensions_cookie_path, | 75 const FilePath& extensions_cookie_path, |
| 75 const FilePath& profile_path, | 76 const FilePath& profile_path, |
| 76 const FilePath& infinite_cache_path, | 77 const FilePath& infinite_cache_path, |
| 77 chrome_browser_net::Predictor* predictor, | 78 chrome_browser_net::Predictor* predictor, |
| 78 PrefService* local_state, | |
| 79 IOThread* io_thread, | |
| 80 bool restore_old_session_cookies, | 79 bool restore_old_session_cookies, |
| 81 quota::SpecialStoragePolicy* special_storage_policy) { | 80 quota::SpecialStoragePolicy* special_storage_policy) { |
| 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 83 DCHECK(!io_data_->lazy_params_.get()); | 82 DCHECK(!io_data_->lazy_params_.get()); |
| 84 DCHECK(predictor); | 83 DCHECK(predictor); |
| 85 | 84 |
| 86 LazyParams* lazy_params = new LazyParams; | 85 LazyParams* lazy_params = new LazyParams; |
| 87 | 86 |
| 88 lazy_params->cookie_path = cookie_path; | 87 lazy_params->cookie_path = cookie_path; |
| 89 lazy_params->server_bound_cert_path = server_bound_cert_path; | 88 lazy_params->server_bound_cert_path = server_bound_cert_path; |
| 90 lazy_params->cache_path = cache_path; | 89 lazy_params->cache_path = cache_path; |
| 91 lazy_params->cache_max_size = cache_max_size; | 90 lazy_params->cache_max_size = cache_max_size; |
| 92 lazy_params->media_cache_path = media_cache_path; | 91 lazy_params->media_cache_path = media_cache_path; |
| 93 lazy_params->media_cache_max_size = media_cache_max_size; | 92 lazy_params->media_cache_max_size = media_cache_max_size; |
| 94 lazy_params->extensions_cookie_path = extensions_cookie_path; | 93 lazy_params->extensions_cookie_path = extensions_cookie_path; |
| 95 lazy_params->infinite_cache_path = infinite_cache_path; | 94 lazy_params->infinite_cache_path = infinite_cache_path; |
| 96 lazy_params->restore_old_session_cookies = restore_old_session_cookies; | 95 lazy_params->restore_old_session_cookies = restore_old_session_cookies; |
| 97 lazy_params->special_storage_policy = special_storage_policy; | 96 lazy_params->special_storage_policy = special_storage_policy; |
| 98 | 97 |
| 99 io_data_->lazy_params_.reset(lazy_params); | 98 io_data_->lazy_params_.reset(lazy_params); |
| 100 | 99 |
| 101 // Keep track of profile path and cache sizes separately so we can use them | 100 // Keep track of profile path and cache sizes separately so we can use them |
| 102 // on demand when creating storage isolated URLRequestContextGetters. | 101 // on demand when creating storage isolated URLRequestContextGetters. |
| 103 io_data_->profile_path_ = profile_path; | 102 io_data_->profile_path_ = profile_path; |
| 104 io_data_->app_cache_max_size_ = cache_max_size; | 103 io_data_->app_cache_max_size_ = cache_max_size; |
| 105 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 104 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
| 106 | 105 |
| 107 io_data_->predictor_.reset(predictor); | 106 io_data_->predictor_.reset(predictor); |
| 108 | 107 |
| 109 if (!main_request_context_getter_) { | |
| 110 main_request_context_getter_ = | |
| 111 ChromeURLRequestContextGetter::CreateOriginal( | |
| 112 profile_, io_data_); | |
| 113 } | |
| 114 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), | |
| 115 local_state, | |
| 116 io_thread, | |
| 117 main_request_context_getter_); | |
| 118 | |
| 119 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 108 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
| 120 } | 109 } |
| 121 | 110 |
| 122 content::ResourceContext* | 111 content::ResourceContext* |
| 123 ProfileImplIOData::Handle::GetResourceContext() const { | 112 ProfileImplIOData::Handle::GetResourceContext() const { |
| 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 125 LazyInitialize(); | 114 LazyInitialize(); |
| 126 return GetResourceContextNoInit(); | 115 return GetResourceContextNoInit(); |
| 127 } | 116 } |
| 128 | 117 |
| 129 content::ResourceContext* | 118 content::ResourceContext* |
| 130 ProfileImplIOData::Handle::GetResourceContextNoInit() const { | 119 ProfileImplIOData::Handle::GetResourceContextNoInit() const { |
| 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 132 // Don't call LazyInitialize here, since the resource context is created at | 121 // Don't call LazyInitialize here, since the resource context is created at |
| 133 // the beginning of initalization and is used by some members while they're | 122 // the beginning of initalization and is used by some members while they're |
| 134 // being initialized (i.e. AppCacheService). | 123 // being initialized (i.e. AppCacheService). |
| 135 return io_data_->GetResourceContext(); | 124 return io_data_->GetResourceContext(); |
| 136 } | 125 } |
| 137 | 126 |
| 138 scoped_refptr<ChromeURLRequestContextGetter> | 127 scoped_refptr<ChromeURLRequestContextGetter> |
| 139 ProfileImplIOData::Handle::GetMainRequestContextGetter() const { | 128 ProfileImplIOData::Handle::CreateMainRequestContextGetter( |
| 129 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 130 blob_protocol_handler, |
| 131 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 132 file_system_protocol_handler, |
| 133 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 134 developer_protocol_handler, |
| 135 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 136 chrome_protocol_handler, |
| 137 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 138 chrome_devtools_protocol_handler, |
| 139 PrefService* local_state, |
| 140 IOThread* io_thread) const { |
| 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 141 LazyInitialize(); | 142 LazyInitialize(); |
| 142 if (!main_request_context_getter_) { | 143 DCHECK(!main_request_context_getter_); |
| 143 main_request_context_getter_ = | 144 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal( |
| 144 ChromeURLRequestContextGetter::CreateOriginal( | 145 profile_, io_data_, blob_protocol_handler.Pass(), |
| 145 profile_, io_data_); | 146 file_system_protocol_handler.Pass(), developer_protocol_handler.Pass(), |
| 147 chrome_protocol_handler.Pass(), chrome_devtools_protocol_handler.Pass()); |
| 146 | 148 |
| 147 content::NotificationService::current()->Notify( | 149 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), |
| 148 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | 150 local_state, |
| 149 content::Source<Profile>(profile_), | 151 io_thread, |
| 150 content::NotificationService::NoDetails()); | 152 main_request_context_getter_); |
| 151 } | 153 |
| 154 content::NotificationService::current()->Notify( |
| 155 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
| 156 content::Source<Profile>(profile_), |
| 157 content::NotificationService::NoDetails()); |
| 152 return main_request_context_getter_; | 158 return main_request_context_getter_; |
| 153 } | 159 } |
| 154 | 160 |
| 155 scoped_refptr<ChromeURLRequestContextGetter> | 161 scoped_refptr<ChromeURLRequestContextGetter> |
| 156 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { | 162 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { |
| 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 158 LazyInitialize(); | 164 LazyInitialize(); |
| 159 if (!media_request_context_getter_) { | 165 if (!media_request_context_getter_) { |
| 160 media_request_context_getter_ = | 166 media_request_context_getter_ = |
| 161 ChromeURLRequestContextGetter::CreateOriginalForMedia( | 167 ChromeURLRequestContextGetter::CreateOriginalForMedia( |
| 162 profile_, io_data_); | 168 profile_, io_data_); |
| 163 } | 169 } |
| 164 return media_request_context_getter_; | 170 return media_request_context_getter_; |
| 165 } | 171 } |
| 166 | 172 |
| 167 scoped_refptr<ChromeURLRequestContextGetter> | 173 scoped_refptr<ChromeURLRequestContextGetter> |
| 168 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { | 174 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { |
| 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 170 LazyInitialize(); | 176 LazyInitialize(); |
| 171 if (!extensions_request_context_getter_) { | 177 if (!extensions_request_context_getter_) { |
| 172 extensions_request_context_getter_ = | 178 extensions_request_context_getter_ = |
| 173 ChromeURLRequestContextGetter::CreateOriginalForExtensions( | 179 ChromeURLRequestContextGetter::CreateOriginalForExtensions( |
| 174 profile_, io_data_); | 180 profile_, io_data_); |
| 175 } | 181 } |
| 176 return extensions_request_context_getter_; | 182 return extensions_request_context_getter_; |
| 177 } | 183 } |
| 178 | 184 |
| 179 scoped_refptr<ChromeURLRequestContextGetter> | 185 scoped_refptr<ChromeURLRequestContextGetter> |
| 180 ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter( | 186 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( |
| 181 const FilePath& partition_path, | 187 const FilePath& partition_path, |
| 182 bool in_memory) const { | 188 bool in_memory, |
| 189 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 190 blob_protocol_handler, |
| 191 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 192 file_system_protocol_handler, |
| 193 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 194 developer_protocol_handler, |
| 195 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 196 chrome_protocol_handler, |
| 197 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 198 chrome_devtools_protocol_handler) const { |
| 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 184 // Check that the partition_path is not the same as the base profile path. We | 200 // Check that the partition_path is not the same as the base profile path. We |
| 185 // expect isolated partition, which will never go to the default profile path. | 201 // expect isolated partition, which will never go to the default profile path. |
| 186 CHECK(partition_path != profile_->GetPath()); | 202 CHECK(partition_path != profile_->GetPath()); |
| 187 LazyInitialize(); | 203 LazyInitialize(); |
| 188 | 204 |
| 189 // Keep a map of request context getters, one per requested storage partition. | 205 // Keep a map of request context getters, one per requested storage partition. |
| 190 StoragePartitionDescriptor descriptor(partition_path, in_memory); | 206 StoragePartitionDescriptor descriptor(partition_path, in_memory); |
| 191 ChromeURLRequestContextGetterMap::iterator iter = | 207 ChromeURLRequestContextGetterMap::iterator iter = |
| 192 app_request_context_getter_map_.find(descriptor); | 208 app_request_context_getter_map_.find(descriptor); |
| 193 if (iter != app_request_context_getter_map_.end()) | 209 if (iter != app_request_context_getter_map_.end()) |
| 194 return iter->second; | 210 return iter->second; |
| 195 | 211 |
| 196 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 212 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 197 protocol_handler_interceptor( | 213 protocol_handler_interceptor( |
| 198 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> | 214 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> |
| 199 CreateJobInterceptorFactory()); | 215 CreateJobInterceptorFactory()); |
| 200 ChromeURLRequestContextGetter* context = | 216 ChromeURLRequestContextGetter* context = |
| 201 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | 217 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
| 202 profile_, io_data_, descriptor, | 218 profile_, io_data_, descriptor, |
| 203 protocol_handler_interceptor.Pass()); | 219 protocol_handler_interceptor.Pass(), blob_protocol_handler.Pass(), |
| 220 file_system_protocol_handler.Pass(), |
| 221 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(), |
| 222 chrome_devtools_protocol_handler.Pass()); |
| 204 app_request_context_getter_map_[descriptor] = context; | 223 app_request_context_getter_map_[descriptor] = context; |
| 205 | 224 |
| 206 return context; | 225 return context; |
| 207 } | 226 } |
| 208 | 227 |
| 209 scoped_refptr<ChromeURLRequestContextGetter> | 228 scoped_refptr<ChromeURLRequestContextGetter> |
| 210 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( | 229 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( |
| 211 const FilePath& partition_path, | 230 const FilePath& partition_path, |
| 212 bool in_memory) const { | 231 bool in_memory) const { |
| 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 214 // We must have a non-default path, or this will act like the default media | 233 // We must have a non-default path, or this will act like the default media |
| 215 // context. | 234 // context. |
| 216 CHECK(partition_path != profile_->GetPath()); | 235 CHECK(partition_path != profile_->GetPath()); |
| 217 LazyInitialize(); | 236 LazyInitialize(); |
| 218 | 237 |
| 219 // Keep a map of request context getters, one per requested storage partition. | 238 // Keep a map of request context getters, one per requested storage partition. |
| 220 StoragePartitionDescriptor descriptor(partition_path, in_memory); | 239 StoragePartitionDescriptor descriptor(partition_path, in_memory); |
| 221 ChromeURLRequestContextGetterMap::iterator iter = | 240 ChromeURLRequestContextGetterMap::iterator iter = |
| 222 isolated_media_request_context_getter_map_.find(descriptor); | 241 isolated_media_request_context_getter_map_.find(descriptor); |
| 223 if (iter != isolated_media_request_context_getter_map_.end()) | 242 if (iter != isolated_media_request_context_getter_map_.end()) |
| 224 return iter->second; | 243 return iter->second; |
| 225 | 244 |
| 226 // Get the app context as the starting point for the media context, so that | 245 // Get the app context as the starting point for the media context, so that |
| 227 // it uses the app's cookie store. | 246 // it uses the app's cookie store. |
| 228 ChromeURLRequestContextGetter* app_context = | 247 ChromeURLRequestContextGetterMap::const_iterator app_iter = |
| 229 GetIsolatedAppRequestContextGetter(partition_path, in_memory); | 248 app_request_context_getter_map_.find(descriptor); |
| 249 DCHECK(app_iter != app_request_context_getter_map_.end()); |
| 250 ChromeURLRequestContextGetter* app_context = app_iter->second; |
| 230 ChromeURLRequestContextGetter* context = | 251 ChromeURLRequestContextGetter* context = |
| 231 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( | 252 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( |
| 232 profile_, app_context, io_data_, descriptor); | 253 profile_, app_context, io_data_, descriptor); |
| 233 isolated_media_request_context_getter_map_[descriptor] = context; | 254 isolated_media_request_context_getter_map_[descriptor] = context; |
| 234 | 255 |
| 235 return context; | 256 return context; |
| 236 } | 257 } |
| 237 | 258 |
| 238 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( | 259 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( |
| 239 base::Time time, | 260 base::Time time, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 ProfileImplIOData::ProfileImplIOData() | 306 ProfileImplIOData::ProfileImplIOData() |
| 286 : ProfileIOData(false), | 307 : ProfileIOData(false), |
| 287 http_server_properties_manager_(NULL) {} | 308 http_server_properties_manager_(NULL) {} |
| 288 ProfileImplIOData::~ProfileImplIOData() { | 309 ProfileImplIOData::~ProfileImplIOData() { |
| 289 DestroyResourceContext(); | 310 DestroyResourceContext(); |
| 290 | 311 |
| 291 if (media_request_context_.get()) | 312 if (media_request_context_.get()) |
| 292 media_request_context_->AssertNoURLRequests(); | 313 media_request_context_->AssertNoURLRequests(); |
| 293 } | 314 } |
| 294 | 315 |
| 295 void ProfileImplIOData::LazyInitializeInternal( | 316 void ProfileImplIOData::InitializeInternal( |
| 296 ProfileParams* profile_params) const { | 317 ProfileParams* profile_params, |
| 318 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 319 blob_protocol_handler, |
| 320 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 321 file_system_protocol_handler, |
| 322 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 323 developer_protocol_handler, |
| 324 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 325 chrome_protocol_handler, |
| 326 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 327 chrome_devtools_protocol_handler) const { |
| 297 ChromeURLRequestContext* main_context = main_request_context(); | 328 ChromeURLRequestContext* main_context = main_request_context(); |
| 298 | 329 |
| 299 IOThread* const io_thread = profile_params->io_thread; | 330 IOThread* const io_thread = profile_params->io_thread; |
| 300 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 331 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
| 301 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 332 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 302 // Only allow Record Mode if we are in a Debug build or where we are running | 333 // Only allow Record Mode if we are in a Debug build or where we are running |
| 303 // a cycle, and the user has limited control. | 334 // a cycle, and the user has limited control. |
| 304 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && | 335 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && |
| 305 (chrome::kRecordModeEnabled || | 336 (chrome::kRecordModeEnabled || |
| 306 command_line.HasSwitch(switches::kVisitURLs)); | 337 command_line.HasSwitch(switches::kVisitURLs)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 main_context->set_http_transaction_factory(main_cache); | 435 main_context->set_http_transaction_factory(main_cache); |
| 405 | 436 |
| 406 #if !defined(DISABLE_FTP_SUPPORT) | 437 #if !defined(DISABLE_FTP_SUPPORT) |
| 407 ftp_factory_.reset( | 438 ftp_factory_.reset( |
| 408 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 439 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 409 main_context->set_ftp_transaction_factory(ftp_factory_.get()); | 440 main_context->set_ftp_transaction_factory(ftp_factory_.get()); |
| 410 #endif // !defined(DISABLE_FTP_SUPPORT) | 441 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 411 | 442 |
| 412 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 443 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
| 413 new net::URLRequestJobFactoryImpl()); | 444 new net::URLRequestJobFactoryImpl()); |
| 445 bool set_protocol = main_job_factory->SetProtocolHandler( |
| 446 chrome::kBlobScheme, blob_protocol_handler.release()); |
| 447 DCHECK(set_protocol); |
| 448 set_protocol = main_job_factory->SetProtocolHandler( |
| 449 chrome::kFileSystemScheme, file_system_protocol_handler.release()); |
| 450 DCHECK(set_protocol); |
| 451 set_protocol = main_job_factory->SetProtocolHandler( |
| 452 chrome::kChromeUIScheme, chrome_protocol_handler.release()); |
| 453 DCHECK(set_protocol); |
| 454 set_protocol = main_job_factory->SetProtocolHandler( |
| 455 chrome::kChromeDevToolsScheme, |
| 456 chrome_devtools_protocol_handler.release()); |
| 457 DCHECK(set_protocol); |
| 414 main_job_factory_ = SetUpJobFactoryDefaults( | 458 main_job_factory_ = SetUpJobFactoryDefaults( |
| 415 main_job_factory.Pass(), | 459 main_job_factory.Pass(), |
| 416 profile_params->protocol_handler_interceptor.Pass(), | 460 profile_params->protocol_handler_interceptor.Pass(), |
| 417 network_delegate(), | 461 network_delegate(), |
| 418 main_context->ftp_transaction_factory(), | 462 main_context->ftp_transaction_factory(), |
| 419 main_context->ftp_auth_cache()); | 463 main_context->ftp_auth_cache()); |
| 464 main_job_factory_.reset(new net::ProtocolInterceptJobFactory( |
| 465 main_job_factory_.Pass(), developer_protocol_handler.Pass())); |
| 420 main_context->set_job_factory(main_job_factory_.get()); | 466 main_context->set_job_factory(main_job_factory_.get()); |
| 421 | 467 |
| 422 #if defined(ENABLE_EXTENSIONS) | 468 #if defined(ENABLE_EXTENSIONS) |
| 423 InitializeExtensionsRequestContext(profile_params); | 469 InitializeExtensionsRequestContext(profile_params); |
| 424 #endif | 470 #endif |
| 425 | 471 |
| 426 // Create a media request context based on the main context, but using a | 472 // Create a media request context based on the main context, but using a |
| 427 // media cache. It shares the same job factory as the main context. | 473 // media cache. It shares the same job factory as the main context. |
| 428 StoragePartitionDescriptor details(profile_path_, false); | 474 StoragePartitionDescriptor details(profile_path_, false); |
| 429 media_request_context_.reset(InitializeMediaRequestContext(main_context, | 475 media_request_context_.reset(InitializeMediaRequestContext(main_context, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 extensions_context->ftp_transaction_factory(), | 523 extensions_context->ftp_transaction_factory(), |
| 478 extensions_context->ftp_auth_cache()); | 524 extensions_context->ftp_auth_cache()); |
| 479 extensions_context->set_job_factory(extensions_job_factory_.get()); | 525 extensions_context->set_job_factory(extensions_job_factory_.get()); |
| 480 } | 526 } |
| 481 | 527 |
| 482 ChromeURLRequestContext* | 528 ChromeURLRequestContext* |
| 483 ProfileImplIOData::InitializeAppRequestContext( | 529 ProfileImplIOData::InitializeAppRequestContext( |
| 484 ChromeURLRequestContext* main_context, | 530 ChromeURLRequestContext* main_context, |
| 485 const StoragePartitionDescriptor& partition_descriptor, | 531 const StoragePartitionDescriptor& partition_descriptor, |
| 486 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 532 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 487 protocol_handler_interceptor) const { | 533 protocol_handler_interceptor, |
| 534 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 535 blob_protocol_handler, |
| 536 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 537 file_system_protocol_handler, |
| 538 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 539 developer_protocol_handler, |
| 540 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 541 chrome_protocol_handler, |
| 542 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 543 chrome_devtools_protocol_handler) const { |
| 488 // Copy most state from the main context. | 544 // Copy most state from the main context. |
| 489 AppRequestContext* context = new AppRequestContext(load_time_stats()); | 545 AppRequestContext* context = new AppRequestContext(load_time_stats()); |
| 490 context->CopyFrom(main_context); | 546 context->CopyFrom(main_context); |
| 491 | 547 |
| 492 FilePath cookie_path = partition_descriptor.path.Append( | 548 FilePath cookie_path = partition_descriptor.path.Append( |
| 493 chrome::kCookieFilename); | 549 chrome::kCookieFilename); |
| 494 FilePath cache_path = partition_descriptor.path.Append(chrome::kCacheDirname); | 550 FilePath cache_path = partition_descriptor.path.Append(chrome::kCacheDirname); |
| 495 | 551 |
| 496 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 552 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 497 // Only allow Record Mode if we are in a Debug build or where we are running | 553 // Only allow Record Mode if we are in a Debug build or where we are running |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); | 598 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); |
| 543 } | 599 } |
| 544 | 600 |
| 545 // Transfer ownership of the cookies and cache to AppRequestContext. | 601 // Transfer ownership of the cookies and cache to AppRequestContext. |
| 546 context->SetCookieStore(cookie_store); | 602 context->SetCookieStore(cookie_store); |
| 547 context->SetHttpTransactionFactory( | 603 context->SetHttpTransactionFactory( |
| 548 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 604 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); |
| 549 | 605 |
| 550 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 606 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
| 551 new net::URLRequestJobFactoryImpl()); | 607 new net::URLRequestJobFactoryImpl()); |
| 608 bool set_protocol = job_factory->SetProtocolHandler( |
| 609 chrome::kBlobScheme, blob_protocol_handler.release()); |
| 610 DCHECK(set_protocol); |
| 611 set_protocol = job_factory->SetProtocolHandler( |
| 612 chrome::kFileSystemScheme, file_system_protocol_handler.release()); |
| 613 DCHECK(set_protocol); |
| 614 set_protocol = job_factory->SetProtocolHandler( |
| 615 chrome::kChromeUIScheme, chrome_protocol_handler.release()); |
| 616 DCHECK(set_protocol); |
| 617 set_protocol = job_factory->SetProtocolHandler( |
| 618 chrome::kChromeDevToolsScheme, |
| 619 chrome_devtools_protocol_handler.release()); |
| 620 DCHECK(set_protocol); |
| 552 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 621 scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
| 553 // Overwrite the job factory that we inherit from the main context so | 622 // Overwrite the job factory that we inherit from the main context so |
| 554 // that we can later provide our own handlers for storage related protocols. | 623 // that we can later provide our own handlers for storage related protocols. |
| 555 // Install all the usual protocol handlers unless we are in a browser plugin | 624 // Install all the usual protocol handlers unless we are in a browser plugin |
| 556 // guest process, in which case only web-safe schemes are allowed. | 625 // guest process, in which case only web-safe schemes are allowed. |
| 557 if (!partition_descriptor.in_memory) { | 626 if (!partition_descriptor.in_memory) { |
| 558 top_job_factory = SetUpJobFactoryDefaults( | 627 top_job_factory = SetUpJobFactoryDefaults( |
| 559 job_factory.Pass(), protocol_handler_interceptor.Pass(), | 628 job_factory.Pass(), protocol_handler_interceptor.Pass(), |
| 560 network_delegate(), | 629 network_delegate(), |
| 561 context->ftp_transaction_factory(), | 630 context->ftp_transaction_factory(), |
| 562 context->ftp_auth_cache()); | 631 context->ftp_auth_cache()); |
| 563 } else { | 632 } else { |
| 564 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); | 633 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); |
| 565 } | 634 } |
| 635 top_job_factory.reset(new net::ProtocolInterceptJobFactory( |
| 636 top_job_factory.Pass(), developer_protocol_handler.Pass())); |
| 566 context->SetJobFactory(top_job_factory.Pass()); | 637 context->SetJobFactory(top_job_factory.Pass()); |
| 567 | 638 |
| 568 return context; | 639 return context; |
| 569 } | 640 } |
| 570 | 641 |
| 571 ChromeURLRequestContext* | 642 ChromeURLRequestContext* |
| 572 ProfileImplIOData::InitializeMediaRequestContext( | 643 ProfileImplIOData::InitializeMediaRequestContext( |
| 573 ChromeURLRequestContext* original_context, | 644 ChromeURLRequestContext* original_context, |
| 574 const StoragePartitionDescriptor& partition_descriptor) const { | 645 const StoragePartitionDescriptor& partition_descriptor) const { |
| 575 // If this is for a in_memory partition, we can simply use the original | 646 // If this is for a in_memory partition, we can simply use the original |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 ProfileImplIOData::AcquireMediaRequestContext() const { | 691 ProfileImplIOData::AcquireMediaRequestContext() const { |
| 621 DCHECK(media_request_context_.get()); | 692 DCHECK(media_request_context_.get()); |
| 622 return media_request_context_.get(); | 693 return media_request_context_.get(); |
| 623 } | 694 } |
| 624 | 695 |
| 625 ChromeURLRequestContext* | 696 ChromeURLRequestContext* |
| 626 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 697 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 627 ChromeURLRequestContext* main_context, | 698 ChromeURLRequestContext* main_context, |
| 628 const StoragePartitionDescriptor& partition_descriptor, | 699 const StoragePartitionDescriptor& partition_descriptor, |
| 629 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 700 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 630 protocol_handler_interceptor) const { | 701 protocol_handler_interceptor, |
| 702 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 703 blob_protocol_handler, |
| 704 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 705 file_system_protocol_handler, |
| 706 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 707 developer_protocol_handler, |
| 708 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 709 chrome_protocol_handler, |
| 710 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 711 chrome_devtools_protocol_handler) const { |
| 631 // We create per-app contexts on demand, unlike the others above. | 712 // We create per-app contexts on demand, unlike the others above. |
| 632 ChromeURLRequestContext* app_request_context = | 713 ChromeURLRequestContext* app_request_context = |
| 633 InitializeAppRequestContext(main_context, partition_descriptor, | 714 InitializeAppRequestContext(main_context, partition_descriptor, |
| 634 protocol_handler_interceptor.Pass()); | 715 protocol_handler_interceptor.Pass(), |
| 716 blob_protocol_handler.Pass(), |
| 717 file_system_protocol_handler.Pass(), |
| 718 developer_protocol_handler.Pass(), |
| 719 chrome_protocol_handler.Pass(), |
| 720 chrome_devtools_protocol_handler.Pass()); |
| 635 DCHECK(app_request_context); | 721 DCHECK(app_request_context); |
| 636 return app_request_context; | 722 return app_request_context; |
| 637 } | 723 } |
| 638 | 724 |
| 639 ChromeURLRequestContext* | 725 ChromeURLRequestContext* |
| 640 ProfileImplIOData::AcquireIsolatedMediaRequestContext( | 726 ProfileImplIOData::AcquireIsolatedMediaRequestContext( |
| 641 ChromeURLRequestContext* app_context, | 727 ChromeURLRequestContext* app_context, |
| 642 const StoragePartitionDescriptor& partition_descriptor) const { | 728 const StoragePartitionDescriptor& partition_descriptor) const { |
| 643 // We create per-app media contexts on demand, unlike the others above. | 729 // We create per-app media contexts on demand, unlike the others above. |
| 644 ChromeURLRequestContext* media_request_context = | 730 ChromeURLRequestContext* media_request_context = |
| 645 InitializeMediaRequestContext(app_context, partition_descriptor); | 731 InitializeMediaRequestContext(app_context, partition_descriptor); |
| 646 DCHECK(media_request_context); | 732 DCHECK(media_request_context); |
| 647 return media_request_context; | 733 return media_request_context; |
| 648 } | 734 } |
| 649 | 735 |
| 650 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( | 736 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( |
| 651 IOThread::Globals* io_thread_globals) const { | 737 IOThread::Globals* io_thread_globals) const { |
| 652 return io_thread_globals->load_time_stats.get(); | 738 return io_thread_globals->load_time_stats.get(); |
| 653 } | 739 } |
| 654 | 740 |
| 655 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 741 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
| 656 base::Time time, | 742 base::Time time, |
| 657 const base::Closure& completion) { | 743 const base::Closure& completion) { |
| 658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 744 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 659 LazyInitialize(); | 745 DCHECK(initialized()); |
| 660 | 746 |
| 661 DCHECK(transport_security_state()); | 747 DCHECK(transport_security_state()); |
| 662 transport_security_state()->DeleteSince(time); // Completes synchronously. | 748 transport_security_state()->DeleteSince(time); // Completes synchronously. |
| 663 DCHECK(http_server_properties_manager_); | 749 DCHECK(http_server_properties_manager_); |
| 664 http_server_properties_manager_->Clear(completion); | 750 http_server_properties_manager_->Clear(completion); |
| 665 } | 751 } |
| OLD | NEW |