Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: components/sync_driver/revisit/sessions_page_revisit_observer.h

Issue 1387253004: [Sync] Creating sync_sessions component, moving revisit logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing test_support target. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_SYNC_DRIVER_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_
6 #define COMPONENTS_SYNC_DRIVER_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_
7
8 #include <vector>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/sync_driver/revisit/page_visit_observer.h"
13 #include "url/gurl.h"
14
15 namespace sessions {
16 struct SessionTab;
17 } // namespace sessions
18
19 namespace sync_driver {
20
21 struct SyncedSession;
22
23 class CurrentTabMatcher;
24 class OffsetTabMatcher;
25
26 // A simple interface to abstract away who is providing sessions.
27 class ForeignSessionsProvider {
28 public:
29 // Fills the already instantiated passed vector with all foreign sessions.
30 // Returned boolean representes if there were foreign sessions and the vector
31 // should be examimed.
32 virtual bool GetAllForeignSessions(
33 std::vector<const sync_driver::SyncedSession*>* sessions) = 0;
34 virtual ~ForeignSessionsProvider() {}
35 };
36
37 // An implementation of PageVisitObserver that checks the given page's url
38 // against in memory session information to detect if we've seen this page
39 // before, constituting a revisit. Then histogram information is emitted about
40 // this page navigation.
41 class SessionsPageRevisitObserver
42 : public PageVisitObserver,
43 public base::SupportsWeakPtr<SessionsPageRevisitObserver> {
44 public:
45 explicit SessionsPageRevisitObserver(
46 scoped_ptr<ForeignSessionsProvider> provider);
47 ~SessionsPageRevisitObserver() override;
48 void OnPageVisit(const GURL& url, const TransitionType transition) override;
49
50 private:
51 friend class SessionsPageRevisitObserverTest;
52
53 // Although the signature is identical to OnPageVisit(...), this method
54 // actually does all of the work. The assumption is that this method is the
55 // target of a PostTask call coming from OnPageVisit(...).
56 void CheckForRevisit(const GURL& url, const TransitionType transition);
57
58 scoped_ptr<ForeignSessionsProvider> provider_;
59
60 DISALLOW_COPY_AND_ASSIGN(SessionsPageRevisitObserver);
61 };
62
63 } // namespace sync_driver
64
65 #endif // COMPONENTS_SYNC_DRIVER_REVISIT_SESSIONS_PAGE_REVISIT_OBSERVER_H_
OLDNEW
« no previous file with comments | « components/sync_driver/revisit/page_visit_observer.h ('k') | components/sync_driver/revisit/sessions_page_revisit_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698