diff options
29 files changed, 211 insertions, 213 deletions
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc index fed036e..9caff33 100644 --- a/chrome/browser/browsing_data/browsing_data_remover.cc +++ b/chrome/browser/browsing_data/browsing_data_remover.cc @@ -26,7 +26,6 @@ #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/media/media_device_id_salt.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/predictor.h" #include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/predictors/logged_in_predictor_table.h" diff --git a/chrome/browser/chrome_net_benchmarking_message_filter.cc b/chrome/browser/chrome_net_benchmarking_message_filter.cc index 1b01f1d..c3d5404 100644 --- a/chrome/browser/chrome_net_benchmarking_message_filter.cc +++ b/chrome/browser/chrome_net_benchmarking_message_filter.cc @@ -9,7 +9,6 @@ #include "base/command_line.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/predictor.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/benchmarking_messages.h" @@ -19,6 +18,8 @@ #include "net/dns/host_cache.h" #include "net/dns/host_resolver.h" #include "net/http/http_cache.h" +#include "net/url_request/url_request_context.h" +#include "net/url_request/url_request_context_getter.h" namespace { diff --git a/chrome/browser/chromeos/login/auth/auth_prewarmer.cc b/chrome/browser/chromeos/login/auth/auth_prewarmer.cc index d187dcd..50bd338 100644 --- a/chrome/browser/chromeos/login/auth/auth_prewarmer.cc +++ b/chrome/browser/chromeos/login/auth/auth_prewarmer.cc @@ -6,12 +6,13 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/preconnect.h" +#include "chrome/browser/profiles/profile.h" #include "chromeos/network/network_handler.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/notification_source.h" #include "google_apis/gaia/gaia_urls.h" #include "url/gurl.h" diff --git a/chrome/browser/chromeos/login/signin/merge_session_throttle.cc b/chrome/browser/chromeos/login/signin/merge_session_throttle.cc index ddc90eb..ce9b7a7 100644 --- a/chrome/browser/chromeos/login/signin/merge_session_throttle.cc +++ b/chrome/browser/chromeos/login/signin/merge_session_throttle.cc @@ -18,7 +18,6 @@ #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" #include "chrome/browser/chromeos/login/users/user_manager.h" #include "chrome/browser/chromeos/login/users/user_manager.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/common/url_constants.h" #include "components/google/core/browser/google_util.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index bdcccfd..f8de09a 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -960,7 +960,7 @@ void ExtensionService::RecordPermissionMessagesHistogram( } void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { - // The ChromeURLRequestContexts need to be first to know that the extension + // The URLRequestContexts need to be first to know that the extension // was loaded, otherwise a race can arise where a renderer that is created // for the extension may try to load an extension URL with an extension id // that the request context doesn't yet know about. The profile is responsible diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 3c632ee..4c98ff1 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -30,7 +30,6 @@ #include "chrome/browser/net/async_dns_field_trial.h" #include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/net/chrome_network_delegate.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/connect_interceptor.h" #include "chrome/browser/net/dns_probe_service.h" #include "chrome/browser/net/pref_proxy_config_tracker.h" @@ -73,6 +72,8 @@ #include "net/url_request/ftp_protocol_handler.h" #include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_fetcher.h" +#include "net/url_request/url_request_context.h" +#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_throttler_manager.h" #include "url/url_constants.h" diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context_getter.cc index e5f605e..748a229 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context_getter.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/net/chrome_url_request_context.h" +#include "chrome/browser/net/chrome_url_request_context_getter.h" #include "base/bind.h" #include "base/compiler_specific.h" @@ -24,7 +24,7 @@ class ChromeURLRequestContextFactory { virtual ~ChromeURLRequestContextFactory() {} // Called to create a new instance (will only be called once). - virtual ChromeURLRequestContext* Create() = 0; + virtual net::URLRequestContext* Create() = 0; protected: DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); @@ -36,7 +36,7 @@ namespace { // Helper factories // ---------------------------------------------------------------------------- -// Factory that creates the main ChromeURLRequestContext. +// Factory that creates the main URLRequestContext. class FactoryForMain : public ChromeURLRequestContextFactory { public: FactoryForMain( @@ -48,7 +48,7 @@ class FactoryForMain : public ChromeURLRequestContextFactory { std::swap(protocol_handlers_, *protocol_handlers); } - virtual ChromeURLRequestContext* Create() OVERRIDE { + virtual net::URLRequestContext* Create() OVERRIDE { profile_io_data_->Init(&protocol_handlers_, request_interceptors_.Pass()); return profile_io_data_->GetMainRequestContext(); } @@ -59,13 +59,13 @@ class FactoryForMain : public ChromeURLRequestContextFactory { content::URLRequestInterceptorScopedVector request_interceptors_; }; -// Factory that creates the ChromeURLRequestContext for extensions. +// Factory that creates the URLRequestContext for extensions. class FactoryForExtensions : public ChromeURLRequestContextFactory { public: explicit FactoryForExtensions(const ProfileIOData* profile_io_data) : profile_io_data_(profile_io_data) {} - virtual ChromeURLRequestContext* Create() OVERRIDE { + virtual net::URLRequestContext* Create() OVERRIDE { return profile_io_data_->GetExtensionsRequestContext(); } @@ -73,7 +73,7 @@ class FactoryForExtensions : public ChromeURLRequestContextFactory { const ProfileIOData* const profile_io_data_; }; -// Factory that creates the ChromeURLRequestContext for a given isolated app. +// Factory that creates the URLRequestContext for a given isolated app. class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { public: FactoryForIsolatedApp( @@ -92,7 +92,7 @@ class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { std::swap(protocol_handlers_, *protocol_handlers); } - virtual ChromeURLRequestContext* Create() OVERRIDE { + virtual net::URLRequestContext* Create() OVERRIDE { // We will copy most of the state from the main request context. // // Note that this factory is one-shot. After Create() is called once, the @@ -117,7 +117,7 @@ class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { content::URLRequestInterceptorScopedVector request_interceptors_; }; -// Factory that creates the media ChromeURLRequestContext for a given isolated +// Factory that creates the media URLRequestContext for a given isolated // app. The media context is based on the corresponding isolated app's context. class FactoryForIsolatedMedia : public ChromeURLRequestContextFactory { public: @@ -129,7 +129,7 @@ class FactoryForIsolatedMedia : public ChromeURLRequestContextFactory { partition_descriptor_(partition_descriptor), app_context_getter_(app_context) {} - virtual ChromeURLRequestContext* Create() OVERRIDE { + virtual net::URLRequestContext* Create() OVERRIDE { // We will copy most of the state from the corresopnding app's // request context. We expect to have the same lifetime as // the associated |app_context_getter_| so we can just reuse @@ -146,14 +146,14 @@ class FactoryForIsolatedMedia : public ChromeURLRequestContextFactory { scoped_refptr<ChromeURLRequestContextGetter> app_context_getter_; }; -// Factory that creates the ChromeURLRequestContext for media. +// Factory that creates the URLRequestContext for media. class FactoryForMedia : public ChromeURLRequestContextFactory { public: explicit FactoryForMedia(const ProfileIOData* profile_io_data) : profile_io_data_(profile_io_data) { } - virtual ChromeURLRequestContext* Create() OVERRIDE { + virtual net::URLRequestContext* Create() OVERRIDE { return profile_io_data_->GetMediaRequestContext(); } @@ -169,28 +169,29 @@ class FactoryForMedia : public ChromeURLRequestContextFactory { ChromeURLRequestContextGetter::ChromeURLRequestContextGetter( ChromeURLRequestContextFactory* factory) - : factory_(factory) { + : factory_(factory), + url_request_context_(NULL) { DCHECK(factory); } ChromeURLRequestContextGetter::~ChromeURLRequestContextGetter() {} -// Lazily create a ChromeURLRequestContext using our factory. -ChromeURLRequestContext* +// Lazily create a URLRequestContext using our factory. +net::URLRequestContext* ChromeURLRequestContextGetter::GetURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (!url_request_context_.get()) { - DCHECK(factory_.get()); - url_request_context_ = factory_->Create()->GetWeakPtr(); + if (factory_.get()) { + DCHECK(!url_request_context_); + url_request_context_ = factory_->Create(); factory_.reset(); } - // Should not be NULL, unless we're trying to use the URLRequestContextGetter - // after the Profile has already been deleted. - CHECK(url_request_context_.get()); + // Context reference is valid, unless we're trying to use the + // URLRequestContextGetter after the Profile has already been deleted. + CHECK(url_request_context_); - return url_request_context_.get(); + return url_request_context_; } scoped_refptr<base::SingleThreadTaskRunner> @@ -256,23 +257,3 @@ ChromeURLRequestContextGetter::CreateForIsolatedMedia( new FactoryForIsolatedMedia( profile_io_data, partition_descriptor, app_context)); } - -// ---------------------------------------------------------------------------- -// ChromeURLRequestContext -// ---------------------------------------------------------------------------- - -ChromeURLRequestContext::ChromeURLRequestContext() - : weak_factory_(this) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); -} - -ChromeURLRequestContext::~ChromeURLRequestContext() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - AssertNoURLRequests(); -} - -void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { - URLRequestContext::CopyFrom(other); - - // Copy ChromeURLRequestContext parameters. -} diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context_getter.h index 18c8b21..91d13eb 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context_getter.h @@ -1,9 +1,9 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ -#define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ +#ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ +#define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ #include <string> @@ -19,34 +19,6 @@ class Profile; class ProfileIOData; struct StoragePartitionDescriptor; -// Subclass of net::URLRequestContext which can be used to store extra -// information for requests. -// -// All methods of this class must be called from the IO thread, -// including the constructor and destructor. -class ChromeURLRequestContext : public net::URLRequestContext { - public: - ChromeURLRequestContext(); - virtual ~ChromeURLRequestContext(); - - base::WeakPtr<ChromeURLRequestContext> GetWeakPtr() { - return weak_factory_.GetWeakPtr(); - } - - // Copies the state from |other| into this context. - void CopyFrom(ChromeURLRequestContext* other); - - private: - base::WeakPtrFactory<ChromeURLRequestContext> weak_factory_; - - // --------------------------------------------------------------------------- - // Important: When adding any new members below, consider whether they need to - // be added to CopyFrom. - // --------------------------------------------------------------------------- - - DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); -}; - // A net::URLRequestContextGetter subclass used by the browser. This returns a // subclass of net::URLRequestContext which can be used to store extra // information about requests. @@ -56,7 +28,7 @@ class ChromeURLRequestContext : public net::URLRequestContext { class ChromeURLRequestContextGetter : public net::URLRequestContextGetter { public: // Constructs a ChromeURLRequestContextGetter that will use |factory| to - // create the ChromeURLRequestContext. + // create the URLRequestContext. explicit ChromeURLRequestContextGetter( ChromeURLRequestContextFactory* factory); @@ -65,7 +37,7 @@ class ChromeURLRequestContextGetter : public net::URLRequestContextGetter { // GetIOMessageLoopProxy however can be called from any thread. // // net::URLRequestContextGetter implementation. - virtual ChromeURLRequestContext* GetURLRequestContext() OVERRIDE; + virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const OVERRIDE; @@ -107,19 +79,22 @@ class ChromeURLRequestContextGetter : public net::URLRequestContextGetter { const ProfileIOData* profile_io_data, const StoragePartitionDescriptor& partition_descriptor); + void Invalidate() { url_request_context_ = NULL; } + private: virtual ~ChromeURLRequestContextGetter(); - // Deferred logic for creating a ChromeURLRequestContext. + // Deferred logic for creating a URLRequestContext. // Access only from the IO thread. scoped_ptr<ChromeURLRequestContextFactory> factory_; - // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext - // instance that was lazily created by GetURLRequestContext(). + // NULL before initialization and after invalidation. + // Otherwise, it is the URLRequestContext instance that + // was lazily created by GetURLRequestContext(). // Access only from the IO thread. - base::WeakPtr<ChromeURLRequestContext> url_request_context_; + net::URLRequestContext* url_request_context_; DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); }; -#endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ +#endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_GETTER_H_ diff --git a/chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc b/chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc index c19baed..60fd28e 100644 --- a/chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc +++ b/chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc @@ -9,7 +9,6 @@ #include "base/message_loop/message_loop.h" #include "base/prefs/pref_registry_simple.h" #include "base/prefs/testing_pref_service.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/prefs/pref_service_mock_factory.h" #include "chrome/browser/prefs/proxy_config_dictionary.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index dfcef82..1a8378c 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -22,6 +22,7 @@ #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/extensions/extension_special_storage_policy.h" #include "chrome/browser/io_thread.h" +#include "chrome/browser/net/chrome_url_request_context_getter.h" #include "chrome/browser/net/pref_proxy_config_tracker.h" #include "chrome/browser/net/proxy_service_factory.h" #include "chrome/browser/plugins/chrome_plugin_service_filter.h" diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc index df01282..7527d6f 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -18,7 +18,7 @@ #include "chrome/browser/net/about_protocol_handler.h" #include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/net/chrome_network_delegate.h" -#include "chrome/browser/net/chrome_url_request_context.h" +#include "chrome/browser/net/chrome_url_request_context_getter.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" @@ -51,6 +51,18 @@ OffTheRecordProfileIOData::Handle::Handle(Profile* profile) OffTheRecordProfileIOData::Handle::~Handle() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + ChromeURLRequestContextGetterMap::iterator iter = + app_request_context_getter_map_.begin(); + for (; iter != app_request_context_getter_map_.end(); ++iter) + iter->second->Invalidate(); + + if (extensions_request_context_getter_) + extensions_request_context_getter_->Invalidate(); + + if (main_request_context_getter_) + main_request_context_getter_->Invalidate(); + io_data_->ShutdownOnUIThread(); } @@ -185,7 +197,7 @@ void OffTheRecordProfileIOData::InitializeInternal( ProfileParams* profile_params, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const { - ChromeURLRequestContext* main_context = main_request_context(); + net::URLRequestContext* main_context = main_request_context(); IOThread* const io_thread = profile_params->io_thread; IOThread::Globals* const io_thread_globals = io_thread->globals(); @@ -276,7 +288,7 @@ void OffTheRecordProfileIOData::InitializeInternal( void OffTheRecordProfileIOData:: InitializeExtensionsRequestContext(ProfileParams* profile_params) const { - ChromeURLRequestContext* extensions_context = extensions_request_context(); + net::URLRequestContext* extensions_context = extensions_request_context(); IOThread* const io_thread = profile_params->io_thread; IOThread::Globals* const io_thread_globals = io_thread->globals(); @@ -323,8 +335,8 @@ void OffTheRecordProfileIOData:: extensions_context->set_job_factory(extensions_job_factory_.get()); } -ChromeURLRequestContext* OffTheRecordProfileIOData::InitializeAppRequestContext( - ChromeURLRequestContext* main_context, +net::URLRequestContext* OffTheRecordProfileIOData::InitializeAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, @@ -365,30 +377,30 @@ ChromeURLRequestContext* OffTheRecordProfileIOData::InitializeAppRequestContext( return context; } -ChromeURLRequestContext* +net::URLRequestContext* OffTheRecordProfileIOData::InitializeMediaRequestContext( - ChromeURLRequestContext* original_context, + net::URLRequestContext* original_context, const StoragePartitionDescriptor& partition_descriptor) const { NOTREACHED(); return NULL; } -ChromeURLRequestContext* +net::URLRequestContext* OffTheRecordProfileIOData::AcquireMediaRequestContext() const { NOTREACHED(); return NULL; } -ChromeURLRequestContext* +net::URLRequestContext* OffTheRecordProfileIOData::AcquireIsolatedAppRequestContext( - ChromeURLRequestContext* main_context, + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const { // We create per-app contexts on demand, unlike the others above. - ChromeURLRequestContext* app_request_context = + net::URLRequestContext* app_request_context = InitializeAppRequestContext(main_context, partition_descriptor, protocol_handler_interceptor.Pass(), @@ -398,9 +410,9 @@ OffTheRecordProfileIOData::AcquireIsolatedAppRequestContext( return app_request_context; } -ChromeURLRequestContext* +net::URLRequestContext* OffTheRecordProfileIOData::AcquireIsolatedMediaRequestContext( - ChromeURLRequestContext* app_context, + net::URLRequestContext* app_context, const StoragePartitionDescriptor& partition_descriptor) const { NOTREACHED(); return NULL; diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.h b/chrome/browser/profiles/off_the_record_profile_io_data.h index 05ed8be..ad7d549 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.h +++ b/chrome/browser/profiles/off_the_record_profile_io_data.h @@ -15,7 +15,6 @@ #include "chrome/browser/profiles/profile_io_data.h" #include "chrome/browser/profiles/storage_partition_descriptor.h" -class ChromeURLRequestContext; class ChromeURLRequestContextGetter; class Profile; @@ -23,6 +22,7 @@ namespace net { class FtpTransactionFactory; class HttpTransactionFactory; class SdchManager; +class URLRequestContext; } // namespace net // OffTheRecordProfile owns a OffTheRecordProfileIOData::Handle, which holds a @@ -115,30 +115,30 @@ class OffTheRecordProfileIOData : public ProfileIOData { const OVERRIDE; virtual void InitializeExtensionsRequestContext( ProfileParams* profile_params) const OVERRIDE; - virtual ChromeURLRequestContext* InitializeAppRequestContext( - ChromeURLRequestContext* main_context, + virtual net::URLRequestContext* InitializeAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const OVERRIDE; - virtual ChromeURLRequestContext* InitializeMediaRequestContext( - ChromeURLRequestContext* original_context, + virtual net::URLRequestContext* InitializeMediaRequestContext( + net::URLRequestContext* original_context, const StoragePartitionDescriptor& partition_descriptor) const OVERRIDE; - virtual ChromeURLRequestContext* + virtual net::URLRequestContext* AcquireMediaRequestContext() const OVERRIDE; - virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - ChromeURLRequestContext* main_context, + virtual net::URLRequestContext* AcquireIsolatedAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const OVERRIDE; - virtual ChromeURLRequestContext* + virtual net::URLRequestContext* AcquireIsolatedMediaRequestContext( - ChromeURLRequestContext* app_context, + net::URLRequestContext* app_context, const StoragePartitionDescriptor& partition_descriptor) const OVERRIDE; diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index f93de44..08ab48a 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -41,7 +41,6 @@ #include "chrome/browser/download/download_service.h" #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/history/top_sites.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/net_pref_observer.h" #include "chrome/browser/net/predictor.h" #include "chrome/browser/net/pref_proxy_config_tracker.h" diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index 249137d..4d12e68 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -103,6 +103,26 @@ ProfileImplIOData::Handle::~Handle() { if (io_data_->http_server_properties_manager_) io_data_->http_server_properties_manager_->ShutdownOnPrefThread(); + + ChromeURLRequestContextGetterMap::iterator iter; + + iter = isolated_media_request_context_getter_map_.begin(); + for (; iter != isolated_media_request_context_getter_map_.end(); ++iter) + iter->second->Invalidate(); + + iter = app_request_context_getter_map_.begin(); + for (; iter != app_request_context_getter_map_.end(); ++iter) + iter->second->Invalidate(); + + if (extensions_request_context_getter_) + extensions_request_context_getter_->Invalidate(); + + if (media_request_context_getter_) + media_request_context_getter_->Invalidate(); + + if (main_request_context_getter_) + main_request_context_getter_->Invalidate(); + io_data_->ShutdownOnUIThread(); } @@ -366,7 +386,7 @@ void ProfileImplIOData::InitializeInternal( ProfileParams* profile_params, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const { - ChromeURLRequestContext* main_context = main_request_context(); + net::URLRequestContext* main_context = main_request_context(); IOThread* const io_thread = profile_params->io_thread; IOThread::Globals* const io_thread_globals = io_thread->globals(); @@ -528,7 +548,7 @@ void ProfileImplIOData::InitializeInternal( void ProfileImplIOData:: InitializeExtensionsRequestContext(ProfileParams* profile_params) const { - ChromeURLRequestContext* extensions_context = extensions_request_context(); + net::URLRequestContext* extensions_context = extensions_request_context(); IOThread* const io_thread = profile_params->io_thread; IOThread::Globals* const io_thread_globals = io_thread->globals(); ApplyProfileParamsToContext(extensions_context); @@ -574,8 +594,8 @@ void ProfileImplIOData:: extensions_context->set_job_factory(extensions_job_factory_.get()); } -ChromeURLRequestContext* ProfileImplIOData::InitializeAppRequestContext( - ChromeURLRequestContext* main_context, +net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, @@ -658,9 +678,9 @@ ChromeURLRequestContext* ProfileImplIOData::InitializeAppRequestContext( return context; } -ChromeURLRequestContext* +net::URLRequestContext* ProfileImplIOData::InitializeMediaRequestContext( - ChromeURLRequestContext* original_context, + net::URLRequestContext* original_context, const StoragePartitionDescriptor& partition_descriptor) const { // Copy most state from the original context. MediaRequestContext* context = new MediaRequestContext(); @@ -711,21 +731,21 @@ ProfileImplIOData::InitializeMediaRequestContext( return context; } -ChromeURLRequestContext* +net::URLRequestContext* ProfileImplIOData::AcquireMediaRequestContext() const { DCHECK(media_request_context_); return media_request_context_.get(); } -ChromeURLRequestContext* ProfileImplIOData::AcquireIsolatedAppRequestContext( - ChromeURLRequestContext* main_context, +net::URLRequestContext* ProfileImplIOData::AcquireIsolatedAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const { // We create per-app contexts on demand, unlike the others above. - ChromeURLRequestContext* app_request_context = + net::URLRequestContext* app_request_context = InitializeAppRequestContext(main_context, partition_descriptor, protocol_handler_interceptor.Pass(), @@ -735,12 +755,12 @@ ChromeURLRequestContext* ProfileImplIOData::AcquireIsolatedAppRequestContext( return app_request_context; } -ChromeURLRequestContext* +net::URLRequestContext* ProfileImplIOData::AcquireIsolatedMediaRequestContext( - ChromeURLRequestContext* app_context, + net::URLRequestContext* app_context, const StoragePartitionDescriptor& partition_descriptor) const { // We create per-app media contexts on demand, unlike the others above. - ChromeURLRequestContext* media_request_context = + net::URLRequestContext* media_request_context = InitializeMediaRequestContext(app_context, partition_descriptor); DCHECK(media_request_context); return media_request_context; diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h index 3f2917f..a39a780 100644 --- a/chrome/browser/profiles/profile_impl_io_data.h +++ b/chrome/browser/profiles/profile_impl_io_data.h @@ -10,6 +10,7 @@ #include "base/containers/hash_tables.h" #include "base/memory/ref_counted.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" +#include "chrome/browser/net/chrome_url_request_context_getter.h" #include "chrome/browser/profiles/profile_io_data.h" #include "content/public/browser/cookie_store_factory.h" @@ -169,30 +170,30 @@ class ProfileImplIOData : public ProfileIOData { const OVERRIDE; virtual void InitializeExtensionsRequestContext( ProfileParams* profile_params) const OVERRIDE; - virtual ChromeURLRequestContext* InitializeAppRequestContext( - ChromeURLRequestContext* main_context, + virtual net::URLRequestContext* InitializeAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const OVERRIDE; - virtual ChromeURLRequestContext* InitializeMediaRequestContext( - ChromeURLRequestContext* original_context, + virtual net::URLRequestContext* InitializeMediaRequestContext( + net::URLRequestContext* original_context, const StoragePartitionDescriptor& partition_descriptor) const OVERRIDE; - virtual ChromeURLRequestContext* + virtual net::URLRequestContext* AcquireMediaRequestContext() const OVERRIDE; - virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - ChromeURLRequestContext* main_context, + virtual net::URLRequestContext* AcquireIsolatedAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const OVERRIDE; - virtual ChromeURLRequestContext* + virtual net::URLRequestContext* AcquireIsolatedMediaRequestContext( - ChromeURLRequestContext* app_context, + net::URLRequestContext* app_context, const StoragePartitionDescriptor& partition_descriptor) const OVERRIDE; @@ -215,7 +216,7 @@ class ProfileImplIOData : public ProfileIOData { mutable scoped_ptr<chrome_browser_net::Predictor> predictor_; - mutable scoped_ptr<ChromeURLRequestContext> media_request_context_; + mutable scoped_ptr<net::URLRequestContext> media_request_context_; mutable scoped_ptr<net::URLRequestJobFactory> main_job_factory_; mutable scoped_ptr<net::URLRequestJobFactory> extensions_job_factory_; diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index fe5e784..004c35e 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -70,6 +70,7 @@ #include "net/url_request/file_protocol_handler.h" #include "net/url_request/ftp_protocol_handler.h" #include "net/url_request/url_request.h" +#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_file_job.h" #include "net/url_request/url_request_intercepting_job_factory.h" #include "net/url_request/url_request_interceptor.h" @@ -599,9 +600,9 @@ ProfileIOData::~ProfileIOData() { size_t num_media_contexts = isolated_media_request_context_map_.size(); size_t current_context = 0; static const size_t kMaxCachedContexts = 20; - ChromeURLRequestContext* app_context_cache[kMaxCachedContexts] = {0}; + net::URLRequestContext* app_context_cache[kMaxCachedContexts] = {0}; void* app_context_vtable_cache[kMaxCachedContexts] = {0}; - ChromeURLRequestContext* media_context_cache[kMaxCachedContexts] = {0}; + net::URLRequestContext* media_context_cache[kMaxCachedContexts] = {0}; void* media_context_vtable_cache[kMaxCachedContexts] = {0}; void* tmp_vtable = NULL; base::debug::Alias(&num_app_contexts); @@ -736,32 +737,32 @@ content::ResourceContext* ProfileIOData::GetResourceContext() const { return resource_context_.get(); } -ChromeURLRequestContext* ProfileIOData::GetMainRequestContext() const { +net::URLRequestContext* ProfileIOData::GetMainRequestContext() const { DCHECK(initialized_); return main_request_context_.get(); } -ChromeURLRequestContext* ProfileIOData::GetMediaRequestContext() const { +net::URLRequestContext* ProfileIOData::GetMediaRequestContext() const { DCHECK(initialized_); - ChromeURLRequestContext* context = AcquireMediaRequestContext(); + net::URLRequestContext* context = AcquireMediaRequestContext(); DCHECK(context); return context; } -ChromeURLRequestContext* ProfileIOData::GetExtensionsRequestContext() const { +net::URLRequestContext* ProfileIOData::GetExtensionsRequestContext() const { DCHECK(initialized_); return extensions_request_context_.get(); } -ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( - ChromeURLRequestContext* main_context, +net::URLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const { DCHECK(initialized_); - ChromeURLRequestContext* context = NULL; + net::URLRequestContext* context = NULL; if (ContainsKey(app_request_context_map_, partition_descriptor)) { context = app_request_context_map_[partition_descriptor]; } else { @@ -777,11 +778,11 @@ ChromeURLRequestContext* ProfileIOData::GetIsolatedAppRequestContext( return context; } -ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( - ChromeURLRequestContext* app_context, +net::URLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext( + net::URLRequestContext* app_context, const StoragePartitionDescriptor& partition_descriptor) const { DCHECK(initialized_); - ChromeURLRequestContext* context = NULL; + net::URLRequestContext* context = NULL; if (ContainsKey(isolated_media_request_context_map_, partition_descriptor)) { context = isolated_media_request_context_map_[partition_descriptor]; } else { @@ -1011,8 +1012,8 @@ void ProfileIOData::Init( const CommandLine& command_line = *CommandLine::ForCurrentProcess(); // Create the common request contexts. - main_request_context_.reset(new ChromeURLRequestContext()); - extensions_request_context_.reset(new ChromeURLRequestContext()); + main_request_context_.reset(new net::URLRequestContext()); + extensions_request_context_.reset(new net::URLRequestContext()); ChromeNetworkDelegate* network_delegate = new ChromeNetworkDelegate( @@ -1116,7 +1117,7 @@ void ProfileIOData::Init( } void ProfileIOData::ApplyProfileParamsToContext( - ChromeURLRequestContext* context) const { + net::URLRequestContext* context) const { context->set_http_user_agent_settings( chrome_http_user_agent_settings_.get()); context->set_ssl_config_service(profile_params_->ssl_config_service.get()); @@ -1254,7 +1255,7 @@ scoped_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory( const ProfileParams* profile_params, net::HttpCache::BackendFactory* main_backend) const { net::HttpNetworkSession::Params params; - ChromeURLRequestContext* context = main_request_context(); + net::URLRequestContext* context = main_request_context(); IOThread* const io_thread = profile_params->io_thread; diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index a64d5e2..bc17731 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -18,7 +18,6 @@ #include "base/synchronization/lock.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/io_thread.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/storage_partition_descriptor.h" #include "components/content_settings/core/common/content_settings_types.h" @@ -28,6 +27,7 @@ #include "net/cookies/cookie_monster.h" #include "net/http/http_cache.h" #include "net/http/http_network_session.h" +#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_job_factory.h" class ChromeHttpUserAgentSettings; @@ -105,18 +105,18 @@ class ProfileIOData { content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const; - ChromeURLRequestContext* GetMainRequestContext() const; - ChromeURLRequestContext* GetMediaRequestContext() const; - ChromeURLRequestContext* GetExtensionsRequestContext() const; - ChromeURLRequestContext* GetIsolatedAppRequestContext( - ChromeURLRequestContext* main_context, + net::URLRequestContext* GetMainRequestContext() const; + net::URLRequestContext* GetMediaRequestContext() const; + net::URLRequestContext* GetExtensionsRequestContext() const; + net::URLRequestContext* GetIsolatedAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const; - ChromeURLRequestContext* GetIsolatedMediaRequestContext( - ChromeURLRequestContext* app_context, + net::URLRequestContext* GetIsolatedMediaRequestContext( + net::URLRequestContext* app_context, const StoragePartitionDescriptor& partition_descriptor) const; // These are useful when the Chrome layer is called from the content layer @@ -162,7 +162,7 @@ class ProfileIOData { return &one_click_signin_rejected_email_list_; } - ChromeURLRequestContext* extensions_request_context() const { + net::URLRequestContext* extensions_request_context() const { return extensions_request_context_.get(); } @@ -260,7 +260,7 @@ class ProfileIOData { protected: // A URLRequestContext for media that owns its HTTP factory, to ensure // it is deleted. - class MediaRequestContext : public ChromeURLRequestContext { + class MediaRequestContext : public net::URLRequestContext { public: MediaRequestContext(); @@ -275,7 +275,7 @@ class ProfileIOData { // A URLRequestContext for apps that owns its cookie store and HTTP factory, // to ensure they are deleted. - class AppRequestContext : public ChromeURLRequestContext { + class AppRequestContext : public net::URLRequestContext { public: AppRequestContext(); @@ -341,7 +341,7 @@ class ProfileIOData { static std::string GetSSLSessionCacheShard(); void InitializeOnUIThread(Profile* profile); - void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; + void ApplyProfileParamsToContext(net::URLRequestContext* context) const; #if defined(OS_ANDROID) #if defined(SPDY_PROXY_AUTH_ORIGIN) @@ -387,7 +387,7 @@ class ProfileIOData { void set_http_server_properties( scoped_ptr<net::HttpServerProperties> http_server_properties) const; - ChromeURLRequestContext* main_request_context() const { + net::URLRequestContext* main_request_context() const { return main_request_context_.get(); } @@ -448,7 +448,7 @@ class ProfileIOData { }; typedef std::map<StoragePartitionDescriptor, - ChromeURLRequestContext*, + net::URLRequestContext*, StoragePartitionDescriptorLess> URLRequestContextMap; @@ -469,8 +469,8 @@ class ProfileIOData { ProfileParams* profile_params) const = 0; // Does an on-demand initialization of a RequestContext for the given // isolated app. - virtual ChromeURLRequestContext* InitializeAppRequestContext( - ChromeURLRequestContext* main_context, + virtual net::URLRequestContext* InitializeAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& details, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, @@ -480,25 +480,25 @@ class ProfileIOData { // Does an on-demand initialization of a media RequestContext for the given // isolated app. - virtual ChromeURLRequestContext* InitializeMediaRequestContext( - ChromeURLRequestContext* original_context, + virtual net::URLRequestContext* InitializeMediaRequestContext( + net::URLRequestContext* original_context, const StoragePartitionDescriptor& details) const = 0; // These functions are used to transfer ownership of the lazily initialized // context from ProfileIOData to the URLRequestContextGetter. - virtual ChromeURLRequestContext* + virtual net::URLRequestContext* AcquireMediaRequestContext() const = 0; - virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - ChromeURLRequestContext* main_context, + virtual net::URLRequestContext* AcquireIsolatedAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) const = 0; - virtual ChromeURLRequestContext* + virtual net::URLRequestContext* AcquireIsolatedMediaRequestContext( - ChromeURLRequestContext* app_context, + net::URLRequestContext* app_context, const StoragePartitionDescriptor& partition_descriptor) const = 0; // The order *DOES* matter for the majority of these member variables, so @@ -596,8 +596,8 @@ class ProfileIOData { // These are only valid in between LazyInitialize() and their accessor being // called. - mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; - mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; + mutable scoped_ptr<net::URLRequestContext> main_request_context_; + mutable scoped_ptr<net::URLRequestContext> extensions_request_context_; // One URLRequestContext per isolated app for main and media requests. mutable URLRequestContextMap app_request_context_map_; mutable URLRequestContextMap isolated_media_request_context_map_; diff --git a/chrome/browser/renderer_host/offline_resource_throttle.cc b/chrome/browser/renderer_host/offline_resource_throttle.cc index 41b7a80..07230b8 100644 --- a/chrome/browser/renderer_host/offline_resource_throttle.cc +++ b/chrome/browser/renderer_host/offline_resource_throttle.cc @@ -12,7 +12,6 @@ #include "base/metrics/histogram.h" #include "base/strings/string_util.h" #include "chrome/browser/chromeos/offline/offline_load_page.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "content/public/browser/appcache_service.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" diff --git a/chrome/browser/safe_browsing/malware_details.cc b/chrome/browser/safe_browsing/malware_details.cc index 390299a..d32ee23 100644 --- a/chrome/browser/safe_browsing/malware_details.cc +++ b/chrome/browser/safe_browsing/malware_details.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/lazy_instance.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/malware_details_cache.h" #include "chrome/browser/safe_browsing/malware_details_history.h" diff --git a/chrome/browser/safe_browsing/malware_details_cache.cc b/chrome/browser/safe_browsing/malware_details_cache.cc index eba1714..ac27102 100644 --- a/chrome/browser/safe_browsing/malware_details_cache.cc +++ b/chrome/browser/safe_browsing/malware_details_cache.cc @@ -10,7 +10,7 @@ #include "base/lazy_instance.h" #include "base/md5.h" #include "base/strings/string_util.h" -#include "chrome/browser/net/chrome_url_request_context.h" +#include "chrome/browser/net/chrome_url_request_context_getter.h" #include "chrome/browser/safe_browsing/malware_details_cache.h" #include "chrome/browser/safe_browsing/report.pb.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" diff --git a/chrome/browser/sessions/session_data_deleter.cc b/chrome/browser/sessions/session_data_deleter.cc index e8b62d2..2eba98c 100644 --- a/chrome/browser/sessions/session_data_deleter.cc +++ b/chrome/browser/sessions/session_data_deleter.cc @@ -4,8 +4,8 @@ #include "base/bind.h" #include "base/command_line.h" +#include "base/memory/ref_counted.h" #include "chrome/browser/browser_shutdown.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/profiles/profile_io_data.h" #include "chrome/browser/ui/startup/startup_browser_creator.h" @@ -17,6 +17,7 @@ #include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_store.h" #include "net/cookies/cookie_util.h" +#include "net/url_request/url_request_context.h" #include "webkit/browser/quota/special_storage_policy.h" namespace { @@ -57,7 +58,7 @@ class SessionDataDeleter // session-only. void DeleteSessionOnlyOriginCookies(const net::CookieList& cookies); - base::WeakPtr<ChromeURLRequestContext> request_context_; + scoped_refptr<net::CookieMonster> cookie_monster_; scoped_refptr<quota::SpecialStoragePolicy> storage_policy_; const bool delete_only_by_session_only_policy_; @@ -104,40 +105,28 @@ void SessionDataDeleter::ClearSessionOnlyLocalStorage( void SessionDataDeleter::DeleteSessionCookiesOnIOThread( ProfileIOData* profile_io_data) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - ChromeURLRequestContext* request_context = + net::URLRequestContext* request_context = profile_io_data->GetMainRequestContext(); - request_context_ = request_context->GetWeakPtr(); - net::CookieMonster* cookie_monster = - request_context_->cookie_store()->GetCookieMonster(); + cookie_monster_ = request_context->cookie_store()->GetCookieMonster(); if (delete_only_by_session_only_policy_) { - cookie_monster->GetAllCookiesAsync( + cookie_monster_->GetAllCookiesAsync( base::Bind(&SessionDataDeleter::DeleteSessionOnlyOriginCookies, this)); } else { - cookie_monster->DeleteSessionCookiesAsync( + cookie_monster_->DeleteSessionCookiesAsync( base::Bind(&SessionDataDeleter::DeleteSessionCookiesDone, this)); } } void SessionDataDeleter::DeleteSessionCookiesDone(int num_deleted) { - ChromeURLRequestContext* request_context = request_context_.get(); - if (!request_context) - return; - - request_context->cookie_store()->GetCookieMonster()->GetAllCookiesAsync( + cookie_monster_->GetAllCookiesAsync( base::Bind(&SessionDataDeleter::DeleteSessionOnlyOriginCookies, this)); } void SessionDataDeleter::DeleteSessionOnlyOriginCookies( const net::CookieList& cookies) { - ChromeURLRequestContext* request_context = request_context_.get(); - if (!request_context) - return; - if (!storage_policy_ || !storage_policy_->HasSessionOnlyOrigins()) return; - net::CookieMonster* cookie_monster = - request_context->cookie_store()->GetCookieMonster(); for (net::CookieList::const_iterator it = cookies.begin(); it != cookies.end(); ++it) { @@ -145,7 +134,7 @@ void SessionDataDeleter::DeleteSessionOnlyOriginCookies( net::cookie_util::CookieOriginToURL(it->Domain(), it->IsSecure()); if (!storage_policy_->IsStorageSessionOnly(url)) continue; - cookie_monster->DeleteCanonicalCookieAsync(*it, base::Bind(CookieDeleted)); + cookie_monster_->DeleteCanonicalCookieAsync(*it, base::Bind(CookieDeleted)); } } diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc index 2b5daee..948416a 100644 --- a/chrome/browser/sync/test/integration/sync_test.cc +++ b/chrome/browser/sync/test/integration/sync_test.cc @@ -65,6 +65,7 @@ #include "net/base/escape.h" #include "net/base/load_flags.h" #include "net/base/network_change_notifier.h" +#include "net/cookies/cookie_monster.h" #include "net/proxy/proxy_config.h" #include "net/proxy/proxy_config_service_fixed.h" #include "net/proxy/proxy_service.h" @@ -134,6 +135,14 @@ class EncryptionChecker : public SingleClientStatusChangeChecker { } }; +void SetupNetworkCallback( + base::WaitableEvent* done, + net::URLRequestContextGetter* url_request_context_getter) { + url_request_context_getter->GetURLRequestContext()-> + set_cookie_store(new net::CookieMonster(NULL, NULL)); + done->Signal(); +} + void SetProxyConfigCallback( base::WaitableEvent* done, net::URLRequestContextGetter* url_request_context_getter, @@ -384,6 +393,8 @@ void SyncTest::InitializeInstance(int index) { ProfileSyncService* profile_sync_service = ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); + SetupNetwork(GetProfile(index)->GetRequestContext()); + if (server_type_ == IN_PROCESS_FAKE_SERVER) { // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer. profile_sync_service->OverrideNetworkResourcesForTest( @@ -1046,6 +1057,15 @@ void SyncTest::TriggerCreateSyncedBookmarks() { GetTitle())); } +void SyncTest::SetupNetwork(net::URLRequestContextGetter* context_getter) { + base::WaitableEvent done(false, false); + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&SetupNetworkCallback, &done, + make_scoped_refptr(context_getter))); + done.Wait(); +} + void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, const net::ProxyConfig& proxy_config) { base::WaitableEvent done(false, false); diff --git a/chrome/browser/sync/test/integration/sync_test.h b/chrome/browser/sync/test/integration/sync_test.h index 70fa9c4..4dc3182 100644 --- a/chrome/browser/sync/test/integration/sync_test.h +++ b/chrome/browser/sync/test/integration/sync_test.h @@ -334,6 +334,8 @@ class SyncTest : public InProcessBrowserTest { void SetProxyConfig(net::URLRequestContextGetter* context, const net::ProxyConfig& proxy_config); + void SetupNetwork(net::URLRequestContextGetter* context); + // Helper method used to set up fake responses for kClientLoginUrl, // kIssueAuthTokenUrl, kGetUserInfoUrl and kSearchDomainCheckUrl in order to // mock out calls to GAIA servers. diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc index 8b9387a..c0f8ef3 100644 --- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc +++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc @@ -122,8 +122,8 @@ class TestProfileIOData : public ProfileIOData { ProfileParams* profile_params) const OVERRIDE { NOTREACHED(); } - virtual ChromeURLRequestContext* InitializeAppRequestContext( - ChromeURLRequestContext* main_context, + virtual net::URLRequestContext* InitializeAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& details, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, @@ -133,19 +133,19 @@ class TestProfileIOData : public ProfileIOData { NOTREACHED(); return NULL; } - virtual ChromeURLRequestContext* InitializeMediaRequestContext( - ChromeURLRequestContext* original_context, + virtual net::URLRequestContext* InitializeMediaRequestContext( + net::URLRequestContext* original_context, const StoragePartitionDescriptor& details) const OVERRIDE { NOTREACHED(); return NULL; } - virtual ChromeURLRequestContext* + virtual net::URLRequestContext* AcquireMediaRequestContext() const OVERRIDE { NOTREACHED(); return NULL; } - virtual ChromeURLRequestContext* AcquireIsolatedAppRequestContext( - ChromeURLRequestContext* main_context, + virtual net::URLRequestContext* AcquireIsolatedAppRequestContext( + net::URLRequestContext* main_context, const StoragePartitionDescriptor& partition_descriptor, scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor, @@ -155,9 +155,9 @@ class TestProfileIOData : public ProfileIOData { NOTREACHED(); return NULL; } - virtual ChromeURLRequestContext* + virtual net::URLRequestContext* AcquireIsolatedMediaRequestContext( - ChromeURLRequestContext* app_context, + net::URLRequestContext* app_context, const StoragePartitionDescriptor& partition_descriptor) const OVERRIDE { NOTREACHED(); diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc index a3a4bee..8c713f8 100644 --- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc +++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc @@ -44,6 +44,7 @@ #include "components/sync_driver/sync_prefs.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" +#include "net/url_request/url_request_context_getter.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" diff --git a/chrome/browser/ui/webui/devtools_ui.cc b/chrome/browser/ui/webui/devtools_ui.cc index e0f3bd1..54f5673 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -10,7 +10,6 @@ #include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc index ad37c71..beef9970 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc @@ -13,7 +13,6 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_promo.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index a394efc..98f9378 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -786,8 +786,8 @@ 'browser/net/chrome_net_log.h', 'browser/net/chrome_network_delegate.cc', 'browser/net/chrome_network_delegate.h', - 'browser/net/chrome_url_request_context.cc', - 'browser/net/chrome_url_request_context.h', + 'browser/net/chrome_url_request_context_getter.cc', + 'browser/net/chrome_url_request_context_getter.h', 'browser/net/client_hints.cc', 'browser/net/client_hints.h', 'browser/net/connect_interceptor.cc', diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc index 369a4e6..cda08bb 100644 --- a/content/browser/webui/url_data_manager_backend.cc +++ b/content/browser/webui/url_data_manager_backend.cc @@ -205,7 +205,7 @@ class URLRequestChromeJob : public net::URLRequestJob, // True when job is generated from an incognito profile. const bool is_incognito_; - // The backend is owned by ChromeURLRequestContext and always outlives us. + // The backend is owned by net::URLRequestContext and always outlives us. URLDataManagerBackend* backend_; base::WeakPtrFactory<URLRequestChromeJob> weak_factory_; |