Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: components/page_load_metrics/renderer/page_timing_metrics_sender.h

Issue 2056153002: Convert PageLoadMetrics to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp build deps Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/page_load_metrics/common/page_load_metrics.mojom.h"
11 #include "components/page_load_metrics/common/page_load_timing.h" 12 #include "components/page_load_metrics/common/page_load_timing.h"
12 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" 13 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h"
13 14
14 namespace base { 15 namespace base {
15 class Timer; 16 class Timer;
16 } // namespace base 17 } // namespace base
17 18
18 namespace IPC {
19 class Sender;
20 } // namespace IPC
21
22 namespace page_load_metrics { 19 namespace page_load_metrics {
23 20
24 // PageTimingMetricsSender is responsible for sending page load timing metrics 21 // PageTimingMetricsSender is responsible for sending page load timing metrics
25 // over IPC. PageTimingMetricsSender may coalesce sent IPCs in order to 22 // over IPC. PageTimingMetricsSender may coalesce sent IPCs in order to
26 // minimize IPC contention. 23 // minimize IPC contention.
27 class PageTimingMetricsSender { 24 class PageTimingMetricsSender {
28 public: 25 public:
29 PageTimingMetricsSender(IPC::Sender* ipc_sender, 26 PageTimingMetricsSender(mojom::PageLoadMetrics* page_load_metrics,
30 int routing_id,
31 std::unique_ptr<base::Timer> timer, 27 std::unique_ptr<base::Timer> timer,
32 const PageLoadTiming& initial_timing); 28 const PageLoadTiming& initial_timing);
33 ~PageTimingMetricsSender(); 29 ~PageTimingMetricsSender();
34 30
35 void DidObserveLoadingBehavior(blink::WebLoadingBehaviorFlag behavior); 31 void DidObserveLoadingBehavior(blink::WebLoadingBehaviorFlag behavior);
36 void Send(const PageLoadTiming& timing); 32 void Send(const PageLoadTiming& timing);
37 33
38 protected: 34 protected:
39 base::Timer* timer() const { return timer_.get(); } 35 base::Timer* timer() const { return timer_.get(); }
40 36
41 private: 37 private:
42 void EnsureSendTimer(int delay); 38 void EnsureSendTimer(int delay);
43 void SendNow(); 39 void SendNow();
44 40
45 IPC::Sender* const ipc_sender_; 41 mojom::PageLoadMetrics* page_load_metrics_;
46 const int routing_id_;
47 std::unique_ptr<base::Timer> timer_; 42 std::unique_ptr<base::Timer> timer_;
48 PageLoadTiming last_timing_; 43 PageLoadTiming last_timing_;
49 44
50 // The the sender keep track of metadata as it comes in, because the sender is 45 // The the sender keep track of metadata as it comes in, because the sender is
51 // scoped to a single committed load. 46 // scoped to a single committed load.
52 PageLoadMetadata metadata_; 47 PageLoadMetadata metadata_;
53 48
54 DISALLOW_COPY_AND_ASSIGN(PageTimingMetricsSender); 49 DISALLOW_COPY_AND_ASSIGN(PageTimingMetricsSender);
55 }; 50 };
56 51
57 } // namespace page_load_metrics 52 } // namespace page_load_metrics
58 53
59 #endif // COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_ 54 #endif // COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698