| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ |
| 6 #define CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ | 6 #define CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <set> | 9 #include <set> |
| 9 | 10 |
| 10 #include "base/callback_list.h" | 11 #include "base/callback_list.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "components/sync_sessions/sessions_sync_manager.h" | 14 #include "components/sync_sessions/sessions_sync_manager.h" |
| 14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 16 | 17 |
| 17 class GURL; | 18 class GURL; |
| 18 class Profile; | 19 class Profile; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class WebContents; | 22 class WebContents; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace sync_sessions { | 25 namespace sync_sessions { |
| 26 |
| 25 class SyncSessionsClient; | 27 class SyncSessionsClient; |
| 26 } | |
| 27 | |
| 28 namespace browser_sync { | |
| 29 | 28 |
| 30 // A SessionsSyncManager::LocalEventRouter that drives session sync via | 29 // A SessionsSyncManager::LocalEventRouter that drives session sync via |
| 31 // the NotificationService. | 30 // the NotificationService. |
| 32 class NotificationServiceSessionsRouter | 31 class NotificationServiceSessionsRouter |
| 33 : public LocalSessionEventRouter, | 32 : public LocalSessionEventRouter, |
| 34 public content::NotificationObserver { | 33 public content::NotificationObserver { |
| 35 public: | 34 public: |
| 36 NotificationServiceSessionsRouter( | 35 NotificationServiceSessionsRouter( |
| 37 Profile* profile, | 36 Profile* profile, |
| 38 sync_sessions::SyncSessionsClient* sessions_client_, | 37 SyncSessionsClient* sessions_client_, |
| 39 const syncer::SyncableService::StartSyncFlare& flare); | 38 const syncer::SyncableService::StartSyncFlare& flare); |
| 40 ~NotificationServiceSessionsRouter() override; | 39 ~NotificationServiceSessionsRouter() override; |
| 41 | 40 |
| 42 // content::NotificationObserver implementation. | 41 // content::NotificationObserver implementation. |
| 43 // BrowserSessionProvider -> sync API model change application. | 42 // BrowserSessionProvider -> sync API model change application. |
| 44 void Observe(int type, | 43 void Observe(int type, |
| 45 const content::NotificationSource& source, | 44 const content::NotificationSource& source, |
| 46 const content::NotificationDetails& details) override; | 45 const content::NotificationDetails& details) override; |
| 47 | 46 |
| 48 // SessionsSyncManager::LocalEventRouter implementation. | 47 // SessionsSyncManager::LocalEventRouter implementation. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 61 // (e.g. http://www.google.com) and the given icon URL (e.g. | 60 // (e.g. http://www.google.com) and the given icon URL (e.g. |
| 62 // http://www.google.com/favicon.ico) have changed. It is valid to call | 61 // http://www.google.com/favicon.ico) have changed. It is valid to call |
| 63 // OnFaviconsChanged() with non-empty |page_urls| and an empty |icon_url| | 62 // OnFaviconsChanged() with non-empty |page_urls| and an empty |icon_url| |
| 64 // and vice versa. | 63 // and vice versa. |
| 65 void OnFaviconsChanged(const std::set<GURL>& page_urls, | 64 void OnFaviconsChanged(const std::set<GURL>& page_urls, |
| 66 const GURL& icon_url); | 65 const GURL& icon_url); |
| 67 | 66 |
| 68 LocalSessionEventHandler* handler_; | 67 LocalSessionEventHandler* handler_; |
| 69 content::NotificationRegistrar registrar_; | 68 content::NotificationRegistrar registrar_; |
| 70 Profile* const profile_; | 69 Profile* const profile_; |
| 71 sync_sessions::SyncSessionsClient* const sessions_client_; | 70 SyncSessionsClient* const sessions_client_; |
| 72 syncer::SyncableService::StartSyncFlare flare_; | 71 syncer::SyncableService::StartSyncFlare flare_; |
| 73 | 72 |
| 74 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&, | 73 std::unique_ptr<base::CallbackList<void(const std::set<GURL>&, |
| 75 const GURL&)>::Subscription> | 74 const GURL&)>::Subscription> |
| 76 favicon_changed_subscription_; | 75 favicon_changed_subscription_; |
| 77 | 76 |
| 78 base::WeakPtrFactory<NotificationServiceSessionsRouter> weak_ptr_factory_; | 77 base::WeakPtrFactory<NotificationServiceSessionsRouter> weak_ptr_factory_; |
| 79 | 78 |
| 80 DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter); | 79 DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter); |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 } // namespace browser_sync | 82 } // namespace sync_sessions |
| 84 | 83 |
| 85 #endif // CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ | 84 #endif // CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ |
| OLD | NEW |