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

Unified Diff: chrome/browser/resource_coordinator/resource_coordinator_render_process_probe.h

Issue 2964103002: [GRC] Decouple Render Process CPU Measurement from CU Graph (Closed)
Patch Set: Rebase Created 3 years, 6 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: chrome/browser/resource_coordinator/resource_coordinator_render_process_probe.h
diff --git a/chrome/browser/resource_coordinator/resource_coordinator_render_process_probe.h b/chrome/browser/resource_coordinator/resource_coordinator_render_process_probe.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ac3e57f62945f5152e8bef443edd77eec1869af
--- /dev/null
+++ b/chrome/browser/resource_coordinator/resource_coordinator_render_process_probe.h
@@ -0,0 +1,66 @@
+// Copyright 2017 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 CHROME_BROWSER_RESOURCE_COORDINATOR_RESOURCE_COORDINATOR_RENDER_PROCESS_PROBE_H_
+#define CHROME_BROWSER_RESOURCE_COORDINATOR_RESOURCE_COORDINATOR_RENDER_PROCESS_PROBE_H_
+
+#include <memory>
+#include <unordered_map>
+
+#include "base/lazy_instance.h"
+#include "base/macros.h"
+#include "base/process/process_handle.h"
+#include "base/process/process_metrics.h"
+#include "base/timer/timer.h"
+
+namespace resource_coordinator {
+
+// |ResourceCoordinatorRenderProcessProbe| collects measurements about render
+// processes and propagates them to the |resource_coordinator| service.
+class ResourceCoordinatorRenderProcessProbe {
+ public:
+ // Returns the current |ResourceCoordinatorRenderProcessProbe| instance
+ // if one exists; otherwise it constructs a new instance.
+ static ResourceCoordinatorRenderProcessProbe* GetInstance();
+
+ // Start collecting render process metrics.
+ void StartGatherCycle();
+
+ // Collects measurements for all active render processes and then
+ // propagates them to their corresponding |ResourceCoordinatorInterface|.
+ void CollectAndSendMeasurements();
Zhen Wang 2017/07/05 15:37:50 Make this private?
+
+ private:
+ friend struct base::LazyInstanceTraitsBase<
+ ResourceCoordinatorRenderProcessProbe>;
+
+ struct ProcessMetricsState {
+ ProcessMetricsState();
+ ~ProcessMetricsState();
+ size_t last_tick_active;
+ std::unique_ptr<base::ProcessMetrics> metrics;
+ };
+
+ using ProcessMetricsStateMap =
+ std::unordered_map<base::ProcessHandle, ProcessMetricsState>;
+
+ ResourceCoordinatorRenderProcessProbe();
+ ~ResourceCoordinatorRenderProcessProbe();
+
+ // A map of currently running ProcessHandles to Process.
+ ProcessMetricsStateMap process_metrics_states_;
+
+ // Timer to signal the |ResourceCoordinatorRenderProcessProbe| instance
+ // to conduct its measurements as a regular interval;
+ base::OneShotTimer repeating_timer_;
+
+ // Number of measurements collected so far.
+ size_t ticks_ = 0u;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourceCoordinatorRenderProcessProbe);
+};
+
+} // namespace resource_coordinator
+
+#endif // CHROME_BROWSER_RESOURCE_COORDINATOR_RESOURCE_COORDINATOR_RENDER_PROCESS_PROBE_H_

Powered by Google App Engine
This is Rietveld 408576698