| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace suggestions { | 31 namespace suggestions { |
| 32 | 32 |
| 33 class SuggestionsStore; | 33 class SuggestionsStore; |
| 34 | 34 |
| 35 extern const char kSuggestionsFieldTrialName[]; | 35 extern const char kSuggestionsFieldTrialName[]; |
| 36 extern const char kSuggestionsFieldTrialURLParam[]; | 36 extern const char kSuggestionsFieldTrialURLParam[]; |
| 37 extern const char kSuggestionsFieldTrialSuggestionsSuffixParam[]; | 37 extern const char kSuggestionsFieldTrialSuggestionsSuffixParam[]; |
| 38 extern const char kSuggestionsFieldTrialBlacklistSuffixParam[]; | 38 extern const char kSuggestionsFieldTrialBlacklistSuffixParam[]; |
| 39 extern const char kSuggestionsFieldTrialStateParam[]; | 39 extern const char kSuggestionsFieldTrialStateParam[]; |
| 40 extern const char kSuggestionsFieldTrialControlParam[]; |
| 40 extern const char kSuggestionsFieldTrialStateEnabled[]; | 41 extern const char kSuggestionsFieldTrialStateEnabled[]; |
| 41 | 42 |
| 42 // An interface to fetch server suggestions asynchronously. | 43 // An interface to fetch server suggestions asynchronously. |
| 43 class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { | 44 class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { |
| 44 public: | 45 public: |
| 45 typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; | 46 typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; |
| 46 | 47 |
| 47 SuggestionsService(Profile* profile, | 48 SuggestionsService(Profile* profile, |
| 48 scoped_ptr<SuggestionsStore> suggestions_store); | 49 scoped_ptr<SuggestionsStore> suggestions_store); |
| 49 virtual ~SuggestionsService(); | 50 virtual ~SuggestionsService(); |
| 50 | 51 |
| 51 // Whether this service is enabled. | 52 // Whether this service is enabled. |
| 52 static bool IsEnabled(); | 53 static bool IsEnabled(); |
| 53 | 54 |
| 55 // Whether the user is part of a control group. |
| 56 static bool IsControlGroup(); |
| 57 |
| 54 // Request suggestions data, which will be passed to |callback|. Initiates a | 58 // Request suggestions data, which will be passed to |callback|. Initiates a |
| 55 // fetch request unless a pending one exists. To prevent multiple requests, | 59 // fetch request unless a pending one exists. To prevent multiple requests, |
| 56 // we place all |callback|s in a queue and update them simultaneously when | 60 // we place all |callback|s in a queue and update them simultaneously when |
| 57 // fetch request completes. Also posts a task to execute OnRequestTimeout | 61 // fetch request completes. Also posts a task to execute OnRequestTimeout |
| 58 // if the request hasn't completed in a given amount of time. | 62 // if the request hasn't completed in a given amount of time. |
| 59 void FetchSuggestionsData(ResponseCallback callback); | 63 void FetchSuggestionsData(ResponseCallback callback); |
| 60 | 64 |
| 61 // Similar to FetchSuggestionsData but doesn't post a task to execute | 65 // Similar to FetchSuggestionsData but doesn't post a task to execute |
| 62 // OnDelaySinceFetch. | 66 // OnDelaySinceFetch. |
| 63 void FetchSuggestionsDataNoTimeout(ResponseCallback callback); | 67 void FetchSuggestionsDataNoTimeout(ResponseCallback callback); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Timeout (in ms) before serving requestors after a fetch suggestions request | 138 // Timeout (in ms) before serving requestors after a fetch suggestions request |
| 135 // has been issued. | 139 // has been issued. |
| 136 int request_timeout_ms_; | 140 int request_timeout_ms_; |
| 137 | 141 |
| 138 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); | 142 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); |
| 139 }; | 143 }; |
| 140 | 144 |
| 141 } // namespace suggestions | 145 } // namespace suggestions |
| 142 | 146 |
| 143 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 147 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
| OLD | NEW |