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

Side by Side Diff: components/sync_driver/revisit/current_tab_matcher.cc

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 #include "components/sync_driver/revisit/current_tab_matcher.h"
6
7 #include "base/metrics/histogram_macros.h"
8 #include "base/time/time.h"
9 #include "components/sessions/core/serialized_navigation_entry.h"
10
11 namespace sync_driver {
12
13 CurrentTabMatcher::CurrentTabMatcher(const PageEquality& page_equality)
14 : page_equality_(page_equality) {}
15
16 void CurrentTabMatcher::Check(const sessions::SessionTab* tab) {
17 if (tab->navigations.empty()) {
18 return;
19 }
20 const sessions::SerializedNavigationEntry& currentEntry =
21 tab->navigations[tab->normalized_navigation_index()];
22 // Cannot rely on SerializedNavigationEntry timestamps, they're
23 // not set for foreign sessions. Instead rely on tab timestamps.
24 if (page_equality_.IsSamePage(currentEntry.virtual_url()) &&
25 (most_recent_match_ == nullptr ||
26 tab->timestamp > most_recent_match_->timestamp)) {
27 most_recent_match_ = tab;
28 }
29 }
30
31 void CurrentTabMatcher::Emit(
32 const PageVisitObserver::TransitionType transition) {
33 if (most_recent_match_ == nullptr) {
34 UMA_HISTOGRAM_ENUMERATION("Sync.PageRevisitTabMissTransition", transition,
35 PageVisitObserver::kTransitionTypeLast);
36 } else {
37 base::TimeDelta age(base::Time::Now() - most_recent_match_->timestamp);
38 UMA_HISTOGRAM_CUSTOM_TIMES("Sync.PageRevisitTabMatchAge", age,
39 base::TimeDelta::FromSeconds(1),
40 base::TimeDelta::FromDays(14), 100);
41 UMA_HISTOGRAM_ENUMERATION("Sync.PageRevisitTabMatchTransition", transition,
42 PageVisitObserver::kTransitionTypeLast);
43 }
44 }
45
46 } // namespace sync_driver
OLDNEW
« no previous file with comments | « components/sync_driver/revisit/current_tab_matcher.h ('k') | components/sync_driver/revisit/current_tab_matcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698