| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PAGE_REVISIT_BROADCASTER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_PAGE_REVISIT_BROADCASTER_H_ |
| 6 #define CHROME_BROWSER_SYNC_SESSIONS_PAGE_REVISIT_BROADCASTER_H_ | 6 #define CHROME_BROWSER_SYNC_SESSIONS_PAGE_REVISIT_BROADCASTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "components/sync_sessions/revisit/page_visit_observer.h" | 9 #include "components/sync_sessions/revisit/page_visit_observer.h" |
| 10 #include "ui/base/page_transition_types.h" | 10 #include "ui/base/page_transition_types.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 class Profile; | 13 class Profile; |
| 14 class PrefService; | 14 class PrefService; |
| 15 | 15 |
| 16 namespace sync_sessions { |
| 17 class SyncSessionsClient; |
| 18 } |
| 19 |
| 16 namespace browser_sync { | 20 namespace browser_sync { |
| 17 | 21 |
| 18 class SessionsSyncManager; | 22 class SessionsSyncManager; |
| 19 | 23 |
| 20 // This class has the job of creating and holding onto the PageVisitObservers | 24 // This class has the job of creating and holding onto the PageVisitObservers |
| 21 // that are to be notified on page change for purposes of instrumenting | 25 // that are to be notified on page change for purposes of instrumenting |
| 22 // revisists. | 26 // revisists. |
| 23 class PageRevisitBroadcaster { | 27 class PageRevisitBroadcaster { |
| 24 public: | 28 public: |
| 25 PageRevisitBroadcaster(SessionsSyncManager* manager, Profile* profile); | 29 PageRevisitBroadcaster(SessionsSyncManager* manager, |
| 30 sync_sessions::SyncSessionsClient* sessions_client, |
| 31 Profile* profile); |
| 26 ~PageRevisitBroadcaster(); | 32 ~PageRevisitBroadcaster(); |
| 27 | 33 |
| 28 // Broadcasts to all observers the given page visit event. Should only be | 34 // Broadcasts to all observers the given page visit event. Should only be |
| 29 // called when the url changes. | 35 // called when the url changes. |
| 30 void OnPageVisit(const GURL& url, const ui::PageTransition transition); | 36 void OnPageVisit(const GURL& url, const ui::PageTransition transition); |
| 31 | 37 |
| 32 private: | 38 private: |
| 33 friend class PageRevisitBroadcasterTest; | 39 friend class PageRevisitBroadcasterTest; |
| 34 | 40 |
| 35 // We convert between enums here for a couple reasons. We don't want to force | 41 // We convert between enums here for a couple reasons. We don't want to force |
| 36 // observers to depend on ui/, and the high bit masks don't work for emitting | 42 // observers to depend on ui/, and the high bit masks don't work for emitting |
| 37 // histograms. Some of the high bit masks correspond to cases we're | 43 // histograms. Some of the high bit masks correspond to cases we're |
| 38 // particularly interested in and want to treat as first class values. | 44 // particularly interested in and want to treat as first class values. |
| 39 static sync_sessions::PageVisitObserver::TransitionType ConvertTransitionEnum( | 45 static sync_sessions::PageVisitObserver::TransitionType ConvertTransitionEnum( |
| 40 const ui::PageTransition original); | 46 const ui::PageTransition original); |
| 41 | 47 |
| 48 // The client of this sync sessions datatype. |
| 49 sync_sessions::SyncSessionsClient* const sessions_client_; |
| 50 |
| 42 ScopedVector<sync_sessions::PageVisitObserver> revisit_observers_; | 51 ScopedVector<sync_sessions::PageVisitObserver> revisit_observers_; |
| 43 | 52 |
| 44 DISALLOW_COPY_AND_ASSIGN(PageRevisitBroadcaster); | 53 DISALLOW_COPY_AND_ASSIGN(PageRevisitBroadcaster); |
| 45 }; | 54 }; |
| 46 | 55 |
| 47 } // namespace browser_sync | 56 } // namespace browser_sync |
| 48 | 57 |
| 49 #endif // CHROME_BROWSER_SYNC_SESSIONS_PAGE_REVISIT_BROADCASTER_H_ | 58 #endif // CHROME_BROWSER_SYNC_SESSIONS_PAGE_REVISIT_BROADCASTER_H_ |
| OLD | NEW |