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

Unified Diff: chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.cc

Issue 539173004: Bring up of the enhanced bookmarks cluster service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@intermediary2
Patch Set: micro-nit Created 6 years, 2 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: chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.cc
diff --git a/chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.cc b/chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8f1540deadcc474b0fe9f89a4bfa0c63d57720c8
--- /dev/null
+++ b/chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.cc
@@ -0,0 +1,51 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.h"
+
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "components/enhanced_bookmarks/enhanced_bookmark_model.h"
+
+namespace enhanced_bookmarks {
+
+ChromeBookmarkServerClusterService::ChromeBookmarkServerClusterService(
+ const std::string& application_language_code,
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter,
+ ProfileOAuth2TokenService* token_service,
+ SigninManagerBase* signin_manager,
+ EnhancedBookmarkModel* enhanced_bookmark_model,
+ PrefService* pref_service,
+ ProfileSyncService* sync_service)
+ : BookmarkServerClusterService(application_language_code,
+ request_context_getter,
+ token_service,
+ signin_manager,
+ enhanced_bookmark_model,
+ pref_service),
+ sync_service_(sync_service) {
+ if (sync_service_)
+ sync_service_->AddObserver(this);
+}
+
+ChromeBookmarkServerClusterService::~ChromeBookmarkServerClusterService() {
+ if (sync_service_)
+ sync_service_->RemoveObserver(this);
+}
+
+void ChromeBookmarkServerClusterService::OnStateChanged() {
+ // Do nothing.
+}
+
+void ChromeBookmarkServerClusterService::OnSyncCycleCompleted() {
+ // The stars cluster API relies on the information in chrome-sync. Sending a
+ // cluster request immediately after a bookmark is changed from the bookmark
+ // observer notification will yield the wrong results. The request must be
+ // delayed until the sync cycle has completed.
+ // TODO(noyau): This might happen too often, need a way to coalesce and delay
+ // the notifications.
+ if (model_->loaded())
+ TriggerTokenRequest(false);
+}
+
+} // namespace enhanced_bookmarks

Powered by Google App Engine
This is Rietveld 408576698