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.
5 #include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.h"
7 #include "chrome/browser/sync/profile_sync_service.h"
8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h"
10 namespace enhanced_bookmarks
{
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
,
24 enhanced_bookmark_model
,
26 sync_service_(sync_service
) {
28 sync_service_
->AddObserver(this);
31 ChromeBookmarkServerClusterService::~ChromeBookmarkServerClusterService() {
33 sync_service_
->RemoveObserver(this);
36 void ChromeBookmarkServerClusterService::OnStateChanged() {
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
48 TriggerTokenRequest(false);
51 } // namespace enhanced_bookmarks