| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ | 5 #ifndef CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ |
| 6 #define CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ | 6 #define CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // service that exposes | 21 // service that exposes |
| 22 // information about resources used by a child process. Currently, this is only | 22 // information about resources used by a child process. Currently, this is only |
| 23 // V8 memory and Blink resource cache usage, but could be expanded to include | 23 // V8 memory and Blink resource cache usage, but could be expanded to include |
| 24 // other resources. This is intended for status viewers such as the task | 24 // other resources. This is intended for status viewers such as the task |
| 25 // manager. | 25 // manager. |
| 26 // | 26 // |
| 27 // To create: | 27 // To create: |
| 28 // 1. Create a chrome::mojom::ResourceUsageReporterPtr and obtain an | 28 // 1. Create a chrome::mojom::ResourceUsageReporterPtr and obtain an |
| 29 // InterfaceRequest<> | 29 // InterfaceRequest<> |
| 30 // using | 30 // using |
| 31 // mojo::GetProxy. | 31 // mojo::MakeRequest. |
| 32 // 2. Use the child process's service registry to connect to the service using | 32 // 2. Use the child process's service registry to connect to the service using |
| 33 // the InterfaceRequest<>. Note, ServiceRegistry is thread hostile and | 33 // the InterfaceRequest<>. Note, ServiceRegistry is thread hostile and |
| 34 // must always be accessed from the same thread. However, InterfaceRequest<> | 34 // must always be accessed from the same thread. However, InterfaceRequest<> |
| 35 // can be passed safely between threads, and therefore a task can be posted | 35 // can be passed safely between threads, and therefore a task can be posted |
| 36 // to the ServiceRegistry thread to connect to the remote service. | 36 // to the ServiceRegistry thread to connect to the remote service. |
| 37 // 3. Pass the chrome::mojom::ResourceUsageReporterPtr to the constructor. | 37 // 3. Pass the chrome::mojom::ResourceUsageReporterPtr to the constructor. |
| 38 // | 38 // |
| 39 // Example: | 39 // Example: |
| 40 // void Foo::ConnectToService( | 40 // void Foo::ConnectToService( |
| 41 // mojo::InterfaceRequest<chrome::mojom::ResourceUsageReporter> req) { | 41 // mojo::InterfaceRequest<chrome::mojom::ResourceUsageReporter> req) { |
| 42 // content::ServiceRegistry* registry = host_->GetServiceRegistry(); | 42 // content::ServiceRegistry* registry = host_->GetServiceRegistry(); |
| 43 // registry->ConnectToRemoteService(std::move(req)); | 43 // registry->ConnectToRemoteService(std::move(req)); |
| 44 // } | 44 // } |
| 45 // | 45 // |
| 46 // ... | 46 // ... |
| 47 // chrome::mojom::ResourceUsageReporterPtr service; | 47 // chrome::mojom::ResourceUsageReporterPtr service; |
| 48 // mojo::InterfaceRequest<chrome::mojom::ResourceUsageReporter> request = | 48 // mojo::InterfaceRequest<chrome::mojom::ResourceUsageReporter> request = |
| 49 // mojo::GetProxy(&service); | 49 // mojo::MakeRequest(&service); |
| 50 // content::BrowserThread::PostTask( | 50 // content::BrowserThread::PostTask( |
| 51 // content::BrowserThread::IO, FROM_HERE, | 51 // content::BrowserThread::IO, FROM_HERE, |
| 52 // base::Bind(&Foo::ConnectToService, this, base::Passed(&request))); | 52 // base::Bind(&Foo::ConnectToService, this, base::Passed(&request))); |
| 53 // resource_usage_.reset(new ProcessResourceUsage(std::move(service))); | 53 // resource_usage_.reset(new ProcessResourceUsage(std::move(service))); |
| 54 // ... | 54 // ... |
| 55 // | 55 // |
| 56 // Note: ProcessResourceUsage is thread-hostile and must live on a single | 56 // Note: ProcessResourceUsage is thread-hostile and must live on a single |
| 57 // thread. | 57 // thread. |
| 58 class ProcessResourceUsage { | 58 class ProcessResourceUsage { |
| 59 public: | 59 public: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 85 std::deque<base::Closure> refresh_callbacks_; | 85 std::deque<base::Closure> refresh_callbacks_; |
| 86 | 86 |
| 87 chrome::mojom::ResourceUsageDataPtr stats_; | 87 chrome::mojom::ResourceUsageDataPtr stats_; |
| 88 | 88 |
| 89 base::ThreadChecker thread_checker_; | 89 base::ThreadChecker thread_checker_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(ProcessResourceUsage); | 91 DISALLOW_COPY_AND_ASSIGN(ProcessResourceUsage); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 #endif // CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ | 94 #endif // CHROME_BROWSER_PROCESS_RESOURCE_USAGE_H_ |
| OLD | NEW |