summaryrefslogtreecommitdiffstats
path: root/components/enhanced_bookmarks/bookmark_server_cluster_service.h
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2015-06-02 01:18:34 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-02 08:19:02 +0000
commitf54c4ca768c99e447186a9cbfc9e77cadc96e27a (patch)
tree26869d7003bc45825329137056848ab2e01c1d65 /components/enhanced_bookmarks/bookmark_server_cluster_service.h
parentb73b2de6a23e3220c79c6bb9e9f3a7b4dd20d2dd (diff)
downloadchromium_src-f54c4ca768c99e447186a9cbfc9e77cadc96e27a.zip
chromium_src-f54c4ca768c99e447186a9cbfc9e77cadc96e27a.tar.gz
chromium_src-f54c4ca768c99e447186a9cbfc9e77cadc96e27a.tar.bz2
Merge ChromeBookmarksServerClusterService with base class
Now that sync_driver::SyncService is available in //components/sync_driver we can merge ChromeBookmarksServerClusterService with its super class since child class was only there to abstract this problematic dependency. Rename the factory as ChromeBookmarkServerClusterService no longer exists. BUG=429756 Review URL: https://codereview.chromium.org/1162043005 Cr-Commit-Position: refs/heads/master@{#332356}
Diffstat (limited to 'components/enhanced_bookmarks/bookmark_server_cluster_service.h')
-rw-r--r--components/enhanced_bookmarks/bookmark_server_cluster_service.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/components/enhanced_bookmarks/bookmark_server_cluster_service.h b/components/enhanced_bookmarks/bookmark_server_cluster_service.h
index 6c2a678..7249c01 100644
--- a/components/enhanced_bookmarks/bookmark_server_cluster_service.h
+++ b/components/enhanced_bookmarks/bookmark_server_cluster_service.h
@@ -12,18 +12,24 @@
#include "components/enhanced_bookmarks/bookmark_server_service.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/signin/core/browser/signin_manager_base.h"
+#include "components/sync_driver/sync_service_observer.h"
#include "net/url_request/url_fetcher.h"
class PrefService;
+namespace sync_driver {
+class SyncService;
+}
+
namespace enhanced_bookmarks {
// Manages requests to the bookmark server to retrieve the current clustering
// state for the bookmarks. A cluster is simply a named set of bookmarks related
-// to each others.
+// to each others. Invalidates its data when a sync operation finishes.
class BookmarkServerClusterService : public KeyedService,
public BookmarkServerService,
- public SigninManagerBase::Observer {
+ public SigninManagerBase::Observer,
+ public sync_driver::SyncServiceObserver {
public:
// Maps a cluster name to the stars.id of the bookmarks.
typedef std::map<std::string, std::vector<std::string>> ClusterMap;
@@ -37,9 +43,13 @@ class BookmarkServerClusterService : public KeyedService,
ProfileOAuth2TokenService* token_service,
SigninManagerBase* signin_manager,
EnhancedBookmarkModel* enhanced_bookmark_model,
+ sync_driver::SyncService* sync_service,
PrefService* pref_service);
~BookmarkServerClusterService() override;
+ // KeyedService methods.
+ void Shutdown() override;
+
// Retrieves all the bookmarks associated with a cluster. The returned
// BookmarkNodes are owned by the bookmark model, and one must listen to the
// model observer notification to clear them.
@@ -53,6 +63,9 @@ class BookmarkServerClusterService : public KeyedService,
// Dynamically generates a vector of all clusters names.
const std::vector<std::string> GetClusters() const;
+ // BookmarkServerService methods.
+ void AddObserver(BookmarkServerServiceObserver* observer) override;
+
// Registers server cluster service prefs.
static void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry);
@@ -98,6 +111,13 @@ class BookmarkServerClusterService : public KeyedService,
// Updates |cluster_data_| from profile prefs.
void LoadModel();
+ // sync_driver::SyncServiceObserver methods.
+ void OnStateChanged() override;
+ void OnSyncCycleCompleted() override;
+
+ // This sets an internal flag to fetch new clusters.
+ void InvalidateCache();
+
// Serialize the |cluster_map| into the returned dictionary value.. The
// |auth_id| uniquely identify the signed in user, to avoid deserializing data
// for a different one.
@@ -113,10 +133,15 @@ class BookmarkServerClusterService : public KeyedService,
// The ISO 639-1 code of the language used by the application.
const std::string application_language_code_;
+ // This class observes the sync service for changes.
+ sync_driver::SyncService* sync_service_;
// The preferences services associated with the relevant profile.
PrefService* pref_service_;
// The cluster data, a map from cluster name to a vector of stars.id.
ClusterMap cluster_data_;
+ bool sync_refresh_skipped_;
+ // This holds the number of cluster refreshes needed.
+ int refreshes_needed_;
DISALLOW_COPY_AND_ASSIGN(BookmarkServerClusterService);
};