By moving the call to Load() up in SearchProvider::Start(), we are giving a chance to initialize TemplateURLService as early as possible. Before the change, Load would be called only if there was a non-empty input. During the startup, there is at least 1 call with empty input.

There is a chance this CL may increase startup time, however I have not observed it while running performance UI tests. As discussed with pkasting@, I'm planning to submit this CL and watch performance graphs to make sure we don't regress.

BUG=167381
TEST=Manually ran performance_ui_tests.


Review URL: https://chromiumcodereview.appspot.com/11859042

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178092 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 713af35fd..4d6e3477 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -209,6 +209,12 @@
 
 void SearchProvider::Start(const AutocompleteInput& input,
                            bool minimal_changes) {
+  // Do our best to load the model as early as possible.  This will reduce
+  // odds of having the model not ready when really needed (a non-empty input).
+  TemplateURLService* model = providers_.template_url_service();
+  DCHECK(model);
+  model->Load();
+
   matches_.clear();
   field_trial_triggered_ = false;
 
@@ -228,9 +234,6 @@
   if (keyword_input_text_.empty())
     keyword_provider = NULL;
 
-  TemplateURLService* model = providers_.template_url_service();
-  DCHECK(model);
-  model->Load();
   const TemplateURL* default_provider = model->GetDefaultSearchProvider();
   if (default_provider && !default_provider->SupportsReplacement())
     default_provider = NULL;