OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_RENDERER_PAGE_LOAD_METRICS_PAGE_TIMING_METRICS_SENDER_H_ | 5 #ifndef CHROME_RENDERER_PAGE_LOAD_METRICS_PAGE_TIMING_METRICS_SENDER_H_ |
6 #define CHROME_RENDERER_PAGE_LOAD_METRICS_PAGE_TIMING_METRICS_SENDER_H_ | 6 #define CHROME_RENDERER_PAGE_LOAD_METRICS_PAGE_TIMING_METRICS_SENDER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "chrome/common/page_load_metrics/page_load_timing.h" | 11 #include "chrome/common/page_load_metrics/page_load_timing.h" |
12 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" | 12 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class Timer; | 15 class Timer; |
16 } // namespace base | 16 } // namespace base |
17 | 17 |
18 namespace IPC { | 18 namespace IPC { |
19 class Sender; | 19 class Sender; |
20 } // namespace IPC | 20 } // namespace IPC |
21 | 21 |
22 namespace page_load_metrics { | 22 namespace page_load_metrics { |
23 | 23 |
| 24 class PageTimingSender; |
| 25 |
24 // PageTimingMetricsSender is responsible for sending page load timing metrics | 26 // PageTimingMetricsSender is responsible for sending page load timing metrics |
25 // over IPC. PageTimingMetricsSender may coalesce sent IPCs in order to | 27 // over IPC. PageTimingMetricsSender may coalesce sent IPCs in order to |
26 // minimize IPC contention. | 28 // minimize IPC contention. |
27 class PageTimingMetricsSender { | 29 class PageTimingMetricsSender { |
28 public: | 30 public: |
29 PageTimingMetricsSender(IPC::Sender* ipc_sender, | 31 PageTimingMetricsSender(IPC::Sender* ipc_sender, |
30 int routing_id, | 32 int routing_id, |
| 33 PageTimingSender* page_timing_sender, |
31 std::unique_ptr<base::Timer> timer, | 34 std::unique_ptr<base::Timer> timer, |
32 const PageLoadTiming& initial_timing); | 35 const PageLoadTiming& initial_timing); |
33 ~PageTimingMetricsSender(); | 36 ~PageTimingMetricsSender(); |
34 | 37 |
35 void DidObserveLoadingBehavior(blink::WebLoadingBehaviorFlag behavior); | 38 void DidObserveLoadingBehavior(blink::WebLoadingBehaviorFlag behavior); |
36 void Send(const PageLoadTiming& timing); | 39 void Send(const PageLoadTiming& timing); |
37 | 40 |
38 protected: | 41 protected: |
39 base::Timer* timer() const { return timer_.get(); } | 42 base::Timer* timer() const { return timer_.get(); } |
40 | 43 |
41 private: | 44 private: |
42 void EnsureSendTimer(int delay); | 45 void EnsureSendTimer(int delay); |
43 void SendNow(); | 46 void SendNow(); |
44 | 47 |
45 IPC::Sender* const ipc_sender_; | 48 IPC::Sender* const ipc_sender_; |
46 const int routing_id_; | 49 const int routing_id_; |
| 50 PageTimingSender* const page_timing_sender_; |
47 std::unique_ptr<base::Timer> timer_; | 51 std::unique_ptr<base::Timer> timer_; |
48 PageLoadTiming last_timing_; | 52 PageLoadTiming last_timing_; |
49 | 53 |
50 // The the sender keep track of metadata as it comes in, because the sender is | 54 // The the sender keep track of metadata as it comes in, because the sender is |
51 // scoped to a single committed load. | 55 // scoped to a single committed load. |
52 PageLoadMetadata metadata_; | 56 PageLoadMetadata metadata_; |
53 | 57 |
54 DISALLOW_COPY_AND_ASSIGN(PageTimingMetricsSender); | 58 DISALLOW_COPY_AND_ASSIGN(PageTimingMetricsSender); |
55 }; | 59 }; |
56 | 60 |
57 } // namespace page_load_metrics | 61 } // namespace page_load_metrics |
58 | 62 |
59 #endif // CHROME_RENDERER_PAGE_LOAD_METRICS_PAGE_TIMING_METRICS_SENDER_H_ | 63 #endif // CHROME_RENDERER_PAGE_LOAD_METRICS_PAGE_TIMING_METRICS_SENDER_H_ |
OLD | NEW |