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

Unified Diff: chrome/browser/metrics/leak_detector/leak_detector_controller.h

Issue 2062743002: Randomly enable leak detector based on probability parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use RenderThreadObserver interface to shutdown remote client on same thread Created 4 years, 4 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/metrics/leak_detector/leak_detector_controller.h
diff --git a/chrome/browser/metrics/leak_detector/leak_detector_controller.h b/chrome/browser/metrics/leak_detector/leak_detector_controller.h
index 7fdeb9308edb1a74943c903ce9469ae200e56320..6651bb790795625e490be584b6b1a2b3101ae51d 100644
--- a/chrome/browser/metrics/leak_detector/leak_detector_controller.h
+++ b/chrome/browser/metrics/leak_detector/leak_detector_controller.h
@@ -35,12 +35,20 @@ class LeakDetectorController
void OnLeaksFound(const std::vector<MemoryLeakReportProto>& reports) override;
// LeakDetectorRemoteController::LocalController:
- MemoryLeakReportProto::Params GetParams() const override;
+ MemoryLeakReportProto::Params GetParamsAndRecordRequest() override;
void SendLeakReports(
const std::vector<MemoryLeakReportProto>& reports) override;
void OnRemoteProcessShutdown() override;
private:
+ // Returns true to indicate that LeakDetector should be enabled on a renderer
+ // process. This is determined as follows:
+ // 1. If the number of processes running LeakDetector is not at max, returns
+ // true with a probability of |per_process_enable_probability_|.
+ // 2. If the number of processes running LeakDetector has reached the max,
+ // returns false.
+ bool ShouldRandomlyEnableLeakDetectorOnRendererProcess() const;
+
// Stores a given array of leak reports in |stored_reports_|. |process_type|
// is the type of process that generated these reports. The reports must all
// come from the same process type.
@@ -58,6 +66,22 @@ class LeakDetectorController
// The build ID of the current Chrome binary.
std::vector<uint8_t> build_id_;
+ // The probability that each process will have the leak detector enabled on
+ // it. For remote processes, this is determined by sending |params_| for
+ // initialization. If the remote process is not to have leak detector enabled,
+ // |params_.sampling_rate()| will be set to 0. Whether or not to enable for a
+ // particular process is independent of the decision for all other processes.
+ double browser_process_enable_probability_;
+ double renderer_process_enable_probability_;
+
+ // The maximum allowed number of renderer processes with leak detector running
+ // simultaneously.
+ int max_renderer_processes_with_leak_detector_enabled_;
+
+ // The number of renderer processes on which the leak detector has been
+ // enabled and is running.
+ int num_renderer_processes_with_leak_detector_enabled_;
+
// For thread safety.
base::ThreadChecker thread_checker_;

Powered by Google App Engine
This is Rietveld 408576698