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 COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 5 #ifndef COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
6 #define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 6 #define COMPONENTS_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 user_prefs { | 31 namespace user_prefs { |
32 class PrefRegistrySyncable; | 32 class PrefRegistrySyncable; |
33 } // namespace user_prefs | 33 } // namespace user_prefs |
34 | 34 |
35 namespace suggestions { | 35 namespace suggestions { |
36 | 36 |
37 class BlacklistStore; | 37 class BlacklistStore; |
38 class SuggestionsStore; | 38 class SuggestionsStore; |
39 | 39 |
40 extern const char kSuggestionsFieldTrialName[]; | |
41 extern const char kSuggestionsFieldTrialControlParam[]; | |
42 extern const char kSuggestionsFieldTrialStateEnabled[]; | |
43 extern const char kSuggestionsFieldTrialStateParam[]; | |
44 | |
45 extern const char kSuggestionsURL[]; | 40 extern const char kSuggestionsURL[]; |
46 extern const char kSuggestionsBlacklistURLPrefix[]; | 41 extern const char kSuggestionsBlacklistURLPrefix[]; |
47 extern const char kSuggestionsBlacklistURLParam[]; | 42 extern const char kSuggestionsBlacklistURLParam[]; |
48 extern const int64 kDefaultExpiryUsec; | 43 extern const int64 kDefaultExpiryUsec; |
49 | 44 |
50 // An interface to fetch server suggestions asynchronously. | 45 // An interface to fetch server suggestions asynchronously. |
51 class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { | 46 class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { |
52 public: | 47 public: |
53 typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; | 48 typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; |
54 | 49 |
55 // Class taking ownership of |suggestions_store|, |thumbnail_manager| and | 50 // Class taking ownership of |suggestions_store|, |thumbnail_manager| and |
56 // |blacklist_store|. | 51 // |blacklist_store|. |
57 SuggestionsService( | 52 SuggestionsService( |
58 net::URLRequestContextGetter* url_request_context, | 53 net::URLRequestContextGetter* url_request_context, |
59 scoped_ptr<SuggestionsStore> suggestions_store, | 54 scoped_ptr<SuggestionsStore> suggestions_store, |
60 scoped_ptr<ImageManager> thumbnail_manager, | 55 scoped_ptr<ImageManager> thumbnail_manager, |
61 scoped_ptr<BlacklistStore> blacklist_store); | 56 scoped_ptr<BlacklistStore> blacklist_store); |
62 ~SuggestionsService() override; | 57 ~SuggestionsService() override; |
63 | 58 |
64 // Whether the user is part of a control group. | |
65 static bool IsControlGroup(); | |
66 | |
67 // Request suggestions data, which will be passed to |callback|. |sync_state| | 59 // Request suggestions data, which will be passed to |callback|. |sync_state| |
68 // will influence the behavior of this function (see SyncState definition). | 60 // will influence the behavior of this function (see SyncState definition). |
69 // | 61 // |
70 // |sync_state| must be specified based on the current state of the system | 62 // |sync_state| must be specified based on the current state of the system |
71 // (see suggestions::GetSyncState). Callers should call this function again if | 63 // (see suggestions::GetSyncState). Callers should call this function again if |
72 // sync state changes. | 64 // sync state changes. |
73 // | 65 // |
74 // If state allows for a network request, it is initiated unless a pending one | 66 // If state allows for a network request, it is initiated unless a pending one |
75 // exists, to fill the cache for next time. | 67 // exists, to fill the cache for next time. |
76 void FetchSuggestionsData(SyncState sync_state, | 68 void FetchSuggestionsData(SyncState sync_state, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 179 |
188 // For callbacks may be run after destruction. | 180 // For callbacks may be run after destruction. |
189 base::WeakPtrFactory<SuggestionsService> weak_ptr_factory_; | 181 base::WeakPtrFactory<SuggestionsService> weak_ptr_factory_; |
190 | 182 |
191 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); | 183 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); |
192 }; | 184 }; |
193 | 185 |
194 } // namespace suggestions | 186 } // namespace suggestions |
195 | 187 |
196 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 188 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
OLD | NEW |