| 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..459e4de96e2865f476b41b50a35c0034b3c3ddbd
|
| --- /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 "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() {}
|
| +
|
| + 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&);
|
| + Document* GetDocument();
|
| + int ActiveConnections();
|
| + void SetNetworkQuietTimers(int active_connections);
|
| + void Network2QuietTimerFired(TimerBase*);
|
| +
|
| + bool network2_quiet_reached_ = false;
|
| + TaskRunnerTimer<NetworkQuietDetector> network2_quiet_timer_;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif
|
|
|