Commit 133f8407 authored by Peter Kvitek's avatar Peter Kvitek Committed by Commit Bot

Added browser child processes info to DevTools SystemInfo.getProcessInfo() result.


Changed DevTools SystemInfo.GetProcessInfo() process type from enum to string.

Change-Id: I7831d6b3fd9a4d2a1feb8aa4c4541d3f86c91a85
Reviewed-on: https://chromium-review.googlesource.com/c/1312117Reviewed-by: default avatarAlexei Filippov <alph@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Peter Kvitek <kvitekp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604749}
parent 00858246
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/public/browser/browser_child_process_host.h" #include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "gpu/config/gpu_feature_type.h" #include "gpu/config/gpu_feature_type.h"
#include "gpu/config/gpu_info.h" #include "gpu/config/gpu_info.h"
...@@ -261,36 +263,59 @@ std::unique_ptr<protocol::SystemInfo::ProcessInfo> MakeProcessInfo( ...@@ -261,36 +263,59 @@ std::unique_ptr<protocol::SystemInfo::ProcessInfo> MakeProcessInfo(
void AddBrowserProcessInfo( void AddBrowserProcessInfo(
protocol::Array<protocol::SystemInfo::ProcessInfo>* process_info) { protocol::Array<protocol::SystemInfo::ProcessInfo>* process_info) {
process_info->addItem( DCHECK_CURRENTLY_ON(BrowserThread::UI);
MakeProcessInfo(base::Process::Current(),
protocol::SystemInfo::ProcessTypeEnum::Browser)); process_info->addItem(MakeProcessInfo(base::Process::Current(), "browser"));
} }
void AddRendererProcessInfo( void AddRendererProcessInfo(
protocol::Array<protocol::SystemInfo::ProcessInfo>* process_info) { protocol::Array<protocol::SystemInfo::ProcessInfo>* process_info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
!it.IsAtEnd(); it.Advance()) { !it.IsAtEnd(); it.Advance()) {
RenderProcessHost* host = it.GetCurrentValue(); RenderProcessHost* host = it.GetCurrentValue();
if (host->GetProcess().IsValid()) { if (host->GetProcess().IsValid()) {
process_info->addItem(MakeProcessInfo( process_info->addItem(MakeProcessInfo(host->GetProcess(), "renderer"));
host->GetProcess(), protocol::SystemInfo::ProcessTypeEnum::Renderer));
} }
} }
} }
} // namespace std::unique_ptr<protocol::Array<protocol::SystemInfo::ProcessInfo>>
AddChildProcessInfo(
Response SystemInfoHandler::GetProcessInfo( std::unique_ptr<protocol::Array<protocol::SystemInfo::ProcessInfo>>
std::unique_ptr<protocol::Array<protocol::SystemInfo::ProcessInfo>>*
process_info) { process_info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::IO);
for (BrowserChildProcessHostIterator it; !it.Done(); ++it) {
const ChildProcessData& process_data = it.GetData();
const base::Process& process = process_data.GetProcess();
if (process.IsValid()) {
process_info->addItem(
MakeProcessInfo(process, process_data.metrics_name));
}
}
*process_info = protocol::Array<SystemInfo::ProcessInfo>::create(); return process_info;
}
AddBrowserProcessInfo(process_info->get()); } // namespace
AddRendererProcessInfo(process_info->get());
return Response::OK(); void SystemInfoHandler::GetProcessInfo(
std::unique_ptr<GetProcessInfoCallback> callback) {
std::unique_ptr<protocol::Array<protocol::SystemInfo::ProcessInfo>>
process_info = protocol::Array<SystemInfo::ProcessInfo>::create();
// Collect browser and renderer processes info on the UI thread.
AddBrowserProcessInfo(process_info.get());
AddRendererProcessInfo(process_info.get());
// Collect child processes info on the IO thread.
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&AddChildProcessInfo, std::move(process_info)),
base::BindOnce(&GetProcessInfoCallback::sendSuccess,
std::move(callback)));
} }
} // namespace protocol } // namespace protocol
......
...@@ -26,9 +26,8 @@ class SystemInfoHandler : public DevToolsDomainHandler, ...@@ -26,9 +26,8 @@ class SystemInfoHandler : public DevToolsDomainHandler,
void Wire(UberDispatcher* dispatcher) override; void Wire(UberDispatcher* dispatcher) override;
void GetInfo(std::unique_ptr<GetInfoCallback> callback) override; void GetInfo(std::unique_ptr<GetInfoCallback> callback) override;
Response GetProcessInfo( void GetProcessInfo(
std::unique_ptr<protocol::Array<protocol::SystemInfo::ProcessInfo>>* std::unique_ptr<GetProcessInfoCallback> callback) override;
process_info) override;
private: private:
friend class SystemInfoHandlerGpuObserver; friend class SystemInfoHandlerGpuObserver;
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
}, },
{ {
"domain": "SystemInfo", "domain": "SystemInfo",
"async": ["getInfo"] "async": ["getInfo", "getProcessInfo"]
}, },
{ {
"domain": "Target", "domain": "Target",
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
continue; continue;
} }
} }
testRunner.log(process, 'Process:', ['id', 'cpuTime']); // Avoid all processes but browser and renderer to ensure stable test.
if (process.type === "browser" || process.type === "renderer")
testRunner.log(process, 'Process:', ['id', 'cpuTime']);
} }
testRunner.completeTest(); testRunner.completeTest();
......
...@@ -5901,17 +5901,11 @@ experimental domain SystemInfo ...@@ -5901,17 +5901,11 @@ experimental domain SystemInfo
# An optional array of GPU driver bug workarounds. # An optional array of GPU driver bug workarounds.
array of string driverBugWorkarounds array of string driverBugWorkarounds
# Specifies process type.
type ProcessType extends string
enum
browser
renderer
# Represents process info. # Represents process info.
type ProcessInfo extends object type ProcessInfo extends object
properties properties
# Specifies process type. # Specifies process type.
ProcessType type string type
# Specifies process id. # Specifies process id.
integer id integer id
# Specifies cumulative CPU usage in seconds across all threads of the # Specifies cumulative CPU usage in seconds across all threads of the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment