| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 main_cache->set_mode( | 408 main_cache->set_mode( |
| 409 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 409 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
| 410 } | 410 } |
| 411 | 411 |
| 412 main_http_factory_.reset(main_cache); | 412 main_http_factory_.reset(main_cache); |
| 413 main_context->set_http_transaction_factory(main_cache); | 413 main_context->set_http_transaction_factory(main_cache); |
| 414 | 414 |
| 415 #if !defined(DISABLE_FTP_SUPPORT) | 415 #if !defined(DISABLE_FTP_SUPPORT) |
| 416 ftp_factory_.reset( | 416 ftp_factory_.reset( |
| 417 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 417 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 418 main_context->set_ftp_transaction_factory(ftp_factory_.get()); | |
| 419 #endif // !defined(DISABLE_FTP_SUPPORT) | 418 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 420 | 419 |
| 421 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 420 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
| 422 new net::URLRequestJobFactoryImpl()); | 421 new net::URLRequestJobFactoryImpl()); |
| 423 main_job_factory_ = SetUpJobFactoryDefaults( | 422 main_job_factory_ = SetUpJobFactoryDefaults( |
| 424 main_job_factory.Pass(), | 423 main_job_factory.Pass(), |
| 425 profile_params->protocol_handler_interceptor.Pass(), | 424 profile_params->protocol_handler_interceptor.Pass(), |
| 426 network_delegate(), | 425 network_delegate(), |
| 427 main_context->ftp_transaction_factory(), | 426 ftp_factory_.get()); |
| 428 main_context->ftp_auth_cache()); | |
| 429 main_context->set_job_factory(main_job_factory_.get()); | 427 main_context->set_job_factory(main_job_factory_.get()); |
| 430 | 428 |
| 431 #if defined(ENABLE_EXTENSIONS) | 429 #if defined(ENABLE_EXTENSIONS) |
| 432 InitializeExtensionsRequestContext(profile_params); | 430 InitializeExtensionsRequestContext(profile_params); |
| 433 #endif | 431 #endif |
| 434 | 432 |
| 435 // Create a media request context based on the main context, but using a | 433 // Create a media request context based on the main context, but using a |
| 436 // media cache. It shares the same job factory as the main context. | 434 // media cache. It shares the same job factory as the main context. |
| 437 StoragePartitionDescriptor details(profile_path_, false); | 435 StoragePartitionDescriptor details(profile_path_, false); |
| 438 media_request_context_.reset(InitializeMediaRequestContext(main_context, | 436 media_request_context_.reset(InitializeMediaRequestContext(main_context, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 459 new net::CookieMonster( | 457 new net::CookieMonster( |
| 460 new SQLitePersistentCookieStore( | 458 new SQLitePersistentCookieStore( |
| 461 lazy_params_->extensions_cookie_path, | 459 lazy_params_->extensions_cookie_path, |
| 462 lazy_params_->restore_old_session_cookies, NULL), NULL); | 460 lazy_params_->restore_old_session_cookies, NULL), NULL); |
| 463 // Enable cookies for devtools and extension URLs. | 461 // Enable cookies for devtools and extension URLs. |
| 464 const char* schemes[] = {chrome::kChromeDevToolsScheme, | 462 const char* schemes[] = {chrome::kChromeDevToolsScheme, |
| 465 extensions::kExtensionScheme}; | 463 extensions::kExtensionScheme}; |
| 466 extensions_cookie_store->SetCookieableSchemes(schemes, 2); | 464 extensions_cookie_store->SetCookieableSchemes(schemes, 2); |
| 467 extensions_context->set_cookie_store(extensions_cookie_store); | 465 extensions_context->set_cookie_store(extensions_cookie_store); |
| 468 | 466 |
| 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 | |
| 474 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 467 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |
| 475 new net::URLRequestJobFactoryImpl()); | 468 new net::URLRequestJobFactoryImpl()); |
| 476 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 469 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |
| 477 // Without a network_delegate, this protocol handler will never | 470 // Without a network_delegate, this protocol handler will never |
| 478 // handle file: requests, but as a side effect it makes | 471 // handle file: requests, but as a side effect it makes |
| 479 // job_factory::IsHandledProtocol return true, which prevents attempts to | 472 // job_factory::IsHandledProtocol return true, which prevents attempts to |
| 480 // handle the protocol externally. We pass NULL in to | 473 // handle the protocol externally. We pass NULL in to |
| 481 // SetUpJobFactory() to get this effect. | 474 // SetUpJobFactory() to get this effect. |
| 482 extensions_job_factory_ = SetUpJobFactoryDefaults( | 475 extensions_job_factory_ = SetUpJobFactoryDefaults( |
| 483 extensions_job_factory.Pass(), | 476 extensions_job_factory.Pass(), |
| 484 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), | 477 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), |
| 485 NULL, | 478 NULL, |
| 486 extensions_context->ftp_transaction_factory(), | 479 ftp_factory_.get()); |
| 487 extensions_context->ftp_auth_cache()); | |
| 488 extensions_context->set_job_factory(extensions_job_factory_.get()); | 480 extensions_context->set_job_factory(extensions_job_factory_.get()); |
| 489 } | 481 } |
| 490 | 482 |
| 491 ChromeURLRequestContext* | 483 ChromeURLRequestContext* |
| 492 ProfileImplIOData::InitializeAppRequestContext( | 484 ProfileImplIOData::InitializeAppRequestContext( |
| 493 ChromeURLRequestContext* main_context, | 485 ChromeURLRequestContext* main_context, |
| 494 const StoragePartitionDescriptor& partition_descriptor, | 486 const StoragePartitionDescriptor& partition_descriptor, |
| 495 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 487 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 496 protocol_handler_interceptor) const { | 488 protocol_handler_interceptor) const { |
| 497 // Copy most state from the main context. | 489 // Copy most state from the main context. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 new net::URLRequestJobFactoryImpl()); | 552 new net::URLRequestJobFactoryImpl()); |
| 561 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 553 scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
| 562 // Overwrite the job factory that we inherit from the main context so | 554 // Overwrite the job factory that we inherit from the main context so |
| 563 // that we can later provide our own handlers for storage related protocols. | 555 // that we can later provide our own handlers for storage related protocols. |
| 564 // Install all the usual protocol handlers unless we are in a browser plugin | 556 // Install all the usual protocol handlers unless we are in a browser plugin |
| 565 // guest process, in which case only web-safe schemes are allowed. | 557 // guest process, in which case only web-safe schemes are allowed. |
| 566 if (!partition_descriptor.in_memory) { | 558 if (!partition_descriptor.in_memory) { |
| 567 top_job_factory = SetUpJobFactoryDefaults( | 559 top_job_factory = SetUpJobFactoryDefaults( |
| 568 job_factory.Pass(), protocol_handler_interceptor.Pass(), | 560 job_factory.Pass(), protocol_handler_interceptor.Pass(), |
| 569 network_delegate(), | 561 network_delegate(), |
| 570 context->ftp_transaction_factory(), | 562 ftp_factory_.get()); |
| 571 context->ftp_auth_cache()); | |
| 572 } else { | 563 } else { |
| 573 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); | 564 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); |
| 574 } | 565 } |
| 575 context->SetJobFactory(top_job_factory.Pass()); | 566 context->SetJobFactory(top_job_factory.Pass()); |
| 576 | 567 |
| 577 return context; | 568 return context; |
| 578 } | 569 } |
| 579 | 570 |
| 580 ChromeURLRequestContext* | 571 ChromeURLRequestContext* |
| 581 ProfileImplIOData::InitializeMediaRequestContext( | 572 ProfileImplIOData::InitializeMediaRequestContext( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 base::Time time, | 656 base::Time time, |
| 666 const base::Closure& completion) { | 657 const base::Closure& completion) { |
| 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 668 LazyInitialize(); | 659 LazyInitialize(); |
| 669 | 660 |
| 670 DCHECK(transport_security_state()); | 661 DCHECK(transport_security_state()); |
| 671 transport_security_state()->DeleteSince(time); // Completes synchronously. | 662 transport_security_state()->DeleteSince(time); // Completes synchronously. |
| 672 DCHECK(http_server_properties_manager_); | 663 DCHECK(http_server_properties_manager_); |
| 673 http_server_properties_manager_->Clear(completion); | 664 http_server_properties_manager_->Clear(completion); |
| 674 } | 665 } |
| OLD | NEW |