| 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 COMPONENTS_SYNC_SESSIONS_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_ | 5 #ifndef COMPONENTS_SYNC_SESSIONS_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_ |
| 6 #define COMPONENTS_SYNC_SESSIONS_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_ | 6 #define COMPONENTS_SYNC_SESSIONS_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "components/sync_sessions/revisit/page_visit_observer.h" | 13 #include "components/sync_sessions/revisit/page_visit_observer.h" |
| 14 | 14 |
| 15 class GURL; | 15 class GURL; |
| 16 | 16 |
| 17 namespace sessions { | 17 namespace sessions { |
| 18 struct SessionTab; | 18 struct SessionTab; |
| 19 } // namespace sessions | 19 } // namespace sessions |
| 20 | 20 |
| 21 namespace sync_driver { | |
| 22 struct SyncedSession; | |
| 23 } // namespace sync_driver | |
| 24 | |
| 25 namespace sync_sessions { | 21 namespace sync_sessions { |
| 26 | 22 |
| 27 class CurrentTabMatcher; | 23 class CurrentTabMatcher; |
| 28 class OffsetTabMatcher; | 24 class OffsetTabMatcher; |
| 25 struct SyncedSession; |
| 29 | 26 |
| 30 // A simple interface to abstract away who is providing sessions. | 27 // A simple interface to abstract away who is providing sessions. |
| 31 class ForeignSessionsProvider { | 28 class ForeignSessionsProvider { |
| 32 public: | 29 public: |
| 33 // Fills the already instantiated passed vector with all foreign sessions. | 30 // Fills the already instantiated passed vector with all foreign sessions. |
| 34 // Returned boolean representes if there were foreign sessions and the vector | 31 // Returned boolean representes if there were foreign sessions and the vector |
| 35 // should be examimed. | 32 // should be examimed. |
| 36 virtual bool GetAllForeignSessions( | 33 virtual bool GetAllForeignSessions( |
| 37 std::vector<const sync_driver::SyncedSession*>* sessions) = 0; | 34 std::vector<const SyncedSession*>* sessions) = 0; |
| 38 virtual ~ForeignSessionsProvider() {} | 35 virtual ~ForeignSessionsProvider() {} |
| 39 }; | 36 }; |
| 40 | 37 |
| 41 // An implementation of PageVisitObserver that checks the given page's url | 38 // An implementation of PageVisitObserver that checks the given page's url |
| 42 // against in memory session information to detect if we've seen this page | 39 // against in memory session information to detect if we've seen this page |
| 43 // before, constituting a revisit. Then histogram information is emitted about | 40 // before, constituting a revisit. Then histogram information is emitted about |
| 44 // this page navigation. | 41 // this page navigation. |
| 45 class SessionsPageRevisitObserver | 42 class SessionsPageRevisitObserver |
| 46 : public PageVisitObserver, | 43 : public PageVisitObserver, |
| 47 public base::SupportsWeakPtr<SessionsPageRevisitObserver> { | 44 public base::SupportsWeakPtr<SessionsPageRevisitObserver> { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 60 void CheckForRevisit(const GURL& url, const TransitionType transition); | 57 void CheckForRevisit(const GURL& url, const TransitionType transition); |
| 61 | 58 |
| 62 std::unique_ptr<ForeignSessionsProvider> provider_; | 59 std::unique_ptr<ForeignSessionsProvider> provider_; |
| 63 | 60 |
| 64 DISALLOW_COPY_AND_ASSIGN(SessionsPageRevisitObserver); | 61 DISALLOW_COPY_AND_ASSIGN(SessionsPageRevisitObserver); |
| 65 }; | 62 }; |
| 66 | 63 |
| 67 } // namespace sync_sessions | 64 } // namespace sync_sessions |
| 68 | 65 |
| 69 #endif // COMPONENTS_SYNC_SESSIONS_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_ | 66 #endif // COMPONENTS_SYNC_SESSIONS_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_ |
| OLD | NEW |