diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 21:07:57 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 21:07:57 +0000 |
commit | 4d34b576b9ce89b61fb7b0d98217f9faaa6c8d4d (patch) | |
tree | 9ede0287396d1fb1e060fe00d08ef0a307cb636d /chrome | |
parent | 51f825e6146c3e34ba97ad45875a599947459819 (diff) | |
download | chromium_src-4d34b576b9ce89b61fb7b0d98217f9faaa6c8d4d.zip chromium_src-4d34b576b9ce89b61fb7b0d98217f9faaa6c8d4d.tar.gz chromium_src-4d34b576b9ce89b61fb7b0d98217f9faaa6c8d4d.tar.bz2 |
Make sure we can still navigate to URLs when the History DB can't be loaded.
BUG=25822
TEST=Make your History files non-readable, run Chrome (Release), Type in "test.com" and see that the selected action is navigation.
Review URL: http://codereview.chromium.org/343051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/history_url_provider.cc | 16 | ||||
-rw-r--r-- | chrome/browser/autocomplete/history_url_provider.h | 7 |
2 files changed, 19 insertions, 4 deletions
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index 3d394e6..a266201 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -36,6 +36,7 @@ HistoryURLProviderParams::HistoryURLProviderParams( input(input), trim_http(trim_http), cancel(false), + failed(false), languages(languages) { } @@ -103,8 +104,10 @@ void HistoryURLProvider::ExecuteWithDB(history::HistoryBackend* backend, history::URLDatabase* db, HistoryURLProviderParams* params) { // We may get called with a NULL database if it couldn't be properly - // initialized. In this case we just say the query is complete. - if (db && !params->cancel) { + // initialized. + if (!db) { + params->failed = true; + } else if (!params->cancel) { TimeTicks beginning_time = TimeTicks::Now(); DoAutocomplete(backend, db, params); @@ -222,9 +225,14 @@ void HistoryURLProvider::QueryComplete( if (params->cancel) return; // Already set done_ when we canceled, no need to set it again. + // Don't modify |matches_| if the query failed, since it might have a default + // match in it, whereas |params->matches| will be empty. + if (!params->failed) { + matches_.swap(params->matches); + UpdateStarredStateOfMatches(); + } + done_ = true; - matches_.swap(params->matches); - UpdateStarredStateOfMatches(); listener_->OnProviderUpdate(true); } diff --git a/chrome/browser/autocomplete/history_url_provider.h b/chrome/browser/autocomplete/history_url_provider.h index d133514..b87a2e3 100644 --- a/chrome/browser/autocomplete/history_url_provider.h +++ b/chrome/browser/autocomplete/history_url_provider.h @@ -101,6 +101,13 @@ struct HistoryURLProviderParams { // we run the extra queries, the lack of signaling is not a problem. bool cancel; + // Set by ExecuteWithDB() on the history thread when the query could not be + // performed because the history system failed to properly init the database. + // If this is set when the main thread is called back, it avoids changing + // |matches_| at all, so it won't delete the default match + // RunAutocompletePasses() creates. + bool failed; + // List of matches written by the history thread. We keep this separate list // to avoid having the main thread read the provider's matches while the // history thread is manipulating them. The provider copies this list back |