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

Unified Diff: components/suggestions/suggestions_service.cc

Issue 473123002: [Most Visited] Check for Sync state when using SuggestionsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: new api Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/suggestions/suggestions_service.cc
diff --git a/components/suggestions/suggestions_service.cc b/components/suggestions/suggestions_service.cc
index db1e3fc9632156cf08337286ea1201c93acd7051..87fc372dd382e9894cc7398195ee2692a153c440 100644
--- a/components/suggestions/suggestions_service.cc
+++ b/components/suggestions/suggestions_service.cc
@@ -156,8 +156,20 @@ bool SuggestionsService::IsControlGroup() {
}
void SuggestionsService::FetchSuggestionsData(
+ SyncState sync_state,
SuggestionsService::ResponseCallback callback) {
DCHECK(thread_checker_.CalledOnValidThread());
+ if (sync_state == NOT_INITIALIZED_ENABLED) {
+ // Sync is not initialized yet, but enabled. Serve previously cached
+ // suggestions if available.
+ waiting_requestors_.push_back(callback);
+ ServeFromCache();
+ return;
+ } else if (sync_state == DISABLED) {
+ suggestions_store_->ClearSuggestions();
manzagop (departed) 2014/08/20 15:43:51 Also cancel any ongoing request and serve the wait
Mathieu 2014/08/20 18:41:29 We shouldn't interact with the server anymore when
+ callback.Run(SuggestionsProfile());
+ return;
+ }
FetchSuggestionsDataNoTimeout(callback);

Powered by Google App Engine
This is Rietveld 408576698