Chromium Code Reviews| 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..d195b5cdf97b36109690766c6051dbea3fa238d4 |
| --- /dev/null |
| +++ b/components/ntp_snippets/sessions/tab_delegate_sync_adapter.h |
| @@ -0,0 +1,50 @@ |
| +// 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 "base/callback.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 OpenTabsUIDelegate; |
| +class SyncService; |
| +} // namespace sync_driver |
| + |
| +namespace ntp_snippets { |
| + |
| +// Adapter that sits on top of SyncService and provides simplified notifications |
| +// when foreign tab data may have changed. |
| +class TabDelegateSyncAdapter |
| + : public sync_driver::SyncServiceObserver, |
| + public ForeignSessionsSuggestionsProvider::OpenTabsUIDelegateProvider { |
| + public: |
| + explicit TabDelegateSyncAdapter(sync_driver::SyncService* sync_service); |
| + ~TabDelegateSyncAdapter() override; |
| + |
| + // OpenTabsUIDelegateProvider implementation. |
| + sync_driver::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; |
| + void SubscribeForForeignTabChange( |
| + const OnChangeWithDelegate& change_callback) override; |
| + |
| + // sync_driver::SyncServiceObserver implementation. |
|
Marc Treib
2016/09/16 12:26:49
These can (and IMO should) be private.
skym
2016/09/16 18:18:50
Can you explain why these should be private? Like
tschumann
2016/09/17 15:52:56
I guess you could argue that we use the adapter to
Marc Treib
2016/09/19 09:24:08
Pretty much what Tim says: To me, it's an implemen
skym
2016/09/19 18:54:47
Done.
skym
2016/09/19 18:54:47
Done.
|
| + void OnStateChanged() override; |
| + void OnSyncConfigurationCompleted() override; |
| + void OnForeignSessionUpdated() override; |
| + |
| + private: |
| + void InvokeCallback(); |
| + |
| + sync_driver::SyncService* sync_service_; |
| + OnChangeWithDelegate change_callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TabDelegateSyncAdapter); |
| +}; |
| + |
| +} // namespace ntp_snippets |
| + |
| +#endif // COMPONENTS_NTP_SNIPPETS_SESSIONS_TAB_DELEGATE_SYNC_ADAPTER_H_ |