Don't pass URLBlacklistManager from UI to IO through ProfileParams on ProfileIOData.

If the ProfileIOData isn't ever lazily initialized, the URLBlacklistManager will be deleted with the ProfileParams on the wrong thread.

BUG=95510
TEST=sync_integration_tests aren't breaking because of destruction of URLBlacklistManager on the wrong thread


Review URL: http://codereview.chromium.org/7841004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99876 0039d316-1c4b-4281-b951-d872f2087c98
parent f5ee2f7f
......@@ -119,7 +119,7 @@ OffTheRecordProfileIOData::Handle::GetIsolatedAppRequestContextGetter(
void OffTheRecordProfileIOData::Handle::LazyInitialize() const {
if (!initialized_) {
io_data_->InitializeProfileParams(profile_);
io_data_->InitializeOnUIThread(profile_);
ChromeNetworkDelegate::InitializeReferrersEnabled(
io_data_->enable_referrers(), profile_->GetPrefs());
#if defined(ENABLE_SAFE_BROWSING)
......
......@@ -157,7 +157,7 @@ ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter(
void ProfileImplIOData::Handle::LazyInitialize() const {
if (!initialized_) {
io_data_->InitializeProfileParams(profile_);
io_data_->InitializeOnUIThread(profile_);
ChromeNetworkDelegate::InitializeReferrersEnabled(
io_data_->enable_referrers(), profile_->GetPrefs());
io_data_->clear_local_state_on_exit()->Init(
......
......@@ -189,7 +189,7 @@ prerender::PrerenderManager* GetPrerenderManagerOnUI(
} // namespace
void ProfileIOData::InitializeProfileParams(Profile* profile) {
void ProfileIOData::InitializeOnUIThread(Profile* profile) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
PrefService* pref_service = profile->GetPrefs();
......@@ -244,16 +244,20 @@ void ProfileIOData::InitializeProfileParams(Profile* profile) {
base::Bind(&GetPrerenderManagerOnUI, profile_getter);
params->protocol_handler_registry = profile->GetProtocolHandlerRegistry();
#if defined(ENABLE_CONFIGURATION_POLICY)
params->url_blacklist_manager.reset(
new policy::URLBlacklistManager(pref_service));
#endif
params->proxy_config_service.reset(
ProxyServiceFactory::CreateProxyConfigService(
profile->GetProxyConfigTracker()));
params->profile = profile;
profile_params_.reset(params.release());
// The URLBlacklistManager has to be created on the UI thread to register
// observers of |pref_service|, and it also has to clean up on
// ShutdownOnUIThread to release these observers on the right thread.
// Don't pass it in |profile_params_| to make sure it is correctly cleaned up,
// in particular when this ProfileIOData isn't |initialized_| during deletion.
#if defined(ENABLE_CONFIGURATION_POLICY)
url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service));
#endif
}
ProfileIOData::AppRequestContext::AppRequestContext() {}
......@@ -410,7 +414,7 @@ void ProfileIOData::LazyInitialize() const {
network_delegate_.reset(new ChromeNetworkDelegate(
io_thread_globals->extension_event_router_forwarder.get(),
profile_params_->extension_info_map,
profile_params_->url_blacklist_manager.get(),
url_blacklist_manager_.get(),
profile_params_->profile,
&enable_referrers_));
......@@ -480,7 +484,6 @@ void ProfileIOData::LazyInitialize() const {
notification_service_ = profile_params_->notification_service;
extension_info_map_ = profile_params_->extension_info_map;
prerender_manager_getter_ = profile_params_->prerender_manager_getter;
url_blacklist_manager_.swap(profile_params_->url_blacklist_manager);
resource_context_.set_host_resolver(io_thread_globals->host_resolver.get());
resource_context_.set_request_context(main_request_context_);
......
......@@ -156,9 +156,6 @@ class ProfileIOData {
// because on linux it relies on initializing things through gconf,
// and needs to be on the main thread.
scoped_ptr<net::ProxyConfigService> proxy_config_service;
// Initialized on the UI thread because it needs to reference the
// Profile's PrefService.
scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager;
// The profile this struct was populated from. It's passed as a void* to
// ensure it's not accidently used on the IO thread. Before using it on the
// UI thread, call ProfileManager::IsValidProfile to ensure it's alive.
......@@ -168,7 +165,7 @@ class ProfileIOData {
explicit ProfileIOData(bool is_incognito);
void InitializeProfileParams(Profile* profile);
void InitializeOnUIThread(Profile* profile);
void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const;
// Lazy initializes the ProfileIOData object the first time a request context
......
......@@ -3654,7 +3654,7 @@
Memcheck:Leak
fun:_Znw*
...
fun:_ZN13ProfileIOData23InitializeProfileParamsEP7Profile
fun:_ZN13ProfileIOData20InitializeOnUIThreadEP7Profile
}
{
bug_72698_b
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment