| Index: components/metrics/leak_detector/leak_detector.h
|
| diff --git a/components/metrics/leak_detector/leak_detector.h b/components/metrics/leak_detector/leak_detector.h
|
| index 12a0d1eb5c0064200915259fa3ab687581a6b610..fb624a281dd2eb59bdd951eb1a46634a5d4e73d7 100644
|
| --- a/components/metrics/leak_detector/leak_detector.h
|
| +++ b/components/metrics/leak_detector/leak_detector.h
|
| @@ -15,8 +15,10 @@
|
| #include "base/feature_list.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| #include "base/observer_list.h"
|
| #include "base/synchronization/lock.h"
|
| +#include "base/task_runner.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "components/metrics/proto/memory_leak_report.pb.h"
|
|
|
| @@ -62,10 +64,14 @@ class LeakDetector {
|
| // Returns the sole instance, or creates it if it hasn't already been created.
|
| static LeakDetector* GetInstance();
|
|
|
| - // Initializes leak detector with a set of params given by |params|. See the
|
| - // definition of MemoryLeakReportProto::Params for info about individual
|
| - // parameters.
|
| - void Init(const MemoryLeakReportProto::Params& params);
|
| + // Initializes leak detector. Args:
|
| + // - |params| is a set of parameters used by the leak detector. See definition
|
| + // of MemoryLeakReportProto::Params for info about individual parameters.
|
| + // - |task_runner| is a TaskRunner to which NotifyObservers() should be
|
| + // posted, if it is initally called from a different thread than the one on
|
| + // which |task_runner| runs.
|
| + void Init(const MemoryLeakReportProto::Params& params,
|
| + scoped_refptr<base::TaskRunner> task_runner);
|
|
|
| // Add |observer| to the list of stored Observers, i.e. |observers_|, to which
|
| // the leak detector will report leaks.
|
| @@ -98,7 +104,8 @@ class LeakDetector {
|
| bool ShouldSample(const void* ptr) const;
|
|
|
| // Notifies all Observers in |observers_| with the given vector of leak
|
| - // report protobufs.
|
| + // report protobufs. If it is not currently on the thread that corresponds to
|
| + // |task_runner_|, it will post the call as task to |task_runner_|.
|
| void NotifyObservers(const std::vector<MemoryLeakReportProto>& reports);
|
|
|
| // List of observers to notify when there's a leak report.
|
| @@ -115,6 +122,9 @@ class LeakDetector {
|
| // For thread safety.
|
| base::ThreadChecker thread_checker_;
|
|
|
| + // For posting leak report notifications.
|
| + scoped_refptr<base::TaskRunner> task_runner_;
|
| +
|
| // Total number of bytes allocated, computed before sampling.
|
| size_t total_alloc_size_;
|
|
|
|
|