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

Unified Diff: components/ntp_snippets/sessions/tab_delegate_sync_adapter.h

Issue 2279123002: [Sync] Initial implementation of foreign sessions suggestions provider. (Closed)
Patch Set: Updating for comments, again! Created 4 years, 3 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: components/ntp_snippets/sessions/tab_delegate_sync_adapter.h
diff --git a/components/ntp_snippets/sessions/tab_delegate_sync_adapter.h b/components/ntp_snippets/sessions/tab_delegate_sync_adapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..9a9f79a39742c7bafe238f1edaffbda6c2da52d4
--- /dev/null
+++ b/components/ntp_snippets/sessions/tab_delegate_sync_adapter.h
@@ -0,0 +1,53 @@
+// Copyright 2016 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.
+
+#ifndef COMPONENTS_NTP_SNIPPETS_SESSIONS_TAB_DELEGATE_SYNC_ADAPTER_H_
+#define COMPONENTS_NTP_SNIPPETS_SESSIONS_TAB_DELEGATE_SYNC_ADAPTER_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.h"
+#include "components/sync/driver/sync_service_observer.h"
+
+namespace sync_driver {
+class SyncService;
+} // namespace sync_driver
+
+namespace ntp_snippets {
+
+// Adapter that sits on top of SyncService and OpenTabsUIDelegate and provides
+// simplified notifications and accessors for foreign tabs data.
+class TabDelegateSyncAdapter : public sync_driver::SyncServiceObserver,
+ public ForeignSessionsProvider {
+ public:
+ explicit TabDelegateSyncAdapter(sync_driver::SyncService* sync_service);
+ ~TabDelegateSyncAdapter() override;
+
+ // ForeignSessionsProvider implementation.
+ bool HasSessionsData() override;
+ std::vector<const sync_sessions::SyncedSession*> GetAllForeignSessions()
+ override;
+ void SubscribeForForeignTabChange(
+ const base::Closure& change_callback) override;
+
+ private:
+ // sync_driver::SyncServiceObserver implementation.
+ void OnStateChanged() override;
+ void OnSyncConfigurationCompleted() override;
+ void OnForeignSessionUpdated() override;
+
+ void InvokeCallback();
+
+ sync_driver::SyncService* sync_service_;
+ base::Closure change_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabDelegateSyncAdapter);
+};
+
+} // namespace ntp_snippets
+
+#endif // COMPONENTS_NTP_SNIPPETS_SESSIONS_TAB_DELEGATE_SYNC_ADAPTER_H_

Powered by Google App Engine
This is Rietveld 408576698