OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_SCHEDULER_RENDERER_USER_MODEL_H_ | |
6 #define COMPONENTS_SCHEDULER_RENDERER_USER_MODEL_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/trace_event/trace_event.h" | |
10 #include "base/trace_event/trace_event_argument.h" | |
11 #include "components/scheduler/renderer/renderer_scheduler.h" | |
12 #include "components/scheduler/scheduler_export.h" | |
13 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
14 | |
15 namespace scheduler { | |
16 | |
17 class SCHEDULER_EXPORT UserModel { | |
18 public: | |
19 UserModel(); | |
20 ~UserModel(); | |
21 | |
22 // Tells us that the system started processing an input event. Must be paired | |
23 // with a call to DidFinishProcessingInputEvent. | |
24 void DidStartProcessingInputEvent(blink::WebInputEvent::Type type, | |
25 const base::TimeTicks now); | |
26 | |
27 // Tells us that the system finished processing an input event. | |
28 void DidFinishProcessingInputEvent(const base::TimeTicks now); | |
29 | |
30 // Returns the amount of time left in the current input escalated priority | |
31 // policy. | |
32 base::TimeDelta TimeLeftInInputEscalatedPolicy(base::TimeTicks now) const; | |
Sami
2015/09/04 10:58:21
It feels like the user model shouldn't know anythi
alex clarke (OOO till 29th)
2015/09/07 11:09:27
Done.
| |
33 | |
34 // Tries to guess if a Touchstart is expected soon. Currently this is | |
35 // very simple, but one day I hope to do something more sophisticated here. | |
36 // The prediction may change after |prediction_valid_duration| has elapsed. | |
37 bool IsTouchStartExpectedSoon( | |
Sami
2015/09/04 10:58:21
Similarly the reason why TouchStart is special is
alex clarke (OOO till 29th)
2015/09/07 11:09:27
Done.
| |
38 RendererScheduler::UseCase use_case, | |
39 const base::TimeTicks now, | |
40 base::TimeDelta* prediction_valid_duration) const; | |
41 | |
42 void AsValueInto(base::trace_event::TracedValue* state) const; | |
43 | |
44 // The time we should stay in a priority-escalated mode after an input event. | |
45 static const int kPriorityEscalationAfterInputMillis = 100; | |
46 | |
47 // TODO(alexclarke): Get a real number on actual data. | |
48 static const int kMinimumTypicalScrollDurationMillis = 500; | |
49 | |
50 // We consider further input events to be likely if the user has interacted | |
51 // with the device in the past two seconds. | |
52 // TODO(alexclarke): Get a real number based on actual data. | |
53 static const int kExpectSubsequentInputMillis = 2000; | |
54 | |
55 private: | |
56 int pending_input_event_count_; | |
57 base::TimeTicks last_input_signal_time_; | |
58 base::TimeTicks last_touchstart_time_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(UserModel); | |
61 }; | |
62 | |
63 } // namespace scheduler | |
64 | |
65 #endif // COMPONENTS_SCHEDULER_RENDERER_USER_MODEL_H_ | |
OLD | NEW |