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 #include "components/sync_sessions/revisit/sessions_page_revisit_observer.h" | 5 #include "components/sync_sessions/revisit/sessions_page_revisit_observer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 // We want to match tabs/navigation entries in two slightly different ways. We | 47 // We want to match tabs/navigation entries in two slightly different ways. We |
48 // value the current url/navigation entry of a tab more highly, and want to | 48 // value the current url/navigation entry of a tab more highly, and want to |
49 // actually seperate metrics from the backwards/forwards entries. And then | 49 // actually seperate metrics from the backwards/forwards entries. And then |
50 // to make things a little bit messier, we only have an accurate modified time | 50 // to make things a little bit messier, we only have an accurate modified time |
51 // for the tabs/current entries. So use index offset for forward/back entries. | 51 // for the tabs/current entries. So use index offset for forward/back entries. |
52 PageEquality page_equality(url); | 52 PageEquality page_equality(url); |
53 CurrentTabMatcher current_matcher(page_equality); | 53 CurrentTabMatcher current_matcher(page_equality); |
54 OffsetTabMatcher offset_matcher(page_equality); | 54 OffsetTabMatcher offset_matcher(page_equality); |
55 | 55 |
56 std::vector<const sync_driver::SyncedSession*> foreign_sessions; | 56 std::vector<const SyncedSession*> foreign_sessions; |
57 if (provider_->GetAllForeignSessions(&foreign_sessions)) { | 57 if (provider_->GetAllForeignSessions(&foreign_sessions)) { |
58 for (const sync_driver::SyncedSession* session : foreign_sessions) { | 58 for (const SyncedSession* session : foreign_sessions) { |
59 for (const std::pair<const SessionID::id_type, sessions::SessionWindow*>& | 59 for (const std::pair<const SessionID::id_type, sessions::SessionWindow*>& |
60 key_value : session->windows) { | 60 key_value : session->windows) { |
61 for (const sessions::SessionTab* tab : key_value.second->tabs) { | 61 for (const sessions::SessionTab* tab : key_value.second->tabs) { |
62 // These matchers look identical and could easily implement an | 62 // These matchers look identical and could easily implement an |
63 // interface and we could iterate through a vector of matchers here. | 63 // interface and we could iterate through a vector of matchers here. |
64 // However this would cause quite a bit of overhead at the inner most | 64 // However this would cause quite a bit of overhead at the inner most |
65 // loop of something that takes linear time in relation to the number | 65 // loop of something that takes linear time in relation to the number |
66 // of open foreign tabs. A small fraction of users have thousands of | 66 // of open foreign tabs. A small fraction of users have thousands of |
67 // open tabs. | 67 // open tabs. |
68 current_matcher.Check(tab); | 68 current_matcher.Check(tab); |
69 offset_matcher.Check(tab); | 69 offset_matcher.Check(tab); |
70 } | 70 } |
71 } | 71 } |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 // emit even if there are no foreign sessions so that that counts all match. | 75 // emit even if there are no foreign sessions so that that counts all match. |
76 current_matcher.Emit(transition); | 76 current_matcher.Emit(transition); |
77 offset_matcher.Emit(transition); | 77 offset_matcher.Emit(transition); |
78 | 78 |
79 base::TimeDelta duration(base::TimeTicks::Now() - start); | 79 base::TimeDelta duration(base::TimeTicks::Now() - start); |
80 UMA_HISTOGRAM_TIMES("Sync.PageRevisitSessionDuration", duration); | 80 UMA_HISTOGRAM_TIMES("Sync.PageRevisitSessionDuration", duration); |
81 } | 81 } |
82 | 82 |
83 } // namespace sync_sessions | 83 } // namespace sync_sessions |
OLD | NEW |