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

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: Add missing background task runners 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 main_context->set_ct_policy_enforcer( 483 main_context->set_ct_policy_enforcer(
484 io_thread_globals->ct_policy_enforcer.get()); 484 io_thread_globals->ct_policy_enforcer.get());
485 485
486 main_context->set_net_log(io_thread->net_log()); 486 main_context->set_net_log(io_thread->net_log());
487 487
488 main_context->set_http_auth_handler_factory( 488 main_context->set_http_auth_handler_factory(
489 io_thread_globals->http_auth_handler_factory.get()); 489 io_thread_globals->http_auth_handler_factory.get());
490 490
491 main_context->set_proxy_service(proxy_service()); 491 main_context->set_proxy_service(proxy_service());
492 492
493 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
mattm 2017/05/17 23:28:09 may want to add comment or different naming to con
nharper 2017/05/18 00:45:53 Done.
494 base::CreateSequencedTaskRunnerWithTraits(
495 {base::MayBlock(), base::TaskPriority::BACKGROUND,
496 base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
497
498 // Set up server bound cert service.
499 DCHECK(!lazy_params_->channel_id_path.empty());
500 scoped_refptr<QuotaPolicyChannelIDStore> channel_id_db =
501 new QuotaPolicyChannelIDStore(lazy_params_->channel_id_path,
502 background_task_runner,
503 lazy_params_->special_storage_policy.get());
504 main_context_storage->set_channel_id_service(
505 base::MakeUnique<net::ChannelIDService>(
506 new net::DefaultChannelIDStore(channel_id_db.get())));
507
493 // Set up cookie store. 508 // Set up cookie store.
494 DCHECK(!lazy_params_->cookie_path.empty()); 509 DCHECK(!lazy_params_->cookie_path.empty());
495 510
496 content::CookieStoreConfig cookie_config( 511 content::CookieStoreConfig cookie_config(
497 lazy_params_->cookie_path, lazy_params_->session_cookie_mode, 512 lazy_params_->cookie_path, lazy_params_->session_cookie_mode,
498 lazy_params_->special_storage_policy.get(), 513 lazy_params_->special_storage_policy.get(),
499 profile_params->cookie_monster_delegate.get()); 514 profile_params->cookie_monster_delegate.get());
500 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); 515 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate();
516 cookie_config.channel_id_service = main_context->channel_id_service();
mattm 2017/05/17 23:28:08 Should this also be done in android_webview/browse
nharper 2017/05/18 00:45:53 android webview has a CookieManager::GetCookieStor
517 cookie_config.background_task_runner = background_task_runner;
501 main_context_storage->set_cookie_store( 518 main_context_storage->set_cookie_store(
502 content::CreateCookieStore(cookie_config)); 519 content::CreateCookieStore(cookie_config));
503 520
504 // Set up server bound cert service.
505 DCHECK(!lazy_params_->channel_id_path.empty());
506 scoped_refptr<QuotaPolicyChannelIDStore> channel_id_db =
507 new QuotaPolicyChannelIDStore(
508 lazy_params_->channel_id_path,
509 base::CreateSequencedTaskRunnerWithTraits(
510 {base::MayBlock(), base::TaskPriority::BACKGROUND}),
511 lazy_params_->special_storage_policy.get());
512 main_context_storage->set_channel_id_service(
513 base::MakeUnique<net::ChannelIDService>(
514 new net::DefaultChannelIDStore(channel_id_db.get())));
515
516 main_context->cookie_store()->SetChannelIDServiceID( 521 main_context->cookie_store()->SetChannelIDServiceID(
mattm 2017/05/17 23:28:09 Seems like this could be obviated as ChannelIDServ
nharper 2017/05/18 00:45:53 They should get merged together - I'd prefer to po
517 main_context->channel_id_service()->GetUniqueID()); 522 main_context->channel_id_service()->GetUniqueID());
518 523
519 std::unique_ptr<net::HttpCache::BackendFactory> main_backend( 524 std::unique_ptr<net::HttpCache::BackendFactory> main_backend(
520 new net::HttpCache::DefaultBackend( 525 new net::HttpCache::DefaultBackend(
521 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path, 526 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path,
522 lazy_params_->cache_max_size, 527 lazy_params_->cache_max_size,
523 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); 528 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)));
524 main_context_storage->set_http_network_session( 529 main_context_storage->set_http_network_session(
525 CreateHttpNetworkSession(*profile_params)); 530 CreateHttpNetworkSession(*profile_params));
526 main_context_storage->set_http_transaction_factory(CreateMainHttpFactory( 531 main_context_storage->set_http_transaction_factory(CreateMainHttpFactory(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 583
579 extensions_context->set_net_log(io_thread->net_log()); 584 extensions_context->set_net_log(io_thread->net_log());
580 585
581 content::CookieStoreConfig cookie_config( 586 content::CookieStoreConfig cookie_config(
582 lazy_params_->extensions_cookie_path, 587 lazy_params_->extensions_cookie_path,
583 lazy_params_->session_cookie_mode, 588 lazy_params_->session_cookie_mode,
584 NULL, NULL); 589 NULL, NULL);
585 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); 590 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate();
586 // Enable cookies for chrome-extension URLs. 591 // Enable cookies for chrome-extension URLs.
587 cookie_config.cookieable_schemes.push_back(extensions::kExtensionScheme); 592 cookie_config.cookieable_schemes.push_back(extensions::kExtensionScheme);
593 cookie_config.channel_id_service = extensions_context->channel_id_service();
588 extensions_cookie_store_ = content::CreateCookieStore(cookie_config); 594 extensions_cookie_store_ = content::CreateCookieStore(cookie_config);
589 extensions_context->set_cookie_store(extensions_cookie_store_.get()); 595 extensions_context->set_cookie_store(extensions_cookie_store_.get());
590 if (extensions_context->channel_id_service()) { 596 if (extensions_context->channel_id_service()) {
591 extensions_cookie_store_->SetChannelIDServiceID( 597 extensions_cookie_store_->SetChannelIDServiceID(
592 extensions_context->channel_id_service()->GetUniqueID()); 598 extensions_context->channel_id_service()->GetUniqueID());
593 } 599 }
594 600
595 std::unique_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( 601 std::unique_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory(
596 new net::URLRequestJobFactoryImpl()); 602 new net::URLRequestJobFactoryImpl());
597 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. 603 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 app_backend = net::HttpCache::DefaultBackend::InMemory(0); 638 app_backend = net::HttpCache::DefaultBackend::InMemory(0);
633 } else { 639 } else {
634 app_backend.reset(new net::HttpCache::DefaultBackend( 640 app_backend.reset(new net::HttpCache::DefaultBackend(
635 net::DISK_CACHE, ChooseCacheBackendType(), cache_path, 641 net::DISK_CACHE, ChooseCacheBackendType(), cache_path,
636 app_cache_max_size_, 642 app_cache_max_size_,
637 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); 643 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)));
638 } 644 }
639 645
640 std::unique_ptr<net::CookieStore> cookie_store; 646 std::unique_ptr<net::CookieStore> cookie_store;
641 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; 647 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db;
648 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
mattm 2017/05/17 23:28:09 same
nharper 2017/05/18 00:45:53 Done.
649 base::CreateSequencedTaskRunnerWithTraits(
650 {base::MayBlock(), base::TaskPriority::BACKGROUND,
651 base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
642 if (partition_descriptor.in_memory) { 652 if (partition_descriptor.in_memory) {
643 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); 653 cookie_path = base::FilePath();
644 } else { 654 }
655 content::CookieStoreConfig cookie_config(
656 cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
657 nullptr, nullptr);
658 if (!partition_descriptor.in_memory) {
645 // Use an app-specific cookie store. 659 // Use an app-specific cookie store.
646 DCHECK(!cookie_path.empty()); 660 DCHECK(!cookie_path.empty());
647 661
648 // TODO(creis): We should have a cookie delegate for notifying the cookie 662 // TODO(creis): We should have a cookie delegate for notifying the cookie
649 // extensions API, but we need to update it to understand isolated apps 663 // extensions API, but we need to update it to understand isolated apps
650 // first. 664 // first.
651 content::CookieStoreConfig cookie_config(
652 cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
653 nullptr, nullptr);
654 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); 665 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate();
655 cookie_store = content::CreateCookieStore(cookie_config); 666 channel_id_db =
656 channel_id_db = new net::SQLiteChannelIDStore( 667 new net::SQLiteChannelIDStore(channel_id_path, background_task_runner);
657 channel_id_path,
658 base::CreateSequencedTaskRunnerWithTraits(
659 {base::MayBlock(), base::TaskPriority::BACKGROUND}));
660 } 668 }
661 std::unique_ptr<net::ChannelIDService> channel_id_service( 669 std::unique_ptr<net::ChannelIDService> channel_id_service(
662 new net::ChannelIDService( 670 new net::ChannelIDService(
663 new net::DefaultChannelIDStore(channel_id_db.get()))); 671 new net::DefaultChannelIDStore(channel_id_db.get())));
672 cookie_config.channel_id_service = channel_id_service.get();
673 cookie_config.background_task_runner = background_task_runner;
674 cookie_store = content::CreateCookieStore(cookie_config);
664 cookie_store->SetChannelIDServiceID(channel_id_service->GetUniqueID()); 675 cookie_store->SetChannelIDServiceID(channel_id_service->GetUniqueID());
665 676
666 // Build a new HttpNetworkSession that uses the new ChannelIDService. 677 // Build a new HttpNetworkSession that uses the new ChannelIDService.
667 // TODO(mmenke): It weird to combine state from 678 // TODO(mmenke): It weird to combine state from
668 // main_request_context_storage() objects and the argumet to this method, 679 // main_request_context_storage() objects and the argumet to this method,
669 // |main_context|. Remove |main_context| as an argument, and just use 680 // |main_context|. Remove |main_context| as an argument, and just use
670 // main_context() instead. 681 // main_context() instead.
671 net::HttpNetworkSession::Params network_params = 682 net::HttpNetworkSession::Params network_params =
672 main_request_context_storage()->http_network_session()->params(); 683 main_request_context_storage()->http_network_session()->params();
673 network_params.channel_id_service = channel_id_service.get(); 684 network_params.channel_id_service = channel_id_service.get();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 const base::Closure& completion) { 817 const base::Closure& completion) {
807 DCHECK_CURRENTLY_ON(BrowserThread::IO); 818 DCHECK_CURRENTLY_ON(BrowserThread::IO);
808 DCHECK(initialized()); 819 DCHECK(initialized());
809 820
810 DCHECK(transport_security_state()); 821 DCHECK(transport_security_state());
811 // Completes synchronously. 822 // Completes synchronously.
812 transport_security_state()->DeleteAllDynamicDataSince(time); 823 transport_security_state()->DeleteAllDynamicDataSince(time);
813 DCHECK(http_server_properties_manager_); 824 DCHECK(http_server_properties_manager_);
814 http_server_properties_manager_->Clear(completion); 825 http_server_properties_manager_->Clear(completion);
815 } 826 }
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