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

Unified Diff: components/page_load_metrics/renderer/page_timing_metrics_sender.h

Issue 1312213010: PageLoadMetrics renderer and browser implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Relax DCHECK constraints slightly for tests Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/page_load_metrics/renderer/page_timing_metrics_sender.h
diff --git a/components/page_load_metrics/renderer/page_timing_metrics_sender.h b/components/page_load_metrics/renderer/page_timing_metrics_sender.h
new file mode 100644
index 0000000000000000000000000000000000000000..0f5e1c9de7146ef1c27b49710a3e8944a6db04b2
--- /dev/null
+++ b/components/page_load_metrics/renderer/page_timing_metrics_sender.h
@@ -0,0 +1,50 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_
+#define COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "components/page_load_metrics/common/page_load_timing.h"
+
+namespace base {
+class Timer;
+} // namespace base
+
+namespace IPC {
+class Sender;
+} // namespace IPC
+
+namespace page_load_metrics {
+
+// PageTimingMetricsSender is responsible for sending page load timing metrics
+// over IPC. PageTimingMetricsSender may coalesce sent IPCs in order to
+// minimize IPC contention.
+class PageTimingMetricsSender {
+ public:
+ PageTimingMetricsSender(IPC::Sender* ipc_sender,
+ int routing_id,
+ scoped_ptr<base::Timer> timer);
+ ~PageTimingMetricsSender();
+
+ void Send(const PageLoadTiming& timing);
+
+ protected:
+ base::Timer* timer() const { return timer_.get(); }
+
+ private:
+ void SendNow();
+
+ IPC::Sender* const ipc_sender_;
+ const int routing_id_;
+ scoped_ptr<base::Timer> timer_;
+ PageLoadTiming last_timing_;
+
+ DISALLOW_COPY_AND_ASSIGN(PageTimingMetricsSender);
+};
+
+} // namespace page_load_metrics
+
+#endif // COMPONENTS_PAGE_LOAD_METRICS_RENDERER_PAGE_TIMING_METRICS_SENDER_H_

Powered by Google App Engine
This is Rietveld 408576698