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