| 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 410   ftp_factory_.reset( | 410   ftp_factory_.reset( | 
| 411       new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 411       new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 
| 412   main_context->set_ftp_transaction_factory(ftp_factory_.get()); | 412   main_context->set_ftp_transaction_factory(ftp_factory_.get()); | 
| 413 #endif  // !defined(DISABLE_FTP_SUPPORT) | 413 #endif  // !defined(DISABLE_FTP_SUPPORT) | 
| 414 | 414 | 
| 415   main_context->set_chrome_url_data_manager_backend( | 415   main_context->set_chrome_url_data_manager_backend( | 
| 416       chrome_url_data_manager_backend()); | 416       chrome_url_data_manager_backend()); | 
| 417 | 417 | 
| 418   scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 418   scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 
| 419       new net::URLRequestJobFactoryImpl()); | 419       new net::URLRequestJobFactoryImpl()); | 
| 420   SetUpJobFactory(main_job_factory.get(), | 420   main_job_factory_ = SetUpJobFactory( | 
| 421                   profile_params->protocol_handler_interceptor.Pass(), | 421       main_job_factory.Pass(), | 
| 422                   network_delegate(), | 422       profile_params->protocol_handler_interceptor.Pass(), | 
| 423                   main_context->ftp_transaction_factory(), | 423       network_delegate(), | 
| 424                   main_context->ftp_auth_cache()); | 424       main_context->ftp_transaction_factory(), | 
| 425   main_job_factory_ = main_job_factory.Pass(); | 425       main_context->ftp_auth_cache()); | 
| 426   main_context->set_job_factory(main_job_factory_.get()); | 426   main_context->set_job_factory(main_job_factory_.get()); | 
| 427 | 427 | 
| 428 #if defined(ENABLE_EXTENSIONS) | 428 #if defined(ENABLE_EXTENSIONS) | 
| 429   InitializeExtensionsRequestContext(profile_params); | 429   InitializeExtensionsRequestContext(profile_params); | 
| 430 #endif | 430 #endif | 
| 431 | 431 | 
| 432   // 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 | 
| 433   // 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. | 
| 434   StoragePartitionDescriptor details(profile_path_, false); | 434   StoragePartitionDescriptor details(profile_path_, false); | 
| 435   media_request_context_.reset(InitializeMediaRequestContext(main_context, | 435   media_request_context_.reset(InitializeMediaRequestContext(main_context, | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 469 #endif  // !defined(DISABLE_FTP_SUPPORT) | 469 #endif  // !defined(DISABLE_FTP_SUPPORT) | 
| 470 | 470 | 
| 471   scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 471   scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 
| 472       new net::URLRequestJobFactoryImpl()); | 472       new net::URLRequestJobFactoryImpl()); | 
| 473   // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 473   // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 
| 474   // Without a network_delegate, this protocol handler will never | 474   // Without a network_delegate, this protocol handler will never | 
| 475   // handle file: requests, but as a side effect it makes | 475   // handle file: requests, but as a side effect it makes | 
| 476   // job_factory::IsHandledProtocol return true, which prevents attempts to | 476   // job_factory::IsHandledProtocol return true, which prevents attempts to | 
| 477   // handle the protocol externally. We pass NULL in to | 477   // handle the protocol externally. We pass NULL in to | 
| 478   // SetUpJobFactory() to get this effect. | 478   // SetUpJobFactory() to get this effect. | 
| 479   SetUpJobFactory(extensions_job_factory.get(), | 479   extensions_job_factory_ = SetUpJobFactory( | 
| 480                   scoped_ptr<net::URLRequestJobFactoryImpl::Interceptor>(NULL), | 480       extensions_job_factory.Pass(), | 
| 481                   NULL, | 481       scoped_ptr<net::URLRequestJobFactoryImpl::Interceptor>(NULL), | 
| 482                   extensions_context->ftp_transaction_factory(), | 482       NULL, | 
| 483                   extensions_context->ftp_auth_cache()); | 483       extensions_context->ftp_transaction_factory(), | 
| 484   extensions_job_factory_ = extensions_job_factory.Pass(); | 484       extensions_context->ftp_auth_cache()); | 
|  | 485 | 
| 485   extensions_context->set_job_factory(extensions_job_factory_.get()); | 486   extensions_context->set_job_factory(extensions_job_factory_.get()); | 
| 486 } | 487 } | 
| 487 | 488 | 
| 488 ChromeURLRequestContext* | 489 ChromeURLRequestContext* | 
| 489 ProfileImplIOData::InitializeAppRequestContext( | 490 ProfileImplIOData::InitializeAppRequestContext( | 
| 490     ChromeURLRequestContext* main_context, | 491     ChromeURLRequestContext* main_context, | 
| 491     const StoragePartitionDescriptor& partition_descriptor, | 492     const StoragePartitionDescriptor& partition_descriptor, | 
| 492     scoped_ptr<net::URLRequestJobFactory::Interceptor> | 493     scoped_ptr<net::URLRequestJobFactory::Interceptor> | 
| 493         protocol_handler_interceptor) const { | 494         protocol_handler_interceptor) const { | 
| 494   // Copy most state from the main context. | 495   // Copy most state from the main context. | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 550 | 551 | 
| 551   // Transfer ownership of the cookies and cache to AppRequestContext. | 552   // Transfer ownership of the cookies and cache to AppRequestContext. | 
| 552   context->SetCookieStore(cookie_store); | 553   context->SetCookieStore(cookie_store); | 
| 553   context->SetHttpTransactionFactory( | 554   context->SetHttpTransactionFactory( | 
| 554       scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 555       scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); | 
| 555 | 556 | 
| 556   // Overwrite the job factory that we inherit from the main context so | 557   // Overwrite the job factory that we inherit from the main context so | 
| 557   // that we can later provide our own handles for storage related protocols. | 558   // that we can later provide our own handles for storage related protocols. | 
| 558   // Install all the usual protocol handlers unless we are in a browser plugin | 559   // Install all the usual protocol handlers unless we are in a browser plugin | 
| 559   // guest process, in which case only web-safe schemes are allowed. | 560   // guest process, in which case only web-safe schemes are allowed. | 
| 560   scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 561   scoped_ptr<net::URLRequestJobFactoryImpl> base_job_factory( | 
| 561       new net::URLRequestJobFactoryImpl()); | 562       new net::URLRequestJobFactoryImpl()); | 
|  | 563   scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 
| 562   if (!partition_descriptor.in_memory) { | 564   if (!partition_descriptor.in_memory) { | 
| 563     SetUpJobFactory(job_factory.get(), protocol_handler_interceptor.Pass(), | 565     top_job_factory = SetUpJobFactory(base_job_factory.Pass(), | 
| 564                     network_delegate(), | 566                                       protocol_handler_interceptor.Pass(), | 
| 565                     context->ftp_transaction_factory(), | 567                                       network_delegate(), | 
| 566                     context->ftp_auth_cache()); | 568                                       context->ftp_transaction_factory(), | 
|  | 569                                       context->ftp_auth_cache()); | 
|  | 570   } else { | 
|  | 571     top_job_factory = base_job_factory.PassAs<net::URLRequestJobFactory>(); | 
| 567   } | 572   } | 
| 568   context->SetJobFactory(job_factory.PassAs<net::URLRequestJobFactory>()); | 573   context->SetJobFactory(top_job_factory.Pass()); | 
| 569 | 574 | 
| 570   return context; | 575   return context; | 
| 571 } | 576 } | 
| 572 | 577 | 
| 573 ChromeURLRequestContext* | 578 ChromeURLRequestContext* | 
| 574 ProfileImplIOData::InitializeMediaRequestContext( | 579 ProfileImplIOData::InitializeMediaRequestContext( | 
| 575     ChromeURLRequestContext* original_context, | 580     ChromeURLRequestContext* original_context, | 
| 576     const StoragePartitionDescriptor& partition_descriptor) const { | 581     const StoragePartitionDescriptor& partition_descriptor) const { | 
| 577   // If this is for a in_memory partition, we can simply use the original | 582   // If this is for a in_memory partition, we can simply use the original | 
| 578   // context (like off-the-record mode). | 583   // context (like off-the-record mode). | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 647       InitializeMediaRequestContext(app_context, partition_descriptor); | 652       InitializeMediaRequestContext(app_context, partition_descriptor); | 
| 648   DCHECK(media_request_context); | 653   DCHECK(media_request_context); | 
| 649   return media_request_context; | 654   return media_request_context; | 
| 650 } | 655 } | 
| 651 | 656 | 
| 652 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( | 657 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( | 
| 653     IOThread::Globals* io_thread_globals) const { | 658     IOThread::Globals* io_thread_globals) const { | 
| 654   return io_thread_globals->load_time_stats.get(); | 659   return io_thread_globals->load_time_stats.get(); | 
| 655 } | 660 } | 
| 656 | 661 | 
| 657 void ProfileImplIOData::SetUpJobFactory( | 662 scoped_ptr<net::URLRequestJobFactory> ProfileImplIOData::SetUpJobFactory( | 
| 658     net::URLRequestJobFactoryImpl* job_factory, | 663     scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, | 
| 659     scoped_ptr<net::URLRequestJobFactory::Interceptor> | 664     scoped_ptr<net::URLRequestJobFactory::Interceptor> | 
| 660         protocol_handler_interceptor, | 665         protocol_handler_interceptor, | 
| 661     net::NetworkDelegate* network_delegate, | 666     net::NetworkDelegate* network_delegate, | 
| 662     net::FtpTransactionFactory* ftp_transaction_factory, | 667     net::FtpTransactionFactory* ftp_transaction_factory, | 
| 663     net::FtpAuthCache* ftp_auth_cache) const { | 668     net::FtpAuthCache* ftp_auth_cache) const { | 
| 664   SetUpJobFactoryDefaults(job_factory, protocol_handler_interceptor.Pass(), | 669   scoped_ptr<net::URLRequestJobFactory> top_job_factory = | 
| 665                           network_delegate, ftp_transaction_factory, | 670       SetUpJobFactoryDefaults(job_factory.Pass(), | 
| 666                           ftp_auth_cache); | 671                               protocol_handler_interceptor.Pass(), | 
| 667 | 672                               network_delegate, ftp_transaction_factory, | 
| 668   job_factory->AddInterceptor( | 673                               ftp_auth_cache); | 
| 669       new chrome_browser_net::ConnectInterceptor(predictor_.get())); | 674   return chrome_browser_net::ConnectInterceptor::CreateURLRequestJobFactory( | 
|  | 675       top_job_factory.Pass(), predictor_.get()); | 
| 670 } | 676 } | 
| 671 | 677 | 
| 672 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 678 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 
| 673     base::Time time, | 679     base::Time time, | 
| 674     const base::Closure& completion) { | 680     const base::Closure& completion) { | 
| 675   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 681   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 
| 676   LazyInitialize(); | 682   LazyInitialize(); | 
| 677 | 683 | 
| 678   DCHECK(transport_security_state()); | 684   DCHECK(transport_security_state()); | 
| 679   transport_security_state()->DeleteSince(time);  // Completes synchronously. | 685   transport_security_state()->DeleteSince(time);  // Completes synchronously. | 
| 680   DCHECK(http_server_properties_manager()); | 686   DCHECK(http_server_properties_manager()); | 
| 681   http_server_properties_manager()->Clear(completion); | 687   http_server_properties_manager()->Clear(completion); | 
| 682 } | 688 } | 
| OLD | NEW | 
|---|