Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / sync_driver / revisit / offset_tab_matcher.h
blobd0789cf40065cd96228f0a3e69dbe5e0c90d88a2
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_OFFSET_TAB_MATCHER_H_
6 #define COMPONENTS_SYNC_DRIVER_OFFSET_TAB_MATCHER_H_
8 #include "components/sessions/session_types.h"
9 #include "components/sync_driver/revisit/page_equality.h"
10 #include "components/sync_driver/revisit/page_visit_observer.h"
12 namespace sync_driver {
14 // This class looks for tabs that have matching pages that are not the current
15 // navigation entry. This corresponds to the pages you would arrive at if you
16 // pressed the forward/backwards buttons. The goal is to emit metrics for the
17 // most recent/current entry. So to break ties of multiple entries that match,
18 // first the timestamp on the tab is used, followed by the index of the entry.
19 // This isn't necessarily perfect at determining the most recent, but it should
20 // be a reasonable enough approximation.
21 class OffsetTabMatcher {
22 public:
23 explicit OffsetTabMatcher(const PageEquality& page_equality);
24 void Check(const sessions::SessionTab* tab);
25 void Emit(const PageVisitObserver::TransitionType transition);
27 private:
28 int Clamp(int input, int lower, int upper);
30 const PageEquality page_equality_;
31 const sessions::SessionTab* best_tab_ = nullptr;
32 // Invalid while best_tab_ is nullptr.
33 int best_offset_ = 0;
35 DISALLOW_COPY_AND_ASSIGN(OffsetTabMatcher);
38 } // namespace sync_driver
40 #endif // COMPONENTS_SYNC_DRIVER_OFFSET_TAB_MATCHER_H_