Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3473)

Unified Diff: chrome/browser/autocomplete/zero_suggest_provider.h

Issue 436833002: Stop sharing BaseSearchProvider::OnURLFetchComplete between 2 providers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/zero_suggest_provider.h
diff --git a/chrome/browser/autocomplete/zero_suggest_provider.h b/chrome/browser/autocomplete/zero_suggest_provider.h
index 23dc2fe1e6d8217ed75dc94f74098062df029a57..1bf9f841ddddf0a8df55e74b58f7ddc9fe9e4214 100644
--- a/chrome/browser/autocomplete/zero_suggest_provider.h
+++ b/chrome/browser/autocomplete/zero_suggest_provider.h
@@ -21,7 +21,9 @@
#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/history/history_types.h"
#include "components/metrics/proto/omnibox_event.pb.h"
+#include "net/url_request/url_fetcher_delegate.h"
+class AutocompleteProviderListener;
class TemplateURLService;
namespace base {
@@ -47,7 +49,8 @@ class PrefRegistrySyncable;
// TODO(jered): Consider deleting this class and building this functionality
// into SearchProvider after dogfood and after we break the association between
// omnibox text and suggestions.
-class ZeroSuggestProvider : public BaseSearchProvider {
+class ZeroSuggestProvider : public BaseSearchProvider,
+ public net::URLFetcherDelegate {
public:
// Creates and returns an instance of this provider.
static ZeroSuggestProvider* Create(AutocompleteProviderListener* listener,
@@ -77,22 +80,20 @@ class ZeroSuggestProvider : public BaseSearchProvider {
virtual ~ZeroSuggestProvider();
+ // Optionally, cache the received |json_data| and return true if we want
+ // to stop processing results at this point. The |parsed_data| is the parsed
+ // version of |json_data| used to determine if we received an empty result.
+ bool StoreSuggestionResponse(const std::string& json_data,
+ const base::Value& parsed_data);
Peter Kasting 2014/08/08 17:33:24 Nit: See previous comments about function ordering
hashimoto 2014/08/11 05:15:04 Done.
+
// BaseSearchProvider:
- virtual bool StoreSuggestionResponse(const std::string& json_data,
- const base::Value& parsed_data) OVERRIDE;
virtual const TemplateURL* GetTemplateURL(bool is_keyword) const OVERRIDE;
virtual const AutocompleteInput GetInput(bool is_keyword) const OVERRIDE;
- virtual SearchSuggestionParser::Results* GetResultsToFill(
- bool is_keyword) OVERRIDE;
virtual bool ShouldAppendExtraParams(
const SearchSuggestionParser::SuggestResult& result) const OVERRIDE;
virtual void StopSuggest() OVERRIDE;
virtual void ClearAllResults() OVERRIDE;
- virtual int GetDefaultResultRelevance() const OVERRIDE;
virtual void RecordDeletionResult(bool success) OVERRIDE;
- virtual void LogFetchComplete(bool success, bool is_keyword) OVERRIDE;
- virtual bool IsKeywordFetcher(const net::URLFetcher* fetcher) const OVERRIDE;
- virtual void UpdateMatches() OVERRIDE;
// Adds AutocompleteMatches for each of the suggestions in |results| to
// |map|.
@@ -107,6 +108,9 @@ class ZeroSuggestProvider : public BaseSearchProvider {
// Fetches zero-suggest suggestions by sending a request using |suggest_url|.
void Run(const GURL& suggest_url);
+ // net::URLFetcherDelegate:
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
Peter Kasting 2014/08/08 17:33:24 Nit: Same nit.
hashimoto 2014/08/11 05:15:04 Done.
+
// Converts the parsed results to a set of AutocompleteMatches and adds them
// to |matches_|. Also update the histograms for how many results were
// received.
@@ -134,6 +138,8 @@ class ZeroSuggestProvider : public BaseSearchProvider {
// populates |matches_| with cached results.
void MaybeUseCachedSuggestions();
+ AutocompleteProviderListener* listener_;
+
// The URL for which a suggestion fetch is pending.
std::string current_query_;

Powered by Google App Engine
This is Rietveld 408576698