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 #ifndef CHROME_BROWSER_ENHANCED_BOOKMARKS_CHROME_BOOKMARK_SERVER_CLUSTER_SERVICE_H_
6 #define CHROME_BROWSER_ENHANCED_BOOKMARKS_CHROME_BOOKMARK_SERVER_CLUSTER_SERVICE_H_
8 #include "chrome/browser/sync/profile_sync_service_observer.h"
9 #include "components/enhanced_bookmarks/bookmark_server_cluster_service.h"
11 class ProfileSyncService
;
13 namespace enhanced_bookmarks
{
15 // A cluster service that invalidates its data when a sync operation finishes.
16 class ChromeBookmarkServerClusterService
: public BookmarkServerClusterService
,
17 public ProfileSyncServiceObserver
{
19 ChromeBookmarkServerClusterService(
20 const std::string
& application_language_code
,
21 scoped_refptr
<net::URLRequestContextGetter
> request_context_getter
,
22 ProfileOAuth2TokenService
* token_service
,
23 SigninManagerBase
* signin_manager
,
24 EnhancedBookmarkModel
* enhanced_bookmark_model
,
25 PrefService
* pref_service
,
26 ProfileSyncService
* sync_service
);
27 ~ChromeBookmarkServerClusterService() override
;
29 // BookmarkServerClusterService
30 void AddObserver(BookmarkServerServiceObserver
* observer
) override
;
32 // ProfileSyncServiceObserver implementation.
33 void OnStateChanged() override
;
34 void OnSyncCycleCompleted() override
;
36 // EnhancedBookmarkModelObserver implementation.
37 void EnhancedBookmarkAdded(const bookmarks::BookmarkNode
* node
) override
;
38 void EnhancedBookmarkRemoved(const bookmarks::BookmarkNode
* node
) override
;
39 void EnhancedBookmarkNodeChanged(
40 const bookmarks::BookmarkNode
* node
) override
;
43 // This sets an internal flag to fetch new clusters.
44 void InvalidateCache();
46 // This class observes the sync service for changes.
47 ProfileSyncService
* sync_service_
;
48 bool sync_refresh_skipped_
= false;
49 // This holds the number of cluster refreshes needed.
50 int refreshes_needed_
= 0;
52 DISALLOW_COPY_AND_ASSIGN(ChromeBookmarkServerClusterService
);
55 } // namespace enhanced_bookmarks
57 #endif // CHROME_BROWSER_ENHANCED_BOOKMARKS_CHROME_BOOKMARK_SERVER_CLUSTER_SERVICE_H_