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.
5 #ifndef COMPONENTS_SYNC_DRIVER_CURRENT_TAB_MATCHER_H_
6 #define COMPONENTS_SYNC_DRIVER_CURRENT_TAB_MATCHER_H_
8 #include "base/gtest_prod_util.h"
9 #include "components/sessions/session_types.h"
10 #include "components/sync_driver/revisit/page_equality.h"
11 #include "components/sync_driver/revisit/page_visit_observer.h"
13 namespace sync_driver
{
15 // This class checks the current navigation entry for the given tabs to see if
16 // they correspond to the same page we were constructed to look for. Upon
17 // finding multiple matches, the most recently modified will be chosen.
18 class CurrentTabMatcher
{
20 explicit CurrentTabMatcher(const PageEquality
& page_equality
);
21 void Check(const sessions::SessionTab
* tab
);
22 void Emit(const PageVisitObserver::TransitionType transition
);
25 FRIEND_TEST_ALL_PREFIXES(CurrentTabMatcherTest
, Timestamp
);
27 const PageEquality page_equality_
;
28 const sessions::SessionTab
* most_recent_match_
= nullptr;
30 DISALLOW_COPY_AND_ASSIGN(CurrentTabMatcher
);
33 } // namespace sync_driver
35 #endif // COMPONENTS_SYNC_DRIVER_CURRENT_TAB_MATCHER_H_