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 COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_ | 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_ |
6 #define COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_ | 6 #define COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "components/page_load_metrics/common/page_load_timing.h" | 10 #include "components/page_load_metrics/common/page_load_timing.h" |
| 11 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 class Timer; | 14 class Timer; |
14 } // namespace base | 15 } // namespace base |
15 | 16 |
16 namespace IPC { | 17 namespace IPC { |
17 class Sender; | 18 class Sender; |
18 } // namespace IPC | 19 } // namespace IPC |
19 | 20 |
20 namespace page_load_metrics { | 21 namespace page_load_metrics { |
21 | 22 |
22 // PageTimingMetricsSender is responsible for sending page load timing metrics | 23 // PageTimingMetricsSender is responsible for sending page load timing metrics |
23 // over IPC. PageTimingMetricsSender may coalesce sent IPCs in order to | 24 // over IPC. PageTimingMetricsSender may coalesce sent IPCs in order to |
24 // minimize IPC contention. | 25 // minimize IPC contention. |
25 class PageTimingMetricsSender { | 26 class PageTimingMetricsSender { |
26 public: | 27 public: |
27 PageTimingMetricsSender(IPC::Sender* ipc_sender, | 28 PageTimingMetricsSender(IPC::Sender* ipc_sender, |
28 int routing_id, | 29 int routing_id, |
29 scoped_ptr<base::Timer> timer); | 30 scoped_ptr<base::Timer> timer); |
30 ~PageTimingMetricsSender(); | 31 ~PageTimingMetricsSender(); |
31 | 32 |
| 33 void DidObserveLoadingBehavior(blink::WebLoadingBehaviorFlag behavior); |
32 void Send(const PageLoadTiming& timing); | 34 void Send(const PageLoadTiming& timing); |
33 | 35 |
34 protected: | 36 protected: |
35 base::Timer* timer() const { return timer_.get(); } | 37 base::Timer* timer() const { return timer_.get(); } |
36 | 38 |
37 private: | 39 private: |
38 void SendNow(); | 40 void SendNow(); |
39 | 41 |
40 IPC::Sender* const ipc_sender_; | 42 IPC::Sender* const ipc_sender_; |
41 const int routing_id_; | 43 const int routing_id_; |
42 scoped_ptr<base::Timer> timer_; | 44 scoped_ptr<base::Timer> timer_; |
43 PageLoadTiming last_timing_; | 45 PageLoadTiming last_timing_; |
44 | 46 |
| 47 // The the sender keep track of metadata as it comes in, because the sender is |
| 48 // scoped to a single committed load. |
| 49 PageLoadMetadata metadata_; |
| 50 |
45 DISALLOW_COPY_AND_ASSIGN(PageTimingMetricsSender); | 51 DISALLOW_COPY_AND_ASSIGN(PageTimingMetricsSender); |
46 }; | 52 }; |
47 | 53 |
48 } // namespace page_load_metrics | 54 } // namespace page_load_metrics |
49 | 55 |
50 #endif // COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_ | 56 #endif // COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_ |
OLD | NEW |