OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/sync_sessions_metrics.h" | 5 #include "components/sync_sessions/sync_sessions_metrics.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "components/sessions/core/session_types.h" | 14 #include "components/sessions/core/session_types.h" |
15 #include "components/sync_sessions/sessions_sync_manager.h" | 15 #include "components/sync_sessions/sessions_sync_manager.h" |
16 #include "components/sync_sessions/synced_session.h" | 16 #include "components/sync_sessions/synced_session.h" |
17 | 17 |
18 namespace sync_sessions { | 18 namespace sync_sessions { |
19 | 19 |
20 // static | 20 // static |
21 void SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP( | 21 void SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP( |
22 SessionsSyncManager* sessions_sync_manager) { | 22 SessionsSyncManager* sessions_sync_manager) { |
23 if (sessions_sync_manager != NULL) { | 23 if (sessions_sync_manager != nullptr) { |
24 std::vector<const SyncedSession*> foreign_sessions; | 24 std::vector<const SyncedSession*> foreign_sessions; |
25 sessions_sync_manager->GetAllForeignSessions(&foreign_sessions); | 25 sessions_sync_manager->GetAllForeignSessions(&foreign_sessions); |
26 base::Time best(MaxTabTimestamp(foreign_sessions)); | 26 base::Time best(MaxTabTimestamp(foreign_sessions)); |
27 base::Time now(base::Time::Now()); | 27 base::Time now(base::Time::Now()); |
28 // Don't emit metrics if the foreign tab is timestamped in the future. While | 28 // Don't emit metrics if the foreign tab is timestamped in the future. While |
29 // the timestamp is set on a different machine, and we may lose some | 29 // the timestamp is set on a different machine, and we may lose some |
30 // fraction of metrics to clock skew, we don't want the potential to have | 30 // fraction of metrics to clock skew, we don't want the potential to have |
31 // bad machines with clocks many hours off causing lots of seemingly 0 | 31 // bad machines with clocks many hours off causing lots of seemingly 0 |
32 // second entries. | 32 // second entries. |
33 if (base::Time::UnixEpoch() < best && best <= now) { | 33 if (base::Time::UnixEpoch() < best && best <= now) { |
(...skipping 19 matching lines...) Expand all Loading... |
53 for (const auto& key_value : session->windows) { | 53 for (const auto& key_value : session->windows) { |
54 for (const auto& tab : key_value.second->tabs) { | 54 for (const auto& tab : key_value.second->tabs) { |
55 best = std::max(best, tab->timestamp); | 55 best = std::max(best, tab->timestamp); |
56 } | 56 } |
57 } | 57 } |
58 } | 58 } |
59 return best; | 59 return best; |
60 } | 60 } |
61 | 61 |
62 } // namespace sync_sessions | 62 } // namespace sync_sessions |
OLD | NEW |