diff options
author | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 22:49:52 +0000 |
---|---|---|
committer | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 22:49:52 +0000 |
commit | ba2e465d364c573b530c3a14c99c2b377e5f626d (patch) | |
tree | 6345f9cef85ce55fceaaadbe7a97d2e5b62611b3 /chrome/service | |
parent | ebe11a5c6f543ed54e7c62c386f8933f954208d8 (diff) | |
download | chromium_src-ba2e465d364c573b530c3a14c99c2b377e5f626d.zip chromium_src-ba2e465d364c573b530c3a14c99c2b377e5f626d.tar.gz chromium_src-ba2e465d364c573b530c3a14c99c2b377e5f626d.tar.bz2 |
Revert 76612 - Service process fixes for Linux.
Linux requires that the proxy_config_service be created on the I/O
thread. Fortunately, ServiceURLRequestContextGetter was already thread safe ref
counted, so we lift creation of that and the (also, fortunately) thread safe
ref counted net::ProxyService up to service process initialization time. That
created proxy service now gets passed in to the dynamic creation of the
ServiceURLRequestContexts. Should have no effect on other platforms.
BUG=74226
TEST=Start Chromium on Linux with --enable-cloud-print-proxy, sign in, and examine ~/.config/chromium/Service State. With the fix, Service State properly contains the needed tokens to properly re-launch and be a proxy.
Review URL: http://codereview.chromium.org/6602041
TBR=scottbyer@chromium.org
Review URL: http://codereview.chromium.org/6606022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r-- | chrome/service/cloud_print/cloud_print_url_fetcher.cc | 4 | ||||
-rw-r--r-- | chrome/service/gaia/service_gaia_authenticator.cc | 7 | ||||
-rw-r--r-- | chrome/service/net/service_url_request_context.cc | 39 | ||||
-rw-r--r-- | chrome/service/net/service_url_request_context.h | 11 | ||||
-rw-r--r-- | chrome/service/service_process.cc | 9 | ||||
-rw-r--r-- | chrome/service/service_process.h | 5 |
6 files changed, 21 insertions, 54 deletions
diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher.cc b/chrome/service/cloud_print/cloud_print_url_fetcher.cc index 1482b50..0d81e17 100644 --- a/chrome/service/cloud_print/cloud_print_url_fetcher.cc +++ b/chrome/service/cloud_print/cloud_print_url_fetcher.cc @@ -10,7 +10,6 @@ #include "chrome/service/cloud_print/cloud_print_consts.h" #include "chrome/service/cloud_print/cloud_print_helpers.h" #include "chrome/service/net/service_url_request_context.h" -#include "chrome/service/service_process.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request_status.h" @@ -146,10 +145,11 @@ CloudPrintURLFetcher::~CloudPrintURLFetcher() {} URLRequestContextGetter* CloudPrintURLFetcher::GetRequestContextGetter() { ServiceURLRequestContextGetter* getter = - g_service_process->GetServiceURLRequestContextGetter(); + new ServiceURLRequestContextGetter(); // Now set up the user agent for cloudprint. std::string user_agent = getter->user_agent(); base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); getter->set_user_agent(user_agent); return getter; } + diff --git a/chrome/service/gaia/service_gaia_authenticator.cc b/chrome/service/gaia/service_gaia_authenticator.cc index af795a8..1f57626 100644 --- a/chrome/service/gaia/service_gaia_authenticator.cc +++ b/chrome/service/gaia/service_gaia_authenticator.cc @@ -6,7 +6,6 @@ #include "base/message_loop_proxy.h" #include "chrome/service/net/service_url_request_context.h" -#include "chrome/service/service_process.h" #include "googleurl/src/gurl.h" ServiceGaiaAuthenticator::ServiceGaiaAuthenticator( @@ -64,8 +63,9 @@ void ServiceGaiaAuthenticator::DoPost(const GURL& post_url, const std::string& post_body) { DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); URLFetcher* request = new URLFetcher(post_url, URLFetcher::POST, this); - request->set_request_context( - g_service_process->GetServiceURLRequestContextGetter()); + ServiceURLRequestContextGetter* context_getter = + new ServiceURLRequestContextGetter(); + request->set_request_context(context_getter); request->set_upload_data("application/x-www-form-urlencoded", post_body); request->Start(); } @@ -89,3 +89,4 @@ void ServiceGaiaAuthenticator::OnURLFetchComplete( http_post_completed_.Signal(); // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! } + diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc index 4f12f54..b09794e 100644 --- a/chrome/service/net/service_url_request_context.cc +++ b/chrome/service/net/service_url_request_context.cc @@ -104,12 +104,20 @@ std::string MakeUserAgentForServiceProcess() { } // namespace ServiceURLRequestContext::ServiceURLRequestContext( - const std::string& user_agent, - net::ProxyService* net_proxy_service) : user_agent_(user_agent) { + const std::string& user_agent) : user_agent_(user_agent) { set_host_resolver( net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, NULL, NULL)); - set_proxy_service(net_proxy_service); + DCHECK(g_service_process); + // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a + // MessageLoopProxy* instead of MessageLoop*. + // Also this needs to be created on the UI thread on Linux. Fix this. + net::ProxyConfigService * proxy_config_service = + net::ProxyService::CreateSystemProxyConfigService( + g_service_process->io_thread()->message_loop(), + g_service_process->file_thread()->message_loop()); + set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver( + proxy_config_service, 0u, NULL)); set_cert_verifier(new net::CertVerifier); set_dnsrr_resolver(new net::DnsRRResolver); set_ftp_transaction_factory(new net::FtpNetworkLayer(host_resolver())); @@ -156,23 +164,12 @@ ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() g_service_process->io_thread()->message_loop_proxy()) { // Build the default user agent. user_agent_ = MakeUserAgentForServiceProcess(); - -#if !defined(OS_MACOSX) - // Create the proxy service now, at initialization time, on the main thread. - // The Mac needs it created later, on the I/O thread. - CreateProxyService(); -#endif } net::URLRequestContext* ServiceURLRequestContextGetter::GetURLRequestContext() { -#if defined(OS_MACOSX) - if (!proxy_service_) - CreateProxyService(); -#endif if (!url_request_context_) - url_request_context_ = new ServiceURLRequestContext(user_agent_, - proxy_service_); + url_request_context_ = new ServiceURLRequestContext(user_agent_); return url_request_context_; } @@ -182,15 +179,3 @@ ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { } ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} - -void ServiceURLRequestContextGetter::CreateProxyService() { - // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a - // MessageLoopProxy* instead of MessageLoop*. - DCHECK(g_service_process); - net::ProxyConfigService * proxy_config_service = - net::ProxyService::CreateSystemProxyConfigService( - g_service_process->io_thread()->message_loop(), - g_service_process->file_thread()->message_loop()); - proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver( - proxy_config_service, 0u, NULL); -} diff --git a/chrome/service/net/service_url_request_context.h b/chrome/service/net/service_url_request_context.h index becc21a..7ffda3c 100644 --- a/chrome/service/net/service_url_request_context.h +++ b/chrome/service/net/service_url_request_context.h @@ -31,8 +31,7 @@ class MessageLoopProxy; // class ServiceURLRequestContext : public net::URLRequestContext { public: - explicit ServiceURLRequestContext(const std::string& user_agent, - net::ProxyService* net_proxy_service); + explicit ServiceURLRequestContext(const std::string& user_agent); // Overridden from net::URLRequestContext: virtual const std::string& GetUserAgent(const GURL& url) const; @@ -46,6 +45,8 @@ class ServiceURLRequestContext : public net::URLRequestContext { class ServiceURLRequestContextGetter : public URLRequestContextGetter { public: + ServiceURLRequestContextGetter(); + virtual net::URLRequestContext* GetURLRequestContext(); virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; @@ -55,18 +56,12 @@ class ServiceURLRequestContextGetter : public URLRequestContextGetter { std::string user_agent() const { return user_agent_; } - private: - friend class ServiceProcess; - ServiceURLRequestContextGetter(); virtual ~ServiceURLRequestContextGetter(); - void CreateProxyService(); - std::string user_agent_; scoped_refptr<net::URLRequestContext> url_request_context_; scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; - scoped_refptr<net::ProxyService> proxy_service_; }; #endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc index 1335936..6a8b689 100644 --- a/chrome/service/service_process.cc +++ b/chrome/service/service_process.cc @@ -23,7 +23,6 @@ #include "chrome/common/pref_names.h" #include "chrome/common/service_process_util.h" #include "chrome/service/cloud_print/cloud_print_proxy.h" -#include "chrome/service/net/service_url_request_context.h" #include "chrome/service/service_ipc_server.h" #include "chrome/service/service_process_prefs.h" #include "grit/chromium_strings.h" @@ -142,8 +141,6 @@ bool ServiceProcess::Initialize(MessageLoopForUI* message_loop, return false; } - request_context_getter_ = new ServiceURLRequestContextGetter(); - // See if we have been suppiled an LSID in the command line. This LSID will // override the credentials we use for Cloud Print. std::string lsid = command_line.GetSwitchValueASCII( @@ -309,12 +306,6 @@ void ServiceProcess::OnChromotingHostDisabled() { OnServiceDisabled(); } -ServiceURLRequestContextGetter* -ServiceProcess::GetServiceURLRequestContextGetter() { - DCHECK(request_context_getter_.get()); - return request_context_getter_.get(); -} - void ServiceProcess::OnServiceEnabled() { enabled_services_++; if ((1 == enabled_services_) && diff --git a/chrome/service/service_process.h b/chrome/service/service_process.h index a3b8cdc..7c2606c 100644 --- a/chrome/service/service_process.h +++ b/chrome/service/service_process.h @@ -19,7 +19,6 @@ class ServiceProcessPrefs; class ServiceIPCServer; class CommandLine; -class ServiceURLRequestContextGetter; namespace net { class NetworkChangeNotifier; @@ -99,8 +98,6 @@ class ServiceProcess : public CloudPrintProxy::Client, } #endif - ServiceURLRequestContextGetter* GetServiceURLRequestContextGetter(); - private: // Schedule a call to ShutdownIfNeeded. void ScheduleShutdownCheck(); @@ -133,8 +130,6 @@ class ServiceProcess : public CloudPrintProxy::Client, // Speficies whether a product update is available. bool update_available_; - scoped_refptr<ServiceURLRequestContextGetter> request_context_getter_; - #if defined(ENABLE_REMOTING) scoped_refptr<remoting::ChromotingHostManager> remoting_host_manager_; #endif |