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

Side by Side Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 5430004: Refactored cookies persistent store clean-up on shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit test and moved flag to the persistence store itself. Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/net/chrome_url_request_context.h" 5 #include "chrome/browser/net/chrome_url_request_context.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 context->set_ftp_transaction_factory( 309 context->set_ftp_transaction_factory(
310 new net::FtpNetworkLayer(context->host_resolver())); 310 new net::FtpNetworkLayer(context->host_resolver()));
311 311
312 // setup cookie store 312 // setup cookie store
313 if (!context->cookie_store()) { 313 if (!context->cookie_store()) {
314 DCHECK(!cookie_store_path_.empty()); 314 DCHECK(!cookie_store_path_.empty());
315 315
316 scoped_refptr<SQLitePersistentCookieStore> cookie_db = 316 scoped_refptr<SQLitePersistentCookieStore> cookie_db =
317 new SQLitePersistentCookieStore(cookie_store_path_); 317 new SQLitePersistentCookieStore(cookie_store_path_);
318 cookie_db->SetClearLocalStateOnExit(clear_local_state_on_exit_);
318 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), 319 context->set_cookie_store(new net::CookieMonster(cookie_db.get(),
319 cookie_monster_delegate_)); 320 cookie_monster_delegate_));
321
jochen (gone - plz use gerrit) 2010/12/02 15:09:51 nit no empty line plz
pastarmovj 2010/12/02 16:29:07 Done.
320 } 322 }
321 323
322 context->set_cookie_policy( 324 context->set_cookie_policy(
323 new ChromeCookiePolicy(host_content_settings_map_)); 325 new ChromeCookiePolicy(host_content_settings_map_));
324 326
325 appcache_service_->set_request_context(context); 327 appcache_service_->set_request_context(context);
326 328
327 context->set_net_log(io_thread_globals->net_log.get()); 329 context->set_net_log(io_thread_globals->net_log.get());
328 return context; 330 return context;
329 } 331 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 accept_language)); 700 accept_language));
699 } else if (*pref_name_in == prefs::kDefaultCharset) { 701 } else if (*pref_name_in == prefs::kDefaultCharset) {
700 std::string default_charset = 702 std::string default_charset =
701 prefs->GetString(prefs::kDefaultCharset); 703 prefs->GetString(prefs::kDefaultCharset);
702 BrowserThread::PostTask( 704 BrowserThread::PostTask(
703 BrowserThread::IO, FROM_HERE, 705 BrowserThread::IO, FROM_HERE,
704 NewRunnableMethod( 706 NewRunnableMethod(
705 this, 707 this,
706 &ChromeURLRequestContextGetter::OnDefaultCharsetChange, 708 &ChromeURLRequestContextGetter::OnDefaultCharsetChange,
707 default_charset)); 709 default_charset));
710 } else if (*pref_name_in == prefs::kClearSiteDataOnExit) {
711 bool clear_site_data =
712 prefs->GetBoolean(prefs::kClearSiteDataOnExit);
713 BrowserThread::PostTask(
714 BrowserThread::IO, FROM_HERE,
715 NewRunnableMethod(
716 this,
717 &ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange,
718 clear_site_data));
708 } 719 }
709 } else { 720 } else {
710 NOTREACHED(); 721 NOTREACHED();
711 } 722 }
712 } 723 }
713 724
714 void ChromeURLRequestContextGetter::RegisterPrefsObserver(Profile* profile) { 725 void ChromeURLRequestContextGetter::RegisterPrefsObserver(Profile* profile) {
715 CheckCurrentlyOnMainThread(); 726 CheckCurrentlyOnMainThread();
716 727
717 registrar_.Init(profile->GetPrefs()); 728 registrar_.Init(profile->GetPrefs());
718 registrar_.Add(prefs::kAcceptLanguages, this); 729 registrar_.Add(prefs::kAcceptLanguages, this);
719 registrar_.Add(prefs::kDefaultCharset, this); 730 registrar_.Add(prefs::kDefaultCharset, this);
731 registrar_.Add(prefs::kClearSiteDataOnExit, this);
720 } 732 }
721 733
722 // static 734 // static
723 ChromeURLRequestContextGetter* 735 ChromeURLRequestContextGetter*
724 ChromeURLRequestContextGetter::CreateRequestContextForMedia( 736 ChromeURLRequestContextGetter::CreateRequestContextForMedia(
725 Profile* profile, const FilePath& disk_cache_path, int cache_size, 737 Profile* profile, const FilePath& disk_cache_path, int cache_size,
726 bool off_the_record) { 738 bool off_the_record) {
727 return new ChromeURLRequestContextGetter( 739 return new ChromeURLRequestContextGetter(
728 profile, 740 profile,
729 new FactoryForMedia(profile, 741 new FactoryForMedia(profile,
730 disk_cache_path, 742 disk_cache_path,
731 cache_size, 743 cache_size,
732 off_the_record)); 744 off_the_record));
733 } 745 }
734 746
735 void ChromeURLRequestContextGetter::OnAcceptLanguageChange( 747 void ChromeURLRequestContextGetter::OnAcceptLanguageChange(
736 const std::string& accept_language) { 748 const std::string& accept_language) {
737 GetIOContext()->OnAcceptLanguageChange(accept_language); 749 GetIOContext()->OnAcceptLanguageChange(accept_language);
738 } 750 }
739 751
740 void ChromeURLRequestContextGetter::OnDefaultCharsetChange( 752 void ChromeURLRequestContextGetter::OnDefaultCharsetChange(
741 const std::string& default_charset) { 753 const std::string& default_charset) {
742 GetIOContext()->OnDefaultCharsetChange(default_charset); 754 GetIOContext()->OnDefaultCharsetChange(default_charset);
743 } 755 }
744 756
757 void ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange(
758 bool clear_site_data) {
759 GetCookieStore()->GetCookieMonster()->GetPersistentCookieStore()->
760 SetClearLocalStateOnExit(clear_site_data);
761 }
762
745 void ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper( 763 void ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper(
746 base::WaitableEvent* completion, 764 base::WaitableEvent* completion,
747 net::CookieStore** result) { 765 net::CookieStore** result) {
748 // Note that CookieStore is refcounted, yet we do not add a reference. 766 // Note that CookieStore is refcounted, yet we do not add a reference.
749 *result = GetURLRequestContext()->cookie_store(); 767 *result = GetURLRequestContext()->cookie_store();
750 completion->Signal(); 768 completion->Signal();
751 } 769 }
752 770
753 // ---------------------------------------------------------------------------- 771 // ----------------------------------------------------------------------------
754 // ChromeURLRequestContext 772 // ChromeURLRequestContext
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 io_thread_(g_browser_process->io_thread()) { 893 io_thread_(g_browser_process->io_thread()) {
876 CheckCurrentlyOnMainThread(); 894 CheckCurrentlyOnMainThread();
877 PrefService* prefs = profile->GetPrefs(); 895 PrefService* prefs = profile->GetPrefs();
878 896
879 // Set up Accept-Language and Accept-Charset header values 897 // Set up Accept-Language and Accept-Charset header values
880 accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader( 898 accept_language_ = net::HttpUtil::GenerateAcceptLanguageHeader(
881 prefs->GetString(prefs::kAcceptLanguages)); 899 prefs->GetString(prefs::kAcceptLanguages));
882 std::string default_charset = prefs->GetString(prefs::kDefaultCharset); 900 std::string default_charset = prefs->GetString(prefs::kDefaultCharset);
883 accept_charset_ = 901 accept_charset_ =
884 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset); 902 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset);
903 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit);
885 904
886 // At this point, we don't know the charset of the referring page 905 // At this point, we don't know the charset of the referring page
887 // where a url request originates from. This is used to get a suggested 906 // where a url request originates from. This is used to get a suggested
888 // filename from Content-Disposition header made of raw 8bit characters. 907 // filename from Content-Disposition header made of raw 8bit characters.
889 // Down the road, it can be overriden if it becomes known (for instance, 908 // Down the road, it can be overriden if it becomes known (for instance,
890 // when download request is made through the context menu in a web page). 909 // when download request is made through the context menu in a web page).
891 // At the moment, it'll remain 'undeterministic' when a user 910 // At the moment, it'll remain 'undeterministic' when a user
892 // types a URL in the omnibar or click on a download link in a page. 911 // types a URL in the omnibar or click on a download link in a page.
893 // For the latter, we need a change on the webkit-side. 912 // For the latter, we need a change on the webkit-side.
894 // We initialize it to the default charset here and a user will 913 // We initialize it to the default charset here and a user will
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 context->set_host_zoom_map(host_zoom_map_); 951 context->set_host_zoom_map(host_zoom_map_);
933 context->set_transport_security_state( 952 context->set_transport_security_state(
934 transport_security_state_); 953 transport_security_state_);
935 context->set_ssl_config_service(ssl_config_service_); 954 context->set_ssl_config_service(ssl_config_service_);
936 context->set_appcache_service(appcache_service_); 955 context->set_appcache_service(appcache_service_);
937 context->set_database_tracker(database_tracker_); 956 context->set_database_tracker(database_tracker_);
938 context->set_blob_storage_context(blob_storage_context_); 957 context->set_blob_storage_context(blob_storage_context_);
939 context->set_browser_file_system_context(browser_file_system_context_); 958 context->set_browser_file_system_context(browser_file_system_context_);
940 context->set_extension_info_map(extension_info_map_); 959 context->set_extension_info_map(extension_info_map_);
941 } 960 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698