#ifndef CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
#define CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
#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"
#include "chrome/browser/search/suggestions/proto/suggestions.pb.h"
#include "components/keyed_service/core/keyed_service.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
class Profile;
namespace suggestions {
extern const char kSuggestionsFieldTrialName[];
extern const char kSuggestionsFieldTrialURLParam[];
extern const char kSuggestionsFieldTrialStateParam[];
extern const char kSuggestionsFieldTrialStateEnabled[];
class SuggestionsService : public KeyedService, public net::URLFetcherDelegate {
public:
typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback;
explicit SuggestionsService(Profile* profile);
virtual ~SuggestionsService();
static bool IsEnabled();
void FetchSuggestionsData(ResponseCallback callback);
private:
FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData);
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
virtual void Shutdown() OVERRIDE;
scoped_ptr<net::URLFetcher> pending_request_;
base::TimeTicks last_request_started_time_;
GURL suggestions_url_;
std::vector<ResponseCallback> waiting_requestors_;
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(SuggestionsService);
};
}
#endif