| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 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 SyncedSession* session : foreign_sessions) { | 58 for (const SyncedSession* session : foreign_sessions) { |
| 59 for (const auto& key_value : session->windows) { | 59 for (const auto& key_value : session->windows) { |
| 60 for (const auto& tab : key_value.second->tabs) { | 60 for (const auto& tab : key_value.second->wrapped_window.tabs) { |
| 61 // These matchers look identical and could easily implement an | 61 // These matchers look identical and could easily implement an |
| 62 // interface and we could iterate through a vector of matchers here. | 62 // interface and we could iterate through a vector of matchers here. |
| 63 // However this would cause quite a bit of overhead at the inner most | 63 // However this would cause quite a bit of overhead at the inner most |
| 64 // loop of something that takes linear time in relation to the number | 64 // loop of something that takes linear time in relation to the number |
| 65 // of open foreign tabs. A small fraction of users have thousands of | 65 // of open foreign tabs. A small fraction of users have thousands of |
| 66 // open tabs. | 66 // open tabs. |
| 67 current_matcher.Check(tab.get()); | 67 current_matcher.Check(tab.get()); |
| 68 offset_matcher.Check(tab.get()); | 68 offset_matcher.Check(tab.get()); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 // emit even if there are no foreign sessions so that that counts all match. | 74 // emit even if there are no foreign sessions so that that counts all match. |
| 75 current_matcher.Emit(transition); | 75 current_matcher.Emit(transition); |
| 76 offset_matcher.Emit(transition); | 76 offset_matcher.Emit(transition); |
| 77 | 77 |
| 78 base::TimeDelta duration(base::TimeTicks::Now() - start); | 78 base::TimeDelta duration(base::TimeTicks::Now() - start); |
| 79 UMA_HISTOGRAM_TIMES("Sync.PageRevisitSessionDuration", duration); | 79 UMA_HISTOGRAM_TIMES("Sync.PageRevisitSessionDuration", duration); |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace sync_sessions | 82 } // namespace sync_sessions |
| OLD | NEW |