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

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

Issue 10537056: Replaced static URLRequestFtpJob factory with non-static protocol handler for FTP jobs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed job factories in off_the_record Created 8 years, 6 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 12 matching lines...) Expand all
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/resource_context.h" 29 #include "content/public/browser/resource_context.h"
30 #include "net/base/server_bound_cert_service.h" 30 #include "net/base/server_bound_cert_service.h"
31 #include "net/ftp/ftp_network_layer.h" 31 #include "net/ftp/ftp_network_layer.h"
32 #include "net/http/http_cache.h" 32 #include "net/http/http_cache.h"
33 #include "net/url_request/ftp_protocol_handler.h"
33 #include "net/url_request/url_request_job_factory.h" 34 #include "net/url_request/url_request_job_factory.h"
34 #include "webkit/quota/special_storage_policy.h" 35 #include "webkit/quota/special_storage_policy.h"
35 36
36 using content::BrowserThread; 37 using content::BrowserThread;
37 38
38 ProfileImplIOData::Handle::Handle(Profile* profile) 39 ProfileImplIOData::Handle::Handle(Profile* profile)
39 : io_data_(new ProfileImplIOData), 40 : io_data_(new ProfileImplIOData),
40 profile_(profile), 41 profile_(profile),
41 initialized_(false) { 42 initialized_(false) {
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 main_http_factory_.reset(main_cache); 428 main_http_factory_.reset(main_cache);
428 media_http_factory_.reset(media_cache); 429 media_http_factory_.reset(media_cache);
429 main_context->set_http_transaction_factory(main_cache); 430 main_context->set_http_transaction_factory(main_cache);
430 media_request_context_->set_http_transaction_factory(media_cache); 431 media_request_context_->set_http_transaction_factory(media_cache);
431 432
432 ftp_factory_.reset( 433 ftp_factory_.reset(
433 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); 434 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
434 main_context->set_ftp_transaction_factory(ftp_factory_.get()); 435 main_context->set_ftp_transaction_factory(ftp_factory_.get());
435 media_request_context_->set_ftp_transaction_factory(ftp_factory_.get()); 436 media_request_context_->set_ftp_transaction_factory(ftp_factory_.get());
436 437
438 ftp_auth_cache_.reset(new net::FtpAuthCache);
439
437 main_context->set_chrome_url_data_manager_backend( 440 main_context->set_chrome_url_data_manager_backend(
438 chrome_url_data_manager_backend()); 441 chrome_url_data_manager_backend());
439 442
440 main_context->set_job_factory(job_factory()); 443 main_job_factory_.reset(new net::URLRequestJobFactory);
441 media_request_context_->set_job_factory(job_factory()); 444 media_request_job_factory_.reset(new net::URLRequestJobFactory);
442 extensions_context->set_job_factory(job_factory()); 445 extensions_job_factory_.reset(new net::URLRequestJobFactory);
443 446
444 job_factory()->AddInterceptor( 447 net::URLRequestJobFactory* job_factories[3];
445 new chrome_browser_net::ConnectInterceptor(predictor_.get())); 448 job_factories[0] = main_job_factory_.get();
449 job_factories[1] = media_request_job_factory_.get();
450 job_factories[2] = extensions_job_factory_.get();
451
452 for (int i = 0; i < 3; i++) {
453 SetUpJobFactoryDefaults(job_factories[i]);
454 CreateFtpProtocolHandler(job_factories[i]);
455 AddConnectInterceptor(job_factories[i]);
456 }
457
458 main_context->set_job_factory(main_job_factory_.get());
459 media_request_context_->set_job_factory(media_request_job_factory_.get());
460 extensions_context->set_job_factory(extensions_job_factory_.get());
446 461
447 lazy_params_.reset(); 462 lazy_params_.reset();
448 } 463 }
449 464
450 ChromeURLRequestContext* 465 ChromeURLRequestContext*
451 ProfileImplIOData::InitializeAppRequestContext( 466 ProfileImplIOData::InitializeAppRequestContext(
452 ChromeURLRequestContext* main_context, 467 ChromeURLRequestContext* main_context,
453 const std::string& app_id) const { 468 const std::string& app_id) const {
454 AppRequestContext* context = new AppRequestContext; 469 AppRequestContext* context = new AppRequestContext;
455 470
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 ProfileImplIOData::AcquireIsolatedAppRequestContext( 536 ProfileImplIOData::AcquireIsolatedAppRequestContext(
522 ChromeURLRequestContext* main_context, 537 ChromeURLRequestContext* main_context,
523 const std::string& app_id) const { 538 const std::string& app_id) const {
524 // We create per-app contexts on demand, unlike the others above. 539 // We create per-app contexts on demand, unlike the others above.
525 ChromeURLRequestContext* app_request_context = 540 ChromeURLRequestContext* app_request_context =
526 InitializeAppRequestContext(main_context, app_id); 541 InitializeAppRequestContext(main_context, app_id);
527 DCHECK(app_request_context); 542 DCHECK(app_request_context);
528 return app_request_context; 543 return app_request_context;
529 } 544 }
530 545
546 void ProfileImplIOData::CreateFtpProtocolHandler(
547 net::URLRequestJobFactory* job_factory) const {
548 job_factory->SetProtocolHandler(
549 chrome::kFtpScheme,
550 new net::FtpProtocolHandler(
551 network_delegate(), ftp_factory_.get(), ftp_auth_cache_.get()));
552 }
553
554 void ProfileImplIOData::AddConnectInterceptor(
555 net::URLRequestJobFactory* job_factory) const {
556 job_factory->AddInterceptor(
557 new chrome_browser_net::ConnectInterceptor(predictor_.get()));
558 }
559
531 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( 560 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread(
532 base::Time time) { 561 base::Time time) {
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 562 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
534 LazyInitialize(); 563 LazyInitialize();
535 564
536 DCHECK(transport_security_state()); 565 DCHECK(transport_security_state());
537 transport_security_state()->DeleteSince(time); 566 transport_security_state()->DeleteSince(time);
538 DCHECK(http_server_properties_manager()); 567 DCHECK(http_server_properties_manager());
539 http_server_properties_manager()->Clear(); 568 http_server_properties_manager()->Clear();
540 } 569 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698