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 namespace bookmarks { | 13 namespace bookmarks { |
14 class BookmarkModel; | 14 class BookmarkModel; |
15 } // namespace bookmarks | 15 } // namespace bookmarks |
16 | 16 |
17 namespace history { | 17 namespace history { |
18 class HistoryService; | 18 class HistoryService; |
19 } // namespace history | 19 } // namespace history |
20 | 20 |
| 21 namespace sync_sessions { |
| 22 class SyncSessionsClient; |
| 23 } |
| 24 |
21 namespace browser_sync { | 25 namespace browser_sync { |
22 | 26 |
23 class SessionsSyncManager; | 27 class SessionsSyncManager; |
24 | 28 |
25 // This class has the job of creating and holding onto the PageVisitObservers | 29 // This class has the job of creating and holding onto the PageVisitObservers |
26 // that are to be notified on page change for purposes of instrumenting | 30 // that are to be notified on page change for purposes of instrumenting |
27 // revisists. | 31 // revisists. |
28 class PageRevisitBroadcaster { | 32 class PageRevisitBroadcaster { |
29 public: | 33 public: |
30 PageRevisitBroadcaster(SessionsSyncManager* sessions, | 34 PageRevisitBroadcaster(SessionsSyncManager* sessions, |
| 35 sync_sessions::SyncSessionsClient* sessions_client, |
31 history::HistoryService* history, | 36 history::HistoryService* history, |
32 bookmarks::BookmarkModel* bookmarks); | 37 bookmarks::BookmarkModel* bookmarks); |
33 ~PageRevisitBroadcaster(); | 38 ~PageRevisitBroadcaster(); |
34 | 39 |
35 // Broadcasts to all observers the given page visit event. Should only be | 40 // Broadcasts to all observers the given page visit event. Should only be |
36 // called when the url changes. | 41 // called when the url changes. |
37 void OnPageVisit(const GURL& url, const ui::PageTransition transition); | 42 void OnPageVisit(const GURL& url, const ui::PageTransition transition); |
38 | 43 |
39 private: | 44 private: |
40 friend class PageRevisitBroadcasterTest; | 45 friend class PageRevisitBroadcasterTest; |
41 | 46 |
42 // We convert between enums here for a couple reasons. We don't want to force | 47 // We convert between enums here for a couple reasons. We don't want to force |
43 // observers to depend on ui/, and the high bit masks don't work for emitting | 48 // observers to depend on ui/, and the high bit masks don't work for emitting |
44 // histograms. Some of the high bit masks correspond to cases we're | 49 // histograms. Some of the high bit masks correspond to cases we're |
45 // particularly interested in and want to treat as first class values. | 50 // particularly interested in and want to treat as first class values. |
46 static sync_sessions::PageVisitObserver::TransitionType ConvertTransitionEnum( | 51 static sync_sessions::PageVisitObserver::TransitionType ConvertTransitionEnum( |
47 const ui::PageTransition original); | 52 const ui::PageTransition original); |
48 | 53 |
| 54 // The client of this sync sessions datatype. |
| 55 sync_sessions::SyncSessionsClient* const sessions_client_; |
| 56 |
49 ScopedVector<sync_sessions::PageVisitObserver> revisit_observers_; | 57 ScopedVector<sync_sessions::PageVisitObserver> revisit_observers_; |
50 | 58 |
51 DISALLOW_COPY_AND_ASSIGN(PageRevisitBroadcaster); | 59 DISALLOW_COPY_AND_ASSIGN(PageRevisitBroadcaster); |
52 }; | 60 }; |
53 | 61 |
54 } // namespace browser_sync | 62 } // namespace browser_sync |
55 | 63 |
56 #endif // CHROME_BROWSER_SYNC_SESSIONS_PAGE_REVISIT_BROADCASTER_H_ | 64 #endif // CHROME_BROWSER_SYNC_SESSIONS_PAGE_REVISIT_BROADCASTER_H_ |
OLD | NEW |