Chromium Code Reviews| Index: chrome/browser/metrics/subprocess_metrics_provider.h |
| diff --git a/chrome/browser/metrics/subprocess_metrics_provider.h b/chrome/browser/metrics/subprocess_metrics_provider.h |
| index 953169c8d8d34002de98100814c65f4c2df03d69..127eafe8872e8135194795055d4af8803ff149d5 100644 |
| --- a/chrome/browser/metrics/subprocess_metrics_provider.h |
| +++ b/chrome/browser/metrics/subprocess_metrics_provider.h |
| @@ -10,9 +10,11 @@ |
| #include "base/gtest_prod_util.h" |
| #include "base/id_map.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "base/scoped_observer.h" |
| #include "base/threading/thread_checker.h" |
| #include "components/metrics/metrics_provider.h" |
| +#include "content/public/browser/browser_child_process_observer.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| #include "content/public/browser/render_process_host_observer.h" |
| @@ -27,12 +29,18 @@ class SharedPersistentMemoryAllocator; |
| // when metrics are being collected for upload, or when something else needs |
| // combined metrics (such as the chrome://histograms page). |
| class SubprocessMetricsProvider : public metrics::MetricsProvider, |
| + public content::BrowserChildProcessObserver, |
| public content::NotificationObserver, |
| public content::RenderProcessHostObserver { |
| public: |
| SubprocessMetricsProvider(); |
| ~SubprocessMetricsProvider() override; |
| + // Start tracking sub-processes. This is called separately rather than being |
| + // set in the constructor because library code that checks for calling on |
| + // the correct thread can break tests. |
|
Alexei Svitkine (slow)
2016/08/12 23:14:36
Can you provide more context? I would hope we can
bcwhite
2016/08/15 19:43:10
There's a DCHECK that it's running on BrowserThrea
Alexei Svitkine (slow)
2016/08/18 07:21:19
See: https://groups.google.com/a/chromium.org/foru
Alexei Svitkine (slow)
2016/08/19 15:10:51
Ping on this. I think you should be able to use th
bcwhite
2016/08/19 15:55:21
Yep. Was just addressing the design issues quickl
|
| + void EnableSubprocessTracking(); |
| + |
| private: |
| friend class SubprocessMetricsProviderTest; |
| @@ -56,6 +64,18 @@ class SubprocessMetricsProvider : public metrics::MetricsProvider, |
| // metrics::MetricsProvider: |
| void MergeHistogramDeltas() override; |
| + // content::BrowserChildProcessObserver: |
| + void BrowserChildProcessHostConnected( |
| + const content::ChildProcessData& data) override; |
| + void BrowserChildProcessHostDisconnected( |
| + const content::ChildProcessData& data) override; |
| + void BrowserChildProcessCrashed( |
| + const content::ChildProcessData& data, |
| + int exit_code) override; |
| + void BrowserChildProcessKilled( |
| + const content::ChildProcessData& data, |
| + int exit_code) override; |
| + |
| // content::NotificationObserver: |
| void Observe(int type, |
| const content::NotificationSource& source, |
| @@ -68,6 +88,13 @@ class SubprocessMetricsProvider : public metrics::MetricsProvider, |
| int exit_code) override; |
| void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; |
| + // Indicates a browser child process to be monitored. This must be called on |
| + // the IO thread. The |provider| is used for calling Register on the UI |
| + // thread. |
| + static void RegisterBrowserChildProcessAllocatorFromIOThread( |
| + base::WeakPtr<SubprocessMetricsProvider> provider, |
| + int id); |
| + |
| base::ThreadChecker thread_checker_; |
| // Object for registing notification requests. |
| @@ -82,6 +109,8 @@ class SubprocessMetricsProvider : public metrics::MetricsProvider, |
| ScopedObserver<content::RenderProcessHost, SubprocessMetricsProvider> |
| scoped_observer_; |
| + base::WeakPtrFactory<SubprocessMetricsProvider> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(SubprocessMetricsProvider); |
| }; |