OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 NetworkQuietDetector_h |
| 6 #define NetworkQuietDetector_h |
| 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "platform/Timer.h" |
| 10 #include "platform/heap/Handle.h" |
| 11 #include "platform/wtf/HashSet.h" |
| 12 #include "platform/wtf/Noncopyable.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class Document; |
| 17 |
| 18 // NetworkQuietDetector observes network request count everytime a load is |
| 19 // finshed after DOMLoadedEventEnd is fired, and signals a network idleness |
| 20 // signal to GRC when there are no more than 2 network connection active during |
| 21 // 1 second. |
| 22 class CORE_EXPORT NetworkQuietDetector |
| 23 : public GarbageCollectedFinalized<NetworkQuietDetector> { |
| 24 WTF_MAKE_NONCOPYABLE(NetworkQuietDetector); |
| 25 |
| 26 public: |
| 27 NetworkQuietDetector(Document*); |
| 28 virtual ~NetworkQuietDetector() {} |
| 29 |
| 30 void CheckNetworkStable(); |
| 31 |
| 32 DECLARE_TRACE(); |
| 33 |
| 34 private: |
| 35 friend class NetworkQuietDetectorTest; |
| 36 |
| 37 // The page is n-quiet if there are no more than n active network requests for |
| 38 // this duration of time. |
| 39 static constexpr double kNetwork2QuietWindowSeconds = 1.0; |
| 40 |
| 41 int ActiveConnections(); |
| 42 void SetNetworkQuietTimers(int active_connections); |
| 43 void Network2QuietTimerFired(TimerBase*); |
| 44 |
| 45 bool network2_quiet_reached_ = false; |
| 46 Member<Document> document_; |
| 47 TaskRunnerTimer<NetworkQuietDetector> network2_quiet_timer_; |
| 48 }; |
| 49 |
| 50 } // namespace blink |
| 51 |
| 52 #endif |
OLD | NEW |