Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: components/scheduler/renderer/user_model.h

Issue 1320633002: Optimize for TouchStart responsiveness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduced a UserModel class Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 processed an input event. Called by the compositor
23 // (impl) thread. Note it's expected that every call to
24 // DidHandleInputEventOnCompositorThread where |event_state| is
25 // EVENT_FORWARDED_TO_MAIN_THREAD will be followed by a corresponding call
26 // to DidHandleInputEventOnMainThread.
27 void DidHandleInputEventOnCompositorThread(
Sami 2015/08/27 15:15:59 This is called on the impl thread but it doesn't l
alex clarke (OOO till 29th) 2015/09/03 10:34:25 This class isn't by itself thread safe. However it
28 blink::WebInputEvent::Type type,
29 RendererScheduler::InputEventState input_event_state,
30 const base::TimeTicks now);
31
32 // Tells us that the system processed an input event.
33 void DidHandleInputEventOnMainThread(const base::TimeTicks now);
34
35 // Returns the amount of time left in the current input escalated priority
36 // policy. Can be called from any thread.
37 base::TimeDelta TimeLeftInInputEscalatedPolicy(base::TimeTicks now) const;
38
39 // Tries to guess if a Touchstart is expected soon. Currently this is
40 // very simple, but one day I hope to do something more sophisticated here.
41 // The prediction may change after |prediction_valid_duration| has elapsed.
42 bool TouchStartExpectedSoon(RendererScheduler::UseCase use_case,
Sami 2015/08/27 15:15:59 nit: Maybe IsTouchStartExpectedSoon() to highlight
alex clarke (OOO till 29th) 2015/09/03 10:34:25 Done.
43 const base::TimeTicks now,
44 base::TimeDelta* prediction_valid_duration) const;
45
46 void AsValueInto(base::trace_event::TracedValue* state) const;
47
48 // The time we should stay in a priority-escalated mode after an input event.
49 static const int kPriorityEscalationAfterInputMillis = 100;
50
51 // TODO(alexclarke): Get a real number on actual data.
52 static const int kMinimumTypicalScrollDurationMillis = 500;
53
54 // We consider further input invents to be likely if the user has interacted
Sami 2015/08/27 15:15:59 typo: events
alex clarke (OOO till 29th) 2015/09/03 10:34:25 Done.
55 // with the device in the past two seconds.
56 // TODO(alexclarke): Get a real number based on actual data.
57 static const int kExpectSubsequentInputMillis = 2000;
58
59 private:
60 int pending_main_thread_input_event_count_;
Sami 2015/08/27 15:15:59 It feels like this shouldn't be part of the user m
61 base::TimeTicks last_input_signal_time_;
62 base::TimeTicks last_touchstart_time_;
63
64 DISALLOW_COPY_AND_ASSIGN(UserModel);
65 };
66
67 } // namespace scheduler
68
69 #endif // COMPONENTS_SCHEDULER_RENDERER_USER_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698