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

Side by Side Diff: components/suggestions/suggestions_service.h

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/callback_list.h" 14 #include "base/callback_list.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/scoped_observer.h" 18 #include "base/scoped_observer.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "components/keyed_service/core/keyed_service.h" 21 #include "components/keyed_service/core/keyed_service.h"
22 #include "components/suggestions/proto/suggestions.pb.h" 22 #include "components/suggestions/proto/suggestions.pb.h"
23 #include "components/sync/driver/sync_service_observer.h" 23 #include "components/sync/driver/sync_service_observer.h"
24 #include "net/url_request/url_fetcher_delegate.h" 24 #include "net/url_request/url_fetcher_delegate.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
26 26
27 class OAuth2TokenService;
28 class SigninManagerBase;
29
27 namespace gfx { 30 namespace gfx {
28 class Image; 31 class Image;
29 } 32 } // namespce gfx
30 33
31 namespace net { 34 namespace net {
32 class URLRequestContextGetter; 35 class URLRequestContextGetter;
33 } // namespace net 36 } // namespace net
34 37
35 namespace sync_driver { 38 namespace syncer {
36 class SyncService; 39 class SyncService;
37 } 40 } // namespace syncer
38 41
39 namespace user_prefs { 42 namespace user_prefs {
40 class PrefRegistrySyncable; 43 class PrefRegistrySyncable;
41 } // namespace user_prefs 44 } // namespace user_prefs
42 45
43 class OAuth2TokenService;
44 class SigninManagerBase;
45
46 namespace suggestions { 46 namespace suggestions {
47 47
48 class BlacklistStore; 48 class BlacklistStore;
49 class ImageManager; 49 class ImageManager;
50 class SuggestionsStore; 50 class SuggestionsStore;
51 51
52 // An interface to fetch server suggestions asynchronously. 52 // An interface to fetch server suggestions asynchronously.
53 class SuggestionsService : public KeyedService, 53 class SuggestionsService : public KeyedService,
54 public net::URLFetcherDelegate, 54 public net::URLFetcherDelegate,
55 public sync_driver::SyncServiceObserver { 55 public syncer::SyncServiceObserver {
56 public: 56 public:
57 using ResponseCallback = base::Callback<void(const SuggestionsProfile&)>; 57 using ResponseCallback = base::Callback<void(const SuggestionsProfile&)>;
58 using BitmapCallback = base::Callback<void(const GURL&, const gfx::Image&)>; 58 using BitmapCallback = base::Callback<void(const GURL&, const gfx::Image&)>;
59 59
60 using ResponseCallbackList = 60 using ResponseCallbackList =
61 base::CallbackList<void(const SuggestionsProfile&)>; 61 base::CallbackList<void(const SuggestionsProfile&)>;
62 62
63 SuggestionsService(const SigninManagerBase* signin_manager, 63 SuggestionsService(const SigninManagerBase* signin_manager,
64 OAuth2TokenService* token_service, 64 OAuth2TokenService* token_service,
65 sync_driver::SyncService* sync_service, 65 syncer::SyncService* sync_service,
66 net::URLRequestContextGetter* url_request_context, 66 net::URLRequestContextGetter* url_request_context,
67 std::unique_ptr<SuggestionsStore> suggestions_store, 67 std::unique_ptr<SuggestionsStore> suggestions_store,
68 std::unique_ptr<ImageManager> thumbnail_manager, 68 std::unique_ptr<ImageManager> thumbnail_manager,
69 std::unique_ptr<BlacklistStore> blacklist_store); 69 std::unique_ptr<BlacklistStore> blacklist_store);
70 ~SuggestionsService() override; 70 ~SuggestionsService() override;
71 71
72 // Initiates a network request for suggestions if sync state allows and there 72 // Initiates a network request for suggestions if sync state allows and there
73 // is no pending request. Returns true iff sync state allowed for a request, 73 // is no pending request. Returns true iff sync state allowed for a request,
74 // whether a new request was actually sent or not. 74 // whether a new request was actually sent or not.
75 bool FetchSuggestionsData(); 75 bool FetchSuggestionsData();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, CheckDefaultTimeStamps); 130 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, CheckDefaultTimeStamps);
131 131
132 // Helpers to build the various suggestions URLs. These are static members 132 // Helpers to build the various suggestions URLs. These are static members
133 // rather than local functions in the .cc file to make them accessible to 133 // rather than local functions in the .cc file to make them accessible to
134 // tests. 134 // tests.
135 static GURL BuildSuggestionsURL(); 135 static GURL BuildSuggestionsURL();
136 static std::string BuildSuggestionsBlacklistURLPrefix(); 136 static std::string BuildSuggestionsBlacklistURLPrefix();
137 static GURL BuildSuggestionsBlacklistURL(const GURL& candidate_url); 137 static GURL BuildSuggestionsBlacklistURL(const GURL& candidate_url);
138 static GURL BuildSuggestionsBlacklistClearURL(); 138 static GURL BuildSuggestionsBlacklistClearURL();
139 139
140 // sync_driver::SyncServiceObserver implementation. 140 // syncer::SyncServiceObserver implementation.
141 void OnStateChanged() override; 141 void OnStateChanged() override;
142 142
143 // Sets default timestamp for suggestions which do not have expiry timestamp. 143 // Sets default timestamp for suggestions which do not have expiry timestamp.
144 void SetDefaultExpiryTimestamp(SuggestionsProfile* suggestions, 144 void SetDefaultExpiryTimestamp(SuggestionsProfile* suggestions,
145 int64_t timestamp_usec); 145 int64_t timestamp_usec);
146 146
147 // Issues a network request if there isn't already one happening. 147 // Issues a network request if there isn't already one happening.
148 void IssueRequestIfNoneOngoing(const GURL& url); 148 void IssueRequestIfNoneOngoing(const GURL& url);
149 149
150 // Issues a network request for suggestions (fetch, blacklist, or clear 150 // Issues a network request for suggestions (fetch, blacklist, or clear
(...skipping 30 matching lines...) Expand all
181 // Adds extra data to suggestions profile. 181 // Adds extra data to suggestions profile.
182 void PopulateExtraData(SuggestionsProfile* suggestions); 182 void PopulateExtraData(SuggestionsProfile* suggestions);
183 183
184 // Test seams. 184 // Test seams.
185 base::TimeDelta blacklist_delay() const { return scheduling_delay_; } 185 base::TimeDelta blacklist_delay() const { return scheduling_delay_; }
186 void set_blacklist_delay(base::TimeDelta delay) { 186 void set_blacklist_delay(base::TimeDelta delay) {
187 scheduling_delay_ = delay; } 187 scheduling_delay_ = delay; }
188 188
189 base::ThreadChecker thread_checker_; 189 base::ThreadChecker thread_checker_;
190 190
191 sync_driver::SyncService* sync_service_; 191 syncer::SyncService* sync_service_;
192 ScopedObserver<sync_driver::SyncService, sync_driver::SyncServiceObserver> 192 ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
193 sync_service_observer_; 193 sync_service_observer_;
194 194
195 net::URLRequestContextGetter* url_request_context_; 195 net::URLRequestContextGetter* url_request_context_;
196 196
197 // The cache for the suggestions. 197 // The cache for the suggestions.
198 std::unique_ptr<SuggestionsStore> suggestions_store_; 198 std::unique_ptr<SuggestionsStore> suggestions_store_;
199 199
200 // Used to obtain server thumbnails, if available. 200 // Used to obtain server thumbnails, if available.
201 std::unique_ptr<ImageManager> thumbnail_manager_; 201 std::unique_ptr<ImageManager> thumbnail_manager_;
202 202
(...skipping 20 matching lines...) Expand all
223 223
224 // For callbacks may be run after destruction. 224 // For callbacks may be run after destruction.
225 base::WeakPtrFactory<SuggestionsService> weak_ptr_factory_; 225 base::WeakPtrFactory<SuggestionsService> weak_ptr_factory_;
226 226
227 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); 227 DISALLOW_COPY_AND_ASSIGN(SuggestionsService);
228 }; 228 };
229 229
230 } // namespace suggestions 230 } // namespace suggestions
231 231
232 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ 232 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
OLDNEW
« no previous file with comments | « components/search_engines/template_url_service.h ('k') | components/suggestions/suggestions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698