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

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

Issue 2874973002: Flush Channel IDs when Cookies get saved to a persistent backend (Closed)
Patch Set: Initialize channel_id_service to nullptr Created 3 years, 7 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 <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 main_context->set_ct_policy_enforcer( 481 main_context->set_ct_policy_enforcer(
482 io_thread_globals->ct_policy_enforcer.get()); 482 io_thread_globals->ct_policy_enforcer.get());
483 483
484 main_context->set_net_log(io_thread->net_log()); 484 main_context->set_net_log(io_thread->net_log());
485 485
486 main_context->set_http_auth_handler_factory( 486 main_context->set_http_auth_handler_factory(
487 io_thread_globals->http_auth_handler_factory.get()); 487 io_thread_globals->http_auth_handler_factory.get());
488 488
489 main_context->set_proxy_service(proxy_service()); 489 main_context->set_proxy_service(proxy_service());
490 490
491 // Create a single task runner to use with the CookieStore and ChannelIDStore.
492 scoped_refptr<base::SequencedTaskRunner> cookie_background_task_runner =
493 base::CreateSequencedTaskRunnerWithTraits(
494 {base::MayBlock(), base::TaskPriority::BACKGROUND,
495 base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
496
497 // Set up server bound cert service.
498 DCHECK(!lazy_params_->channel_id_path.empty());
499 scoped_refptr<QuotaPolicyChannelIDStore> channel_id_db =
500 new QuotaPolicyChannelIDStore(lazy_params_->channel_id_path,
501 cookie_background_task_runner,
502 lazy_params_->special_storage_policy.get());
503 main_context_storage->set_channel_id_service(
504 base::MakeUnique<net::ChannelIDService>(
505 new net::DefaultChannelIDStore(channel_id_db.get())));
506
491 // Set up cookie store. 507 // Set up cookie store.
492 DCHECK(!lazy_params_->cookie_path.empty()); 508 DCHECK(!lazy_params_->cookie_path.empty());
493 509
494 content::CookieStoreConfig cookie_config( 510 content::CookieStoreConfig cookie_config(
495 lazy_params_->cookie_path, lazy_params_->session_cookie_mode, 511 lazy_params_->cookie_path, lazy_params_->session_cookie_mode,
496 lazy_params_->special_storage_policy.get(), 512 lazy_params_->special_storage_policy.get(),
497 profile_params->cookie_monster_delegate.get()); 513 profile_params->cookie_monster_delegate.get());
498 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); 514 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate();
515 cookie_config.channel_id_service = main_context->channel_id_service();
516 cookie_config.background_task_runner = cookie_background_task_runner;
499 main_context_storage->set_cookie_store( 517 main_context_storage->set_cookie_store(
500 content::CreateCookieStore(cookie_config)); 518 content::CreateCookieStore(cookie_config));
501 519
502 // Set up server bound cert service.
503 DCHECK(!lazy_params_->channel_id_path.empty());
504 scoped_refptr<QuotaPolicyChannelIDStore> channel_id_db =
505 new QuotaPolicyChannelIDStore(
506 lazy_params_->channel_id_path,
507 base::CreateSequencedTaskRunnerWithTraits(
508 {base::MayBlock(), base::TaskPriority::BACKGROUND}),
509 lazy_params_->special_storage_policy.get());
510 main_context_storage->set_channel_id_service(
511 base::MakeUnique<net::ChannelIDService>(
512 new net::DefaultChannelIDStore(channel_id_db.get())));
513
514 main_context->cookie_store()->SetChannelIDServiceID( 520 main_context->cookie_store()->SetChannelIDServiceID(
515 main_context->channel_id_service()->GetUniqueID()); 521 main_context->channel_id_service()->GetUniqueID());
516 522
517 std::unique_ptr<net::HttpCache::BackendFactory> main_backend( 523 std::unique_ptr<net::HttpCache::BackendFactory> main_backend(
518 new net::HttpCache::DefaultBackend( 524 new net::HttpCache::DefaultBackend(
519 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path, 525 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path,
520 lazy_params_->cache_max_size, 526 lazy_params_->cache_max_size,
521 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); 527 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)));
522 main_context_storage->set_http_network_session( 528 main_context_storage->set_http_network_session(
523 CreateHttpNetworkSession(*profile_params)); 529 CreateHttpNetworkSession(*profile_params));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // store. 575 // store.
570 net::URLRequestContext* extensions_context = extensions_request_context(); 576 net::URLRequestContext* extensions_context = extensions_request_context();
571 577
572 content::CookieStoreConfig cookie_config( 578 content::CookieStoreConfig cookie_config(
573 lazy_params_->extensions_cookie_path, 579 lazy_params_->extensions_cookie_path,
574 lazy_params_->session_cookie_mode, 580 lazy_params_->session_cookie_mode,
575 NULL, NULL); 581 NULL, NULL);
576 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); 582 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate();
577 // Enable cookies for chrome-extension URLs. 583 // Enable cookies for chrome-extension URLs.
578 cookie_config.cookieable_schemes.push_back(extensions::kExtensionScheme); 584 cookie_config.cookieable_schemes.push_back(extensions::kExtensionScheme);
585 cookie_config.channel_id_service = extensions_context->channel_id_service();
579 extensions_cookie_store_ = content::CreateCookieStore(cookie_config); 586 extensions_cookie_store_ = content::CreateCookieStore(cookie_config);
580 extensions_context->set_cookie_store(extensions_cookie_store_.get()); 587 extensions_context->set_cookie_store(extensions_cookie_store_.get());
581 } 588 }
582 589
583 net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext( 590 net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext(
584 net::URLRequestContext* main_context, 591 net::URLRequestContext* main_context,
585 const StoragePartitionDescriptor& partition_descriptor, 592 const StoragePartitionDescriptor& partition_descriptor,
586 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 593 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
587 protocol_handler_interceptor, 594 protocol_handler_interceptor,
588 content::ProtocolHandlerMap* protocol_handlers, 595 content::ProtocolHandlerMap* protocol_handlers,
(...skipping 15 matching lines...) Expand all
604 app_backend = net::HttpCache::DefaultBackend::InMemory(0); 611 app_backend = net::HttpCache::DefaultBackend::InMemory(0);
605 } else { 612 } else {
606 app_backend.reset(new net::HttpCache::DefaultBackend( 613 app_backend.reset(new net::HttpCache::DefaultBackend(
607 net::DISK_CACHE, ChooseCacheBackendType(), cache_path, 614 net::DISK_CACHE, ChooseCacheBackendType(), cache_path,
608 app_cache_max_size_, 615 app_cache_max_size_,
609 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); 616 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)));
610 } 617 }
611 618
612 std::unique_ptr<net::CookieStore> cookie_store; 619 std::unique_ptr<net::CookieStore> cookie_store;
613 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; 620 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db;
621 // Create a single task runner to use with the CookieStore and ChannelIDStore.
622 scoped_refptr<base::SequencedTaskRunner> cookie_background_task_runner =
623 base::CreateSequencedTaskRunnerWithTraits(
624 {base::MayBlock(), base::TaskPriority::BACKGROUND,
625 base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
614 if (partition_descriptor.in_memory) { 626 if (partition_descriptor.in_memory) {
615 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); 627 cookie_path = base::FilePath();
616 } else { 628 }
629 content::CookieStoreConfig cookie_config(
630 cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
631 nullptr, nullptr);
632 if (!partition_descriptor.in_memory) {
617 // Use an app-specific cookie store. 633 // Use an app-specific cookie store.
618 DCHECK(!cookie_path.empty()); 634 DCHECK(!cookie_path.empty());
619 635
620 // TODO(creis): We should have a cookie delegate for notifying the cookie 636 // TODO(creis): We should have a cookie delegate for notifying the cookie
621 // extensions API, but we need to update it to understand isolated apps 637 // extensions API, but we need to update it to understand isolated apps
622 // first. 638 // first.
623 content::CookieStoreConfig cookie_config(
624 cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
625 nullptr, nullptr);
626 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); 639 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate();
627 cookie_store = content::CreateCookieStore(cookie_config);
628 channel_id_db = new net::SQLiteChannelIDStore( 640 channel_id_db = new net::SQLiteChannelIDStore(
629 channel_id_path, 641 channel_id_path, cookie_background_task_runner);
630 base::CreateSequencedTaskRunnerWithTraits(
631 {base::MayBlock(), base::TaskPriority::BACKGROUND}));
632 } 642 }
633 std::unique_ptr<net::ChannelIDService> channel_id_service( 643 std::unique_ptr<net::ChannelIDService> channel_id_service(
634 new net::ChannelIDService( 644 new net::ChannelIDService(
635 new net::DefaultChannelIDStore(channel_id_db.get()))); 645 new net::DefaultChannelIDStore(channel_id_db.get())));
646 cookie_config.channel_id_service = channel_id_service.get();
647 cookie_config.background_task_runner = cookie_background_task_runner;
648 cookie_store = content::CreateCookieStore(cookie_config);
636 cookie_store->SetChannelIDServiceID(channel_id_service->GetUniqueID()); 649 cookie_store->SetChannelIDServiceID(channel_id_service->GetUniqueID());
637 650
638 // Build a new HttpNetworkSession that uses the new ChannelIDService. 651 // Build a new HttpNetworkSession that uses the new ChannelIDService.
639 // TODO(mmenke): It weird to combine state from 652 // TODO(mmenke): It weird to combine state from
640 // main_request_context_storage() objects and the argumet to this method, 653 // main_request_context_storage() objects and the argumet to this method,
641 // |main_context|. Remove |main_context| as an argument, and just use 654 // |main_context|. Remove |main_context| as an argument, and just use
642 // main_context() instead. 655 // main_context() instead.
643 net::HttpNetworkSession::Params network_params = 656 net::HttpNetworkSession::Params network_params =
644 main_request_context_storage()->http_network_session()->params(); 657 main_request_context_storage()->http_network_session()->params();
645 network_params.channel_id_service = channel_id_service.get(); 658 network_params.channel_id_service = channel_id_service.get();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 const base::Closure& completion) { 791 const base::Closure& completion) {
779 DCHECK_CURRENTLY_ON(BrowserThread::IO); 792 DCHECK_CURRENTLY_ON(BrowserThread::IO);
780 DCHECK(initialized()); 793 DCHECK(initialized());
781 794
782 DCHECK(transport_security_state()); 795 DCHECK(transport_security_state());
783 // Completes synchronously. 796 // Completes synchronously.
784 transport_security_state()->DeleteAllDynamicDataSince(time); 797 transport_security_state()->DeleteAllDynamicDataSince(time);
785 DCHECK(http_server_properties_manager_); 798 DCHECK(http_server_properties_manager_);
786 http_server_properties_manager_->Clear(completion); 799 http_server_properties_manager_->Clear(completion);
787 } 800 }
OLDNEW
« no previous file with comments | « chrome/browser/net/quota_policy_channel_id_store.cc ('k') | chrome/browser/safe_browsing/safe_browsing_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698