| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_servi
ce.h" | |
| 6 | |
| 7 #include "chrome/browser/sync/profile_sync_service.h" | |
| 8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" | |
| 9 | |
| 10 namespace enhanced_bookmarks { | |
| 11 | |
| 12 ChromeBookmarkServerClusterService::ChromeBookmarkServerClusterService( | |
| 13 const std::string& application_language_code, | |
| 14 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | |
| 15 ProfileOAuth2TokenService* token_service, | |
| 16 SigninManagerBase* signin_manager, | |
| 17 EnhancedBookmarkModel* enhanced_bookmark_model, | |
| 18 PrefService* pref_service, | |
| 19 ProfileSyncService* sync_service) | |
| 20 : BookmarkServerClusterService(application_language_code, | |
| 21 request_context_getter, | |
| 22 token_service, | |
| 23 signin_manager, | |
| 24 enhanced_bookmark_model, | |
| 25 pref_service), | |
| 26 sync_service_(sync_service) { | |
| 27 if (sync_service_) | |
| 28 sync_service_->AddObserver(this); | |
| 29 } | |
| 30 | |
| 31 ChromeBookmarkServerClusterService::~ChromeBookmarkServerClusterService() { | |
| 32 if (sync_service_) | |
| 33 sync_service_->RemoveObserver(this); | |
| 34 } | |
| 35 | |
| 36 void ChromeBookmarkServerClusterService::OnStateChanged() { | |
| 37 // Do nothing. | |
| 38 } | |
| 39 | |
| 40 void ChromeBookmarkServerClusterService::OnSyncCycleCompleted() { | |
| 41 // The stars cluster API relies on the information in chrome-sync. Sending a | |
| 42 // cluster request immediately after a bookmark is changed from the bookmark | |
| 43 // observer notification will yield the wrong results. The request must be | |
| 44 // delayed until the sync cycle has completed. | |
| 45 // TODO(noyau): This might happen too often, need a way to coalesce and delay | |
| 46 // the notifications. | |
| 47 if (model_->loaded()) | |
| 48 TriggerTokenRequest(false); | |
| 49 } | |
| 50 | |
| 51 } // namespace enhanced_bookmarks | |
| OLD | NEW |