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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 134 |
131 // For callbacks may be run after destruction. | 135 // For callbacks may be run after destruction. |
132 base::WeakPtrFactory<SuggestionsService> weak_ptr_factory_; | 136 base::WeakPtrFactory<SuggestionsService> weak_ptr_factory_; |
133 | 137 |
134 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); | 138 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); |
135 }; | 139 }; |
136 | 140 |
137 } // namespace suggestions | 141 } // namespace suggestions |
138 | 142 |
139 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 143 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
OLD | NEW |