Chromium Code Reviews| Index: third_party/WebKit/Source/core/loader/NetworkQuietDetector.h |
| diff --git a/third_party/WebKit/Source/core/loader/NetworkQuietDetector.h b/third_party/WebKit/Source/core/loader/NetworkQuietDetector.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..61adf3aef4f0e0817d4f28b14d0adac99182f273 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/loader/NetworkQuietDetector.h |
| @@ -0,0 +1,55 @@ |
| +// Copyright 2017 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 NetworkQuietDetector_h |
| +#define NetworkQuietDetector_h |
| + |
| +#include "core/CoreExport.h" |
| +#include "core/dom/Document.h" |
| +#include "platform/Supplementable.h" |
| +#include "platform/Timer.h" |
| +#include "platform/heap/Handle.h" |
| +#include "platform/wtf/Noncopyable.h" |
| + |
| +namespace blink { |
| + |
| +class Document; |
| + |
| +// NetworkQuietDetector observes network request count everytime a load is |
| +// finshed after DOMContentLoadedEventEnd is fired, and signals a network |
| +// idleness signal to GRC when there are no more than 2 network connection |
| +// active in 1 second. |
| +class CORE_EXPORT NetworkQuietDetector |
| + : public GarbageCollectedFinalized<NetworkQuietDetector>, |
| + public Supplement<Document> { |
| + WTF_MAKE_NONCOPYABLE(NetworkQuietDetector); |
| + USING_GARBAGE_COLLECTED_MIXIN(NetworkQuietDetector); |
| + |
| + public: |
| + static NetworkQuietDetector& From(Document&); |
| + virtual ~NetworkQuietDetector() {} |
|
oystein (OOO til 10th of July)
2017/06/12 21:20:00
~NetworkQuietDetector() override; instead of virtu
lpy
2017/06/14 18:19:35
It's not an override.
|
| + |
| + void CheckNetworkStable(); |
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| + private: |
| + friend class NetworkQuietDetectorTest; |
| + |
| + // The page is n-quiet if there are no more than n active network requests for |
| + // this duration of time. |
| + static constexpr double kNetwork2QuietWindowSeconds = 1.0; |
| + |
| + explicit NetworkQuietDetector(Document&); |
| + int ActiveConnections(); |
| + void SetNetworkQuietTimers(int active_connections); |
| + void Network2QuietTimerFired(TimerBase*); |
| + |
| + bool network2_quiet_reached_ = false; |
| + TaskRunnerTimer<NetworkQuietDetector> network2_quiet_timer_; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif |