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

Unified Diff: chrome/browser/search/suggestions/suggestions_service.h

Issue 170743009: Revert of Adding the chrome://suggestions test page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
« no previous file with comments | « chrome/browser/search/instant_service.cc ('k') | chrome/browser/search/suggestions/suggestions_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « chrome/browser/search/instant_service.cc ('k') | chrome/browser/search/suggestions/suggestions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698