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 CHROME_BROWSER_PAGE_LOAD_METRICS_USER_INPUT_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_USER_INPUT_TRACKER_H_ |
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_USER_INPUT_TRACKER_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_USER_INPUT_TRACKER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // rapid succession, e.g. JS code that dispatches new navigation requests in a | 30 // rapid succession, e.g. JS code that dispatches new navigation requests in a |
31 // tight loop can result in dozens of programmatically generated navigations | 31 // tight loop can result in dozens of programmatically generated navigations |
32 // being user initiated. | 32 // being user initiated. |
33 // | 33 // |
34 // Note that UserInputTracker does not keep track of input events processed by | 34 // Note that UserInputTracker does not keep track of input events processed by |
35 // the browser, such as interactions with the Chrome browser UI (e.g. clicking | 35 // the browser, such as interactions with the Chrome browser UI (e.g. clicking |
36 // the 'reload' button). | 36 // the 'reload' button). |
37 class UserInputTracker { | 37 class UserInputTracker { |
38 public: | 38 public: |
39 // Only public for tests. | 39 // Only public for tests. |
40 static const size_t kMaxTrackedEvents; | 40 static constexpr size_t kMaxTrackedEvents = 100; |
41 static base::TimeTicks GetEventTime(const blink::WebInputEvent& event); | 41 static base::TimeTicks GetEventTime(const blink::WebInputEvent& event); |
42 | 42 |
43 // Given a time, round to the nearest rate-limited offset. UserInputTracker | 43 // Given a time, round to the nearest rate-limited offset. UserInputTracker |
44 // rate limits events, such that at most one event will be recorded per every | 44 // rate limits events, such that at most one event will be recorded per every |
45 // 20ms. RoundToRateLimitedOffset round a TimeTicks down to its nearest whole | 45 // 20ms. RoundToRateLimitedOffset round a TimeTicks down to its nearest whole |
46 // 20ms. | 46 // 20ms. |
47 static base::TimeTicks RoundToRateLimitedOffset(base::TimeTicks time); | 47 static base::TimeTicks RoundToRateLimitedOffset(base::TimeTicks time); |
48 | 48 |
49 UserInputTracker(); | 49 UserInputTracker(); |
50 ~UserInputTracker(); | 50 ~UserInputTracker(); |
(...skipping 19 matching lines...) Expand all Loading... |
70 | 70 |
71 std::vector<base::TimeTicks> sorted_event_times_; | 71 std::vector<base::TimeTicks> sorted_event_times_; |
72 base::TimeTicks most_recent_consumed_time_; | 72 base::TimeTicks most_recent_consumed_time_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(UserInputTracker); | 74 DISALLOW_COPY_AND_ASSIGN(UserInputTracker); |
75 }; | 75 }; |
76 | 76 |
77 } // namespace page_load_metrics | 77 } // namespace page_load_metrics |
78 | 78 |
79 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_USER_INPUT_TRACKER_H_ | 79 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_USER_INPUT_TRACKER_H_ |
OLD | NEW |