From 15a8709fe24ebb55e15ed88b306d76ad72412931 Mon Sep 17 00:00:00 2001 From: sdefresne Date: Thu, 16 Oct 2014 07:41:51 -0700 Subject: Add missing dependency on TemplateURLService from PrefMetricsService There is an indirect dependency from PrefMetricsService on TemplateURLService that cause an incorrect ordering of the factories instantiation when using a TestingProfile, as can be seen in the following callstack: TemplateURLServiceFactory::GetForProfile(Profile*) chrome::(anonymous namespace)::GetDefaultSearchProviderTemplateURL(Profile*) chrome::(anonymous namespace)::NewTabURLDetails::ForProfile(Profile*)1 chrome::HandleNewTabURLRewrite(GURL*, content::BrowserContext*) content::BrowserURLHandlerImpl::RewriteURLIfNecessary(GURL*, content::BrowserContext*, bool*) (anonymous namespace)::SampleNewTabPageURL(Profile*) PrefMetricsService::RecordLaunchPrefs() PrefMetricsService::PrefMetricsService(Profile*) PrefMetricsService::Factory::BuildServiceInstanceFor(content::BrowserContext*) Add an explicit dependency to fix the ordering. BUG=373326 Review URL: https://codereview.chromium.org/659973002 Cr-Commit-Position: refs/heads/master@{#299890} --- chrome/browser/prefs/pref_metrics_service.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc index 4b19849..d5b67d3 100644 --- a/chrome/browser/prefs/pref_metrics_service.cc +++ b/chrome/browser/prefs/pref_metrics_service.cc @@ -18,6 +18,7 @@ #include "chrome/browser/prefs/synced_pref_change_registrar.h" #include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/tabs/pinned_tab_codec.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" @@ -223,6 +224,7 @@ PrefMetricsService::Factory::Factory() : BrowserContextKeyedServiceFactory( "PrefMetricsService", BrowserContextDependencyManager::GetInstance()) { + DependsOn(TemplateURLServiceFactory::GetInstance()); } PrefMetricsService::Factory::~Factory() { -- cgit v1.1