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

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

Issue 342068: Third patch in getting rid of caching MessageLoop pointers and always using C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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
« no previous file with comments | « chrome/browser/metrics/metrics_service_uitest.cc ('k') | chrome/browser/net/dns_global.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/privacy_blacklist/blacklist.h" 10 #include "chrome/browser/privacy_blacklist/blacklist.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const CommandLine& command_line) { 111 const CommandLine& command_line) {
112 // The linux gconf-based proxy settings getter relies on being initialized 112 // The linux gconf-based proxy settings getter relies on being initialized
113 // from the UI thread. 113 // from the UI thread.
114 CheckCurrentlyOnMainThread(); 114 CheckCurrentlyOnMainThread();
115 115
116 scoped_ptr<net::ProxyConfig> proxy_config_from_cmd_line( 116 scoped_ptr<net::ProxyConfig> proxy_config_from_cmd_line(
117 CreateProxyConfig(command_line)); 117 CreateProxyConfig(command_line));
118 118
119 if (!proxy_config_from_cmd_line.get()) { 119 if (!proxy_config_from_cmd_line.get()) {
120 // Use system settings. 120 // Use system settings.
121 // TODO(port): the IO and FILE message loops are only used by Linux. Can
122 // that code be moved to chrome/browser instead of being in net, so that it
123 // can use ChromeThread instead of raw MessageLoop pointers? See bug 25354.
121 return net::ProxyService::CreateSystemProxyConfigService( 124 return net::ProxyService::CreateSystemProxyConfigService(
122 g_browser_process->io_thread()->message_loop(), 125 g_browser_process->io_thread()->message_loop(),
123 g_browser_process->file_thread()->message_loop()); 126 g_browser_process->file_thread()->message_loop());
124 } 127 }
125 128
126 // Otherwise use the fixed settings from the command line. 129 // Otherwise use the fixed settings from the command line.
127 return new net::ProxyConfigServiceFixed(*proxy_config_from_cmd_line.get()); 130 return new net::ProxyConfigServiceFixed(*proxy_config_from_cmd_line.get());
128 } 131 }
129 132
130 // Create a proxy service according to the options on command line. 133 // Create a proxy service according to the options on command line.
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 const NotificationDetails& details) { 663 const NotificationDetails& details) {
661 CheckCurrentlyOnMainThread(); 664 CheckCurrentlyOnMainThread();
662 665
663 if (NotificationType::PREF_CHANGED == type) { 666 if (NotificationType::PREF_CHANGED == type) {
664 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); 667 std::wstring* pref_name_in = Details<std::wstring>(details).ptr();
665 PrefService* prefs = Source<PrefService>(source).ptr(); 668 PrefService* prefs = Source<PrefService>(source).ptr();
666 DCHECK(pref_name_in && prefs); 669 DCHECK(pref_name_in && prefs);
667 if (*pref_name_in == prefs::kAcceptLanguages) { 670 if (*pref_name_in == prefs::kAcceptLanguages) {
668 std::string accept_language = 671 std::string accept_language =
669 WideToASCII(prefs->GetString(prefs::kAcceptLanguages)); 672 WideToASCII(prefs->GetString(prefs::kAcceptLanguages));
670 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 673 ChromeThread::PostTask(
674 ChromeThread::IO, FROM_HERE,
671 NewRunnableMethod( 675 NewRunnableMethod(
672 this, 676 this,
673 &ChromeURLRequestContextGetter::OnAcceptLanguageChange, 677 &ChromeURLRequestContextGetter::OnAcceptLanguageChange,
674 accept_language)); 678 accept_language));
675 } else if (*pref_name_in == prefs::kCookieBehavior) { 679 } else if (*pref_name_in == prefs::kCookieBehavior) {
676 net::CookiePolicy::Type policy_type = net::CookiePolicy::FromInt( 680 net::CookiePolicy::Type policy_type = net::CookiePolicy::FromInt(
677 prefs_->GetInteger(prefs::kCookieBehavior)); 681 prefs_->GetInteger(prefs::kCookieBehavior));
678 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 682 ChromeThread::PostTask(
683 ChromeThread::IO, FROM_HERE,
679 NewRunnableMethod( 684 NewRunnableMethod(
680 this, 685 this,
681 &ChromeURLRequestContextGetter::OnCookiePolicyChange, 686 &ChromeURLRequestContextGetter::OnCookiePolicyChange,
682 policy_type)); 687 policy_type));
683 } else if (*pref_name_in == prefs::kDefaultCharset) { 688 } else if (*pref_name_in == prefs::kDefaultCharset) {
684 std::string default_charset = 689 std::string default_charset =
685 WideToASCII(prefs->GetString(prefs::kDefaultCharset)); 690 WideToASCII(prefs->GetString(prefs::kDefaultCharset));
686 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 691 ChromeThread::PostTask(
692 ChromeThread::IO, FROM_HERE,
687 NewRunnableMethod( 693 NewRunnableMethod(
688 this, 694 this,
689 &ChromeURLRequestContextGetter::OnDefaultCharsetChange, 695 &ChromeURLRequestContextGetter::OnDefaultCharsetChange,
690 default_charset)); 696 default_charset));
691 } 697 }
692 } else { 698 } else {
693 NOTREACHED(); 699 NOTREACHED();
694 } 700 }
695 } 701 }
696 702
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) 868 if (ChromeThread::CurrentlyOn(ChromeThread::IO))
863 return GetURLRequestContext()->cookie_store(); 869 return GetURLRequestContext()->cookie_store();
864 870
865 // If we aren't running on the IO thread, we cannot call 871 // If we aren't running on the IO thread, we cannot call
866 // GetURLRequestContext(). Instead we will post a task to the IO loop 872 // GetURLRequestContext(). Instead we will post a task to the IO loop
867 // and wait for it to complete. 873 // and wait for it to complete.
868 874
869 base::WaitableEvent completion(false, false); 875 base::WaitableEvent completion(false, false);
870 net::CookieStore* result = NULL; 876 net::CookieStore* result = NULL;
871 877
872 g_browser_process->io_thread()->message_loop()->PostTask( 878 ChromeThread::PostTask(
873 FROM_HERE, 879 ChromeThread::IO, FROM_HERE,
874 NewRunnableMethod(this, 880 NewRunnableMethod(this,
875 &ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper, 881 &ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper,
876 &completion, 882 &completion,
877 &result)); 883 &result));
878 884
879 completion.Wait(); 885 completion.Wait();
880 DCHECK(result); 886 DCHECK(result);
881 return result; 887 return result;
882 } 888 }
883 889
884 void ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper( 890 void ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper(
885 base::WaitableEvent* completion, 891 base::WaitableEvent* completion,
886 net::CookieStore** result) { 892 net::CookieStore** result) {
887 // Note that CookieStore is refcounted, yet we do not add a reference. 893 // Note that CookieStore is refcounted, yet we do not add a reference.
888 *result = GetURLRequestContext()->cookie_store(); 894 *result = GetURLRequestContext()->cookie_store();
889 completion->Signal(); 895 completion->Signal();
890 } 896 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service_uitest.cc ('k') | chrome/browser/net/dns_global.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698