Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 11154006: Change initialization interface of URLRequestJobFactory objects. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Refactor to make better use of scoped_ptr. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 #if !defined(DISABLE_FTP_SUPPORT) 436 #if !defined(DISABLE_FTP_SUPPORT)
437 ftp_factory_.reset( 437 ftp_factory_.reset(
438 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); 438 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
439 main_context->set_ftp_transaction_factory(ftp_factory_.get()); 439 main_context->set_ftp_transaction_factory(ftp_factory_.get());
440 extensions_context->set_ftp_transaction_factory(ftp_factory_.get()); 440 extensions_context->set_ftp_transaction_factory(ftp_factory_.get());
441 #endif // !defined(DISABLE_FTP_SUPPORT) 441 #endif // !defined(DISABLE_FTP_SUPPORT)
442 442
443 main_context->set_chrome_url_data_manager_backend( 443 main_context->set_chrome_url_data_manager_backend(
444 chrome_url_data_manager_backend()); 444 chrome_url_data_manager_backend());
445 445
446 main_job_factory_.reset(new net::URLRequestJobFactoryImpl); 446 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
447 extensions_job_factory_.reset(new net::URLRequestJobFactoryImpl); 447 new net::URLRequestJobFactoryImpl());
448 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory(
449 new net::URLRequestJobFactoryImpl());
448 450
449 SetUpJobFactory(main_job_factory_.get(), 451 SetUpJobFactory(main_job_factory.get(),
450 profile_params->protocol_handler_interceptor.Pass(), 452 profile_params->protocol_handler_interceptor.Pass(),
451 network_delegate(), 453 network_delegate(),
452 main_context->ftp_transaction_factory(), 454 main_context->ftp_transaction_factory(),
453 main_context->ftp_auth_cache()); 455 main_context->ftp_auth_cache());
454 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. 456 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate.
455 // Without a network_delegate, this protocol handler will never 457 // Without a network_delegate, this protocol handler will never
456 // handle file: requests, but as a side effect it makes 458 // handle file: requests, but as a side effect it makes
457 // job_factory::IsHandledProtocol return true, which prevents attempts to 459 // job_factory::IsHandledProtocol return true, which prevents attempts to
458 // handle the protocol externally. We pass NULL in to 460 // handle the protocol externally. We pass NULL in to
459 // SetUpJobFactory() to get this effect. 461 // SetUpJobFactory() to get this effect.
460 SetUpJobFactory(extensions_job_factory_.get(), 462 SetUpJobFactory(extensions_job_factory.get(),
461 scoped_ptr<net::URLRequestJobFactoryImpl::Interceptor>(NULL), 463 scoped_ptr<net::URLRequestJobFactoryImpl::Interceptor>(NULL),
462 NULL, 464 NULL,
463 extensions_context->ftp_transaction_factory(), 465 extensions_context->ftp_transaction_factory(),
464 extensions_context->ftp_auth_cache()); 466 extensions_context->ftp_auth_cache());
465 467
468 main_job_factory_ = main_job_factory.Pass();
466 main_context->set_job_factory(main_job_factory_.get()); 469 main_context->set_job_factory(main_job_factory_.get());
470 extensions_job_factory_ = extensions_job_factory.Pass();
467 extensions_context->set_job_factory(extensions_job_factory_.get()); 471 extensions_context->set_job_factory(extensions_job_factory_.get());
468 472
469 // Create a media request context based on the main context, but using a 473 // Create a media request context based on the main context, but using a
470 // media cache. It shares the same job factory as the main context. 474 // media cache. It shares the same job factory as the main context.
471 media_request_context_.reset(InitializeMediaRequestContext(main_context, "")); 475 media_request_context_.reset(InitializeMediaRequestContext(main_context, ""));
472 476
473 lazy_params_.reset(); 477 lazy_params_.reset();
474 } 478 }
475 479
476 ChromeURLRequestContext* 480 ChromeURLRequestContext*
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); 547 cookie_store = new net::CookieMonster(cookie_db.get(), NULL);
544 } 548 }
545 549
546 // Transfer ownership of the cookies and cache to AppRequestContext. 550 // Transfer ownership of the cookies and cache to AppRequestContext.
547 context->SetCookieStore(cookie_store); 551 context->SetCookieStore(cookie_store);
548 context->SetHttpTransactionFactory( 552 context->SetHttpTransactionFactory(
549 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); 553 scoped_ptr<net::HttpTransactionFactory>(app_http_cache));
550 554
551 // Overwrite the job factory that we inherit from the main context so 555 // Overwrite the job factory that we inherit from the main context so
552 // that we can later provide our own handles for storage related protocols. 556 // that we can later provide our own handles for storage related protocols.
553 scoped_ptr<net::URLRequestJobFactory> job_factory( 557 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
554 new net::URLRequestJobFactoryImpl()); 558 new net::URLRequestJobFactoryImpl());
555 SetUpJobFactory(job_factory.get(), protocol_handler_interceptor.Pass(), 559 SetUpJobFactory(job_factory.get(), protocol_handler_interceptor.Pass(),
556 network_delegate(), 560 network_delegate(),
557 context->ftp_transaction_factory(), 561 context->ftp_transaction_factory(),
558 context->ftp_auth_cache()); 562 context->ftp_auth_cache());
559 context->SetJobFactory(job_factory.Pass()); 563 context->SetJobFactory(job_factory.PassAs<net::URLRequestJobFactory>());
560 564
561 return context; 565 return context;
562 } 566 }
563 567
564 ChromeURLRequestContext* 568 ChromeURLRequestContext*
565 ProfileImplIOData::InitializeMediaRequestContext( 569 ProfileImplIOData::InitializeMediaRequestContext(
566 ChromeURLRequestContext* original_context, 570 ChromeURLRequestContext* original_context,
567 const std::string& app_id) const { 571 const std::string& app_id) const {
568 // If this is for a guest process, we do not persist storage, so we can 572 // If this is for a guest process, we do not persist storage, so we can
569 // simply use the app's in-memory cache (like off-the-record mode). 573 // simply use the app's in-memory cache (like off-the-record mode).
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 DCHECK(media_request_context); 645 DCHECK(media_request_context);
642 return media_request_context; 646 return media_request_context;
643 } 647 }
644 648
645 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats( 649 chrome_browser_net::LoadTimeStats* ProfileImplIOData::GetLoadTimeStats(
646 IOThread::Globals* io_thread_globals) const { 650 IOThread::Globals* io_thread_globals) const {
647 return io_thread_globals->load_time_stats.get(); 651 return io_thread_globals->load_time_stats.get();
648 } 652 }
649 653
650 void ProfileImplIOData::SetUpJobFactory( 654 void ProfileImplIOData::SetUpJobFactory(
651 net::URLRequestJobFactory* job_factory, 655 net::URLRequestJobFactoryImpl* job_factory,
652 scoped_ptr<net::URLRequestJobFactory::Interceptor> 656 scoped_ptr<net::URLRequestJobFactory::Interceptor>
653 protocol_handler_interceptor, 657 protocol_handler_interceptor,
654 net::NetworkDelegate* network_delegate, 658 net::NetworkDelegate* network_delegate,
655 net::FtpTransactionFactory* ftp_transaction_factory, 659 net::FtpTransactionFactory* ftp_transaction_factory,
656 net::FtpAuthCache* ftp_auth_cache) const { 660 net::FtpAuthCache* ftp_auth_cache) const {
657 SetUpJobFactoryDefaults(job_factory, protocol_handler_interceptor.Pass(), 661 SetUpJobFactoryDefaults(job_factory, protocol_handler_interceptor.Pass(),
658 network_delegate, ftp_transaction_factory, 662 network_delegate, ftp_transaction_factory,
659 ftp_auth_cache); 663 ftp_auth_cache);
660 664
661 job_factory->AddInterceptor( 665 job_factory->AddInterceptor(
662 new chrome_browser_net::ConnectInterceptor(predictor_.get())); 666 new chrome_browser_net::ConnectInterceptor(predictor_.get()));
663 } 667 }
664 668
665 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( 669 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread(
666 base::Time time) { 670 base::Time time) {
667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 671 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
668 LazyInitialize(); 672 LazyInitialize();
669 673
670 DCHECK(transport_security_state()); 674 DCHECK(transport_security_state());
671 transport_security_state()->DeleteSince(time); 675 transport_security_state()->DeleteSince(time);
672 DCHECK(http_server_properties_manager()); 676 DCHECK(http_server_properties_manager());
673 http_server_properties_manager()->Clear(); 677 http_server_properties_manager()->Clear();
674 } 678 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698