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 #ifndef COMPONENTS_SYNC_SESSIONS_SYNC_SESSIONS_METRICS_H_ | 5 #ifndef COMPONENTS_SYNC_SESSIONS_SYNC_SESSIONS_METRICS_H_ |
6 #define COMPONENTS_SYNC_SESSIONS_SYNC_SESSIONS_METRICS_H_ | 6 #define COMPONENTS_SYNC_SESSIONS_SYNC_SESSIONS_METRICS_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 class Time; | 11 class Time; |
12 } // namespace base | 12 } // namespace base |
13 | 13 |
14 namespace browser_sync { | 14 namespace sync_sessions { |
| 15 |
15 class SessionsSyncManager; | 16 class SessionsSyncManager; |
16 } // namespace browser_sync | |
17 | |
18 namespace sync_driver { | |
19 struct SyncedSession; | 17 struct SyncedSession; |
20 } // namespace sync_driver | |
21 | |
22 namespace sync_sessions { | |
23 | 18 |
24 class SyncSessionsMetrics { | 19 class SyncSessionsMetrics { |
25 public: | 20 public: |
26 // Records via an UMA histogram the age of the youngest foreign tab the given | 21 // Records via an UMA histogram the age of the youngest foreign tab the given |
27 // manager is aware of. No attempt is made to aquire a more recent version of | 22 // manager is aware of. No attempt is made to aquire a more recent version of |
28 // world. If anything goes wrong, such as the manager being null, no foreign | 23 // world. If anything goes wrong, such as the manager being null, no foreign |
29 // session present, or a foreign tab with a timestamp in the future then no | 24 // session present, or a foreign tab with a timestamp in the future then no |
30 // metric is emitted. | 25 // metric is emitted. |
31 static void RecordYoungestForeignTabAgeOnNTP( | 26 static void RecordYoungestForeignTabAgeOnNTP( |
32 browser_sync::SessionsSyncManager* sessions_sync_manager); | 27 SessionsSyncManager* sessions_sync_manager); |
33 | 28 |
34 private: | 29 private: |
35 friend class SyncSessionsMetricsTest; | 30 friend class SyncSessionsMetricsTest; |
36 | 31 |
37 // Returns the highest timestamp for any tab in the given sessions. Note that | 32 // Returns the highest timestamp for any tab in the given sessions. Note that |
38 // sessions should be sorted by timestamp, and session timestamps should | 33 // sessions should be sorted by timestamp, and session timestamps should |
39 // always be greater or equal to children window/tab timestamps. No navigation | 34 // always be greater or equal to children window/tab timestamps. No navigation |
40 // timestamps are checked. | 35 // timestamps are checked. |
41 static base::Time MaxTabTimestamp( | 36 static base::Time MaxTabTimestamp( |
42 const std::vector<const sync_driver::SyncedSession*>& sessions); | 37 const std::vector<const SyncedSession*>& sessions); |
43 }; | 38 }; |
44 | 39 |
45 } // namespace sync_sessions | 40 } // namespace sync_sessions |
46 | 41 |
47 #endif // COMPONENTS_SYNC_SESSIONS_SYNC_SESSIONS_METRICS_H_ | 42 #endif // COMPONENTS_SYNC_SESSIONS_SYNC_SESSIONS_METRICS_H_ |
OLD | NEW |