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) | 467 #if !defined(DISABLE_FTP_SUPPORT) |
erikwright (departed)
2013/01/21 16:20:13
As mentioned.
| |
470 DCHECK(ftp_factory_.get()); | 468 DCHECK(ftp_factory_.get()); |
471 extensions_context->set_ftp_transaction_factory(ftp_factory_.get()); | |
472 #endif // !defined(DISABLE_FTP_SUPPORT) | 469 #endif // !defined(DISABLE_FTP_SUPPORT) |
473 | 470 |
474 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 471 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |
475 new net::URLRequestJobFactoryImpl()); | 472 new net::URLRequestJobFactoryImpl()); |
476 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 473 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |
477 // Without a network_delegate, this protocol handler will never | 474 // Without a network_delegate, this protocol handler will never |
478 // handle file: requests, but as a side effect it makes | 475 // handle file: requests, but as a side effect it makes |
479 // job_factory::IsHandledProtocol return true, which prevents attempts to | 476 // job_factory::IsHandledProtocol return true, which prevents attempts to |
480 // handle the protocol externally. We pass NULL in to | 477 // handle the protocol externally. We pass NULL in to |
481 // SetUpJobFactory() to get this effect. | 478 // SetUpJobFactory() to get this effect. |
482 extensions_job_factory_ = SetUpJobFactoryDefaults( | 479 extensions_job_factory_ = SetUpJobFactoryDefaults( |
483 extensions_job_factory.Pass(), | 480 extensions_job_factory.Pass(), |
484 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), | 481 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), |
485 NULL, | 482 NULL, |
486 extensions_context->ftp_transaction_factory(), | 483 ftp_factory_.get()); |
487 extensions_context->ftp_auth_cache()); | |
488 extensions_context->set_job_factory(extensions_job_factory_.get()); | 484 extensions_context->set_job_factory(extensions_job_factory_.get()); |
489 } | 485 } |
490 | 486 |
491 ChromeURLRequestContext* | 487 ChromeURLRequestContext* |
492 ProfileImplIOData::InitializeAppRequestContext( | 488 ProfileImplIOData::InitializeAppRequestContext( |
493 ChromeURLRequestContext* main_context, | 489 ChromeURLRequestContext* main_context, |
494 const StoragePartitionDescriptor& partition_descriptor, | 490 const StoragePartitionDescriptor& partition_descriptor, |
495 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 491 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
496 protocol_handler_interceptor) const { | 492 protocol_handler_interceptor) const { |
497 // Copy most state from the main context. | 493 // Copy most state from the main context. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 // extensions API, but we need to update it to understand isolated apps | 545 // extensions API, but we need to update it to understand isolated apps |
550 // first. | 546 // first. |
551 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); | 547 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); |
552 } | 548 } |
553 | 549 |
554 // Transfer ownership of the cookies and cache to AppRequestContext. | 550 // Transfer ownership of the cookies and cache to AppRequestContext. |
555 context->SetCookieStore(cookie_store); | 551 context->SetCookieStore(cookie_store); |
556 context->SetHttpTransactionFactory( | 552 context->SetHttpTransactionFactory( |
557 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 553 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); |
558 | 554 |
555 #if !defined(DISABLE_FTP_SUPPORT) | |
erikwright (departed)
2013/01/21 16:20:13
As mentioned.
| |
556 DCHECK(ftp_factory_.get()); | |
557 #endif // !defined(DISABLE_FTP_SUPPORT) | |
558 | |
559 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 559 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
560 new net::URLRequestJobFactoryImpl()); | 560 new net::URLRequestJobFactoryImpl()); |
561 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 561 scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
562 // Overwrite the job factory that we inherit from the main context so | 562 // 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. | 563 // 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 | 564 // 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. | 565 // guest process, in which case only web-safe schemes are allowed. |
566 if (!partition_descriptor.in_memory) { | 566 if (!partition_descriptor.in_memory) { |
567 top_job_factory = SetUpJobFactoryDefaults( | 567 top_job_factory = SetUpJobFactoryDefaults( |
568 job_factory.Pass(), protocol_handler_interceptor.Pass(), | 568 job_factory.Pass(), protocol_handler_interceptor.Pass(), |
569 network_delegate(), | 569 network_delegate(), |
570 context->ftp_transaction_factory(), | 570 ftp_factory_.get()); |
571 context->ftp_auth_cache()); | |
572 } else { | 571 } else { |
573 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); | 572 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); |
574 } | 573 } |
575 context->SetJobFactory(top_job_factory.Pass()); | 574 context->SetJobFactory(top_job_factory.Pass()); |
576 | 575 |
577 return context; | 576 return context; |
578 } | 577 } |
579 | 578 |
580 ChromeURLRequestContext* | 579 ChromeURLRequestContext* |
581 ProfileImplIOData::InitializeMediaRequestContext( | 580 ProfileImplIOData::InitializeMediaRequestContext( |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 base::Time time, | 664 base::Time time, |
666 const base::Closure& completion) { | 665 const base::Closure& completion) { |
667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 666 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
668 LazyInitialize(); | 667 LazyInitialize(); |
669 | 668 |
670 DCHECK(transport_security_state()); | 669 DCHECK(transport_security_state()); |
671 transport_security_state()->DeleteSince(time); // Completes synchronously. | 670 transport_security_state()->DeleteSince(time); // Completes synchronously. |
672 DCHECK(http_server_properties_manager_); | 671 DCHECK(http_server_properties_manager_); |
673 http_server_properties_manager_->Clear(completion); | 672 http_server_properties_manager_->Clear(completion); |
674 } | 673 } |
OLD | NEW |