| Index: chrome/browser/search/suggestions/suggestions_service.h
|
| diff --git a/chrome/browser/search/suggestions/suggestions_service.h b/chrome/browser/search/suggestions/suggestions_service.h
|
| index b3430f07102f87fbe73263976173dfc4c0fbdb5b..750d23b7c1b0a962b0490cb15324c41ae08f1b4c 100644
|
| --- a/chrome/browser/search/suggestions/suggestions_service.h
|
| +++ b/chrome/browser/search/suggestions/suggestions_service.h
|
| @@ -8,7 +8,6 @@
|
| #include <vector>
|
|
|
| #include "base/basictypes.h"
|
| -#include "base/callback.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/time/time.h"
|
| @@ -26,48 +25,42 @@
|
| extern const char kSuggestionsFieldTrialStateParam[];
|
| extern const char kSuggestionsFieldTrialStateEnabled[];
|
|
|
| -// An interface to fetch server suggestions asynchronously.
|
| +// Provides an interface for the Suggestions component that provides server
|
| +// suggestions.
|
| class SuggestionsService : public BrowserContextKeyedService,
|
| public net::URLFetcherDelegate {
|
| public:
|
| - typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback;
|
| -
|
| explicit SuggestionsService(Profile* profile);
|
| virtual ~SuggestionsService();
|
|
|
| // Whether this service is enabled.
|
| static bool IsEnabled();
|
|
|
| - // Request suggestions data, which will be passed to |callback|. Initiates a
|
| - // fetch request unless a pending one exists. To prevent multiple requests,
|
| - // we place all |callback|s in a queue and update them simultaneously when
|
| - // fetch request completes.
|
| - void FetchSuggestionsData(ResponseCallback callback);
|
| + const SuggestionsProfile& suggestions() { return suggestions_; }
|
|
|
| private:
|
| FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData);
|
|
|
| - // net::URLFetcherDelegate implementation.
|
| - // Called when fetch request completes. Parses the received suggestions data,
|
| - // and dispatches them to callbacks stored in queue.
|
| + // Starts the fetching process once, where |OnURLFetchComplete| is called with
|
| + // the response.
|
| + void FetchSuggestionsData();
|
| +
|
| + // net::URLFetcherDelegate implementation:
|
| virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
|
|
|
| - // BrowserContextKeyedService implementation.
|
| - virtual void Shutdown() OVERRIDE;
|
| -
|
| - // Contains the current suggestions fetch request. Will only have a value
|
| - // while a request is pending, and will be reset by |OnURLFetchComplete|.
|
| + // Contains the current suggestions request. Will only have a value while a
|
| + // request is pending, and will be reset by |OnURLFetchComplete|.
|
| scoped_ptr<net::URLFetcher> pending_request_;
|
|
|
| - // The start time of the previous suggestions request. This is used to measure
|
| - // the latency of requests. Initially zero.
|
| + // The start time of the last suggestions request. This is used to measure the
|
| + // latency of requests. Initially zero.
|
| base::TimeTicks last_request_started_time_;
|
|
|
| // The URL to fetch suggestions data from.
|
| GURL suggestions_url_;
|
|
|
| - // Queue of callbacks. These are flushed when fetch request completes.
|
| - std::vector<ResponseCallback> waiting_requestors_;
|
| + // Stores the suggestions as they were received from the server.
|
| + SuggestionsProfile suggestions_;
|
|
|
| Profile* profile_;
|
|
|
|
|