Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/renderer/renderer_load_tracker.h |
| diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/renderer_load_tracker.h b/third_party/WebKit/Source/platform/scheduler/renderer/renderer_load_tracker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..481095be0a08b20e442b59125a41a8de315e520a |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/scheduler/renderer/renderer_load_tracker.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRACKER_H_ |
| +#define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRACKER_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/time/time.h" |
| +#include "public/platform/WebCommon.h" |
| + |
| +namespace blink { |
| +namespace scheduler { |
| + |
| +// 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.
|
| +// In order to avoid bias it reports load level at regular intervals. |
| +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.
|
| + public: |
| + // Callback is called with (current_time, load_level) parameters. |
| + using Callback = base::Callback<void(base::TimeTicks, double)>; |
| + |
| + RendererLoadTracker(base::TimeTicks now, const Callback& callback); |
| + ~RendererLoadTracker(); |
| + |
| + void Pause(base::TimeTicks now); |
| + void Resume(base::TimeTicks now); |
| + |
| + void RecordTaskTime(base::TimeTicks start_time, base::TimeTicks end_time); |
| + |
| + 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.
|
| + |
| + private: |
| + void Advance(base::TimeTicks now, bool is_active, bool is_task_running); |
| + |
| + double Load(); |
| + |
| + base::TimeTicks current_time_; |
| + base::TimeTicks next_reporting_time_; |
| + |
| + bool active_; |
| + base::TimeTicks last_status_change_time_; |
| + |
| + base::TimeDelta total_time_; |
| + base::TimeDelta total_runtime_; |
| + |
| + // Start reporting values after |waiting_period_|. |
| + base::TimeDelta waiting_period_; |
| + base::TimeDelta reporting_interval_; |
| + |
| + Callback callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RendererLoadTracker); |
| +}; |
| + |
| +} // namespace scheduler |
| +} // namespace blink |
| + |
| +#endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRACKER_H_ |