Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRAC KER_H_ | |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRAC KER_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/time/time.h" | |
| 11 #include "public/platform/WebCommon.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 namespace scheduler { | |
| 15 | |
| 16 // This class tracks renderer load level. | |
|
Sami
2016/08/22 14:33:16
nit: This comment basically just repeats the class
altimin
2016/08/22 15:36:24
Done.
| |
| 17 // In order to avoid bias it reports load level at regular intervals. | |
| 18 class BLINK_PLATFORM_EXPORT RendererLoadTracker { | |
|
Sami
2016/08/22 14:33:16
Since this only tracks the main thread instead of
altimin
2016/08/22 15:36:24
Done.
| |
| 19 public: | |
| 20 // Callback is called with (current_time, load_level) parameters. | |
| 21 using Callback = base::Callback<void(base::TimeTicks, double)>; | |
| 22 | |
| 23 RendererLoadTracker(base::TimeTicks now, const Callback& callback); | |
| 24 ~RendererLoadTracker(); | |
| 25 | |
| 26 void Pause(base::TimeTicks now); | |
| 27 void Resume(base::TimeTicks now); | |
| 28 | |
| 29 void RecordTaskTime(base::TimeTicks start_time, base::TimeTicks end_time); | |
| 30 | |
| 31 void RecordIdle(base::TimeTicks now); | |
|
Sami
2016/08/22 14:33:16
Could we also count wake-ups here? Could you add a
altimin
2016/08/22 15:36:23
Done.
| |
| 32 | |
| 33 private: | |
| 34 void Advance(base::TimeTicks now, bool is_active, bool is_task_running); | |
| 35 | |
| 36 double Load(); | |
| 37 | |
| 38 base::TimeTicks current_time_; | |
| 39 base::TimeTicks next_reporting_time_; | |
| 40 | |
| 41 bool active_; | |
| 42 base::TimeTicks last_status_change_time_; | |
| 43 | |
| 44 base::TimeDelta total_time_; | |
| 45 base::TimeDelta total_runtime_; | |
| 46 | |
| 47 // Start reporting values after |waiting_period_|. | |
| 48 base::TimeDelta waiting_period_; | |
| 49 base::TimeDelta reporting_interval_; | |
| 50 | |
| 51 Callback callback_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(RendererLoadTracker); | |
| 54 }; | |
| 55 | |
| 56 } // namespace scheduler | |
| 57 } // namespace blink | |
| 58 | |
| 59 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_T RACKER_H_ | |
| OLD | NEW |