| Index: chrome/browser/process_resource_usage.h
|
| diff --git a/chrome/browser/process_resource_usage.h b/chrome/browser/process_resource_usage.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ad295a6bf5528c37f95045821f9c0870a50706fe
|
| --- /dev/null
|
| +++ b/chrome/browser/process_resource_usage.h
|
| @@ -0,0 +1,59 @@
|
| +// 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 CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_
|
| +#define CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "chrome/common/resource_usage_reporter.mojom.h"
|
| +
|
| +// Provides resource usage information about a child process.
|
| +//
|
| +// This is a wrapper around the ResourceUsageReporter Mojo service that exposes
|
| +// information about resources used by a child process. Currently, this is only
|
| +// V8 memory usage, but could be expanded to include other resources such as web
|
| +// cache. This is intended for status viewers such as the task manager and
|
| +// about://memory-internals.
|
| +//
|
| +// To create:
|
| +// 1. Obtain a ResourceUsageReporter connection using the child process's
|
| +// service registry. i.e:
|
| +// ResourceUsageReporterPtr service;
|
| +// process->GetServiceRegistry()->ConnectToRemoteService(&service);
|
| +// 2. If needed, the connection can be passed to another thread using
|
| +// ResourceUsageReporterPtr::PassInterface().
|
| +// 3. Pass the service to the constructor.
|
| +//
|
| +// Note: ProcessResourceUsage is thread-hostile and must live on a single
|
| +// thread.
|
| +class ProcessResourceUsage {
|
| + public:
|
| + // Must be called from the same thread that created |service|.
|
| + explicit ProcessResourceUsage(ResourceUsageReporterPtr service);
|
| + ~ProcessResourceUsage();
|
| +
|
| + // Refresh the resource usage information.
|
| + void Refresh();
|
| +
|
| + // Get V8 memory usage information.
|
| + bool ReportsV8MemoryStats() const;
|
| + size_t GetV8MemoryAllocated() const;
|
| + size_t GetV8MemoryUsed() const;
|
| +
|
| + private:
|
| + // Mojo IPC callback.
|
| + void OnRefreshDone(ResourceUsageDataPtr data);
|
| +
|
| + ResourceUsageReporterPtr service_;
|
| + bool update_in_progress_;
|
| +
|
| + ResourceUsageDataPtr stats_;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ProcessResourceUsage);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_
|
|
|