| 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 main_cache->set_mode( | 404 main_cache->set_mode( |
| 405 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 405 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
| 406 } | 406 } |
| 407 | 407 |
| 408 main_http_factory_.reset(main_cache); | 408 main_http_factory_.reset(main_cache); |
| 409 main_context->set_http_transaction_factory(main_cache); | 409 main_context->set_http_transaction_factory(main_cache); |
| 410 | 410 |
| 411 #if !defined(DISABLE_FTP_SUPPORT) | 411 #if !defined(DISABLE_FTP_SUPPORT) |
| 412 ftp_factory_.reset( | 412 ftp_factory_.reset( |
| 413 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 413 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 414 main_context->set_ftp_transaction_factory(ftp_factory_.get()); |
| 414 #endif // !defined(DISABLE_FTP_SUPPORT) | 415 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 415 | 416 |
| 416 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 417 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
| 417 new net::URLRequestJobFactoryImpl()); | 418 new net::URLRequestJobFactoryImpl()); |
| 418 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); | 419 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); |
| 419 main_job_factory_ = SetUpJobFactoryDefaults( | 420 main_job_factory_ = SetUpJobFactoryDefaults( |
| 420 main_job_factory.Pass(), | 421 main_job_factory.Pass(), |
| 421 profile_params->protocol_handler_interceptor.Pass(), | 422 profile_params->protocol_handler_interceptor.Pass(), |
| 422 network_delegate(), | 423 network_delegate(), |
| 423 ftp_factory_.get()); | 424 main_context->ftp_transaction_factory(), |
| 425 main_context->ftp_auth_cache()); |
| 424 main_context->set_job_factory(main_job_factory_.get()); | 426 main_context->set_job_factory(main_job_factory_.get()); |
| 425 | 427 |
| 426 #if defined(ENABLE_EXTENSIONS) | 428 #if defined(ENABLE_EXTENSIONS) |
| 427 InitializeExtensionsRequestContext(profile_params); | 429 InitializeExtensionsRequestContext(profile_params); |
| 428 #endif | 430 #endif |
| 429 | 431 |
| 430 // Create a media request context based on the main context, but using a | 432 // Create a media request context based on the main context, but using a |
| 431 // media cache. It shares the same job factory as the main context. | 433 // media cache. It shares the same job factory as the main context. |
| 432 StoragePartitionDescriptor details(profile_path_, false); | 434 StoragePartitionDescriptor details(profile_path_, false); |
| 433 media_request_context_.reset(InitializeMediaRequestContext(main_context, | 435 media_request_context_.reset(InitializeMediaRequestContext(main_context, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 457 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 459 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| 458 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 460 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 459 BrowserThread::GetBlockingPool()->GetSequenceToken()), | 461 BrowserThread::GetBlockingPool()->GetSequenceToken()), |
| 460 lazy_params_->restore_old_session_cookies, NULL), NULL); | 462 lazy_params_->restore_old_session_cookies, NULL), NULL); |
| 461 // Enable cookies for devtools and extension URLs. | 463 // Enable cookies for devtools and extension URLs. |
| 462 const char* schemes[] = {chrome::kChromeDevToolsScheme, | 464 const char* schemes[] = {chrome::kChromeDevToolsScheme, |
| 463 extensions::kExtensionScheme}; | 465 extensions::kExtensionScheme}; |
| 464 extensions_cookie_store->SetCookieableSchemes(schemes, 2); | 466 extensions_cookie_store->SetCookieableSchemes(schemes, 2); |
| 465 extensions_context->set_cookie_store(extensions_cookie_store); | 467 extensions_context->set_cookie_store(extensions_cookie_store); |
| 466 | 468 |
| 469 #if !defined(DISABLE_FTP_SUPPORT) |
| 470 DCHECK(ftp_factory_.get()); |
| 471 extensions_context->set_ftp_transaction_factory(ftp_factory_.get()); |
| 472 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 473 |
| 467 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 474 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |
| 468 new net::URLRequestJobFactoryImpl()); | 475 new net::URLRequestJobFactoryImpl()); |
| 469 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 476 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |
| 470 // Without a network_delegate, this protocol handler will never | 477 // Without a network_delegate, this protocol handler will never |
| 471 // handle file: requests, but as a side effect it makes | 478 // handle file: requests, but as a side effect it makes |
| 472 // job_factory::IsHandledProtocol return true, which prevents attempts to | 479 // job_factory::IsHandledProtocol return true, which prevents attempts to |
| 473 // handle the protocol externally. We pass NULL in to | 480 // handle the protocol externally. We pass NULL in to |
| 474 // SetUpJobFactory() to get this effect. | 481 // SetUpJobFactory() to get this effect. |
| 475 extensions_job_factory_ = SetUpJobFactoryDefaults( | 482 extensions_job_factory_ = SetUpJobFactoryDefaults( |
| 476 extensions_job_factory.Pass(), | 483 extensions_job_factory.Pass(), |
| 477 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), | 484 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), |
| 478 NULL, | 485 NULL, |
| 479 ftp_factory_.get()); | 486 extensions_context->ftp_transaction_factory(), |
| 487 extensions_context->ftp_auth_cache()); |
| 480 extensions_context->set_job_factory(extensions_job_factory_.get()); | 488 extensions_context->set_job_factory(extensions_job_factory_.get()); |
| 481 } | 489 } |
| 482 | 490 |
| 483 ChromeURLRequestContext* | 491 ChromeURLRequestContext* |
| 484 ProfileImplIOData::InitializeAppRequestContext( | 492 ProfileImplIOData::InitializeAppRequestContext( |
| 485 ChromeURLRequestContext* main_context, | 493 ChromeURLRequestContext* main_context, |
| 486 const StoragePartitionDescriptor& partition_descriptor, | 494 const StoragePartitionDescriptor& partition_descriptor, |
| 487 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 495 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 488 protocol_handler_interceptor, | 496 protocol_handler_interceptor, |
| 489 content::ProtocolHandlerMap* protocol_handlers) const { | 497 content::ProtocolHandlerMap* protocol_handlers) const { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 InstallProtocolHandlers(job_factory.get(), protocol_handlers); | 569 InstallProtocolHandlers(job_factory.get(), protocol_handlers); |
| 562 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 570 scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
| 563 // Overwrite the job factory that we inherit from the main context so | 571 // Overwrite the job factory that we inherit from the main context so |
| 564 // that we can later provide our own handlers for storage related protocols. | 572 // that we can later provide our own handlers for storage related protocols. |
| 565 // Install all the usual protocol handlers unless we are in a browser plugin | 573 // Install all the usual protocol handlers unless we are in a browser plugin |
| 566 // guest process, in which case only web-safe schemes are allowed. | 574 // guest process, in which case only web-safe schemes are allowed. |
| 567 if (!partition_descriptor.in_memory) { | 575 if (!partition_descriptor.in_memory) { |
| 568 top_job_factory = SetUpJobFactoryDefaults( | 576 top_job_factory = SetUpJobFactoryDefaults( |
| 569 job_factory.Pass(), protocol_handler_interceptor.Pass(), | 577 job_factory.Pass(), protocol_handler_interceptor.Pass(), |
| 570 network_delegate(), | 578 network_delegate(), |
| 571 ftp_factory_.get()); | 579 context->ftp_transaction_factory(), |
| 580 context->ftp_auth_cache()); |
| 572 } else { | 581 } else { |
| 573 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); | 582 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); |
| 574 } | 583 } |
| 575 context->SetJobFactory(top_job_factory.Pass()); | 584 context->SetJobFactory(top_job_factory.Pass()); |
| 576 | 585 |
| 577 return context; | 586 return context; |
| 578 } | 587 } |
| 579 | 588 |
| 580 ChromeURLRequestContext* | 589 ChromeURLRequestContext* |
| 581 ProfileImplIOData::InitializeMediaRequestContext( | 590 ProfileImplIOData::InitializeMediaRequestContext( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 const base::Closure& completion) { | 677 const base::Closure& completion) { |
| 669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 678 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 670 DCHECK(initialized()); | 679 DCHECK(initialized()); |
| 671 | 680 |
| 672 DCHECK(transport_security_state()); | 681 DCHECK(transport_security_state()); |
| 673 // Completes synchronously. | 682 // Completes synchronously. |
| 674 transport_security_state()->DeleteAllDynamicDataSince(time); | 683 transport_security_state()->DeleteAllDynamicDataSince(time); |
| 675 DCHECK(http_server_properties_manager_); | 684 DCHECK(http_server_properties_manager_); |
| 676 http_server_properties_manager_->Clear(completion); | 685 http_server_properties_manager_->Clear(completion); |
| 677 } | 686 } |
| OLD | NEW |