OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ | |
6 #define CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/threading/thread_checker.h" | |
10 #include "chrome/common/resource_usage_reporter.mojom.h" | |
11 | |
12 // Provides resource usage information about a child process. | |
13 // | |
14 // This is a wrapper around the ResourceUsageReporter Mojo service that exposes | |
15 // information about resources used by a child process. Currently, this is only | |
16 // V8 memory usage, but could be expanded to include other resources such as web | |
17 // cache. This is intended for status viewers such as the task manager and | |
18 // about://memory-internals. | |
jam
2015/05/12 16:12:23
is someone tasked to make about:memory-internals t
Anand Mistry (off Chromium)
2015/05/13 00:42:11
Yes, me. I have another CL in progress that switch
| |
19 // | |
20 // To create: | |
21 // 1. Obtain a ResourceUsageReporter connection using the child process's | |
22 // service registry. i.e: | |
23 // ResourceUsageReporterPtr service; | |
24 // process->GetServiceRegistry()->ConnectToRemoteService(&service); | |
25 // 2. If needed, the connection can be passed to another thread using | |
26 // ResourceUsageReporterPtr::PassInterface(). | |
27 // 3. Pass the service to the constructor. | |
28 // | |
29 // Note: ProcessResourceUsage is thread-hostile and must live on a single | |
30 // thread. | |
31 class ProcessResourceUsage { | |
32 public: | |
33 // Must be called from the same thread that created |service|. | |
34 explicit ProcessResourceUsage(ResourceUsageReporterPtr service); | |
35 ~ProcessResourceUsage(); | |
36 | |
37 // Refresh the resource usage information. | |
38 void Refresh(); | |
39 | |
40 // Get V8 memory usage information. | |
41 bool ReportsV8MemoryStats() const; | |
42 size_t GetV8MemoryAllocated() const; | |
43 size_t GetV8MemoryUsed() const; | |
44 | |
45 private: | |
46 // Mojo IPC callback. | |
47 void OnRefreshDone(ResourceUsageDataPtr data); | |
48 | |
49 ResourceUsageReporterPtr service_; | |
50 bool update_in_progress_; | |
51 | |
52 ResourceUsageDataPtr stats_; | |
53 | |
54 base::ThreadChecker thread_checker_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(ProcessResourceUsage); | |
57 }; | |
58 | |
59 #endif // CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ | |
OLD | NEW |