Commit 82a9e031 authored by nhiroki's avatar nhiroki Committed by Commit bot

ServiceWorker: Show real process IDs in chrome://serviceworker-internals

Before this patch, the serviceworker-internals shows a render process host ID in
"Renderer process ID" entry. This is not really helpful for blink/chromium
developers to debug errors related to renderer process activity.

After this patch, the internal page shows a real render process ID in the entry.

BUG=544760

Review URL: https://codereview.chromium.org/1645453002

Cr-Commit-Position: refs/heads/master@{#372030}
parent cda481a2
......@@ -22,10 +22,12 @@
#include "content/grit/content_resources.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/url_constants.h"
using base::DictionaryValue;
......@@ -89,6 +91,20 @@ void CallServiceWorkerVersionMethodWithVersionID(
(*version.get().*method)(callback);
}
base::ProcessId GetRealProcessId(int process_host_id) {
if (process_host_id == ChildProcessHost::kInvalidUniqueID)
return base::kNullProcessId;
RenderProcessHost* rph = RenderProcessHost::FromID(process_host_id);
if (!rph)
return base::kNullProcessId;
base::ProcessHandle handle = rph->GetHandle();
if (handle == base::kNullProcessHandle)
return base::kNullProcessId;
return base::Process(handle).Pid();
}
void UpdateVersionInfo(const ServiceWorkerVersionInfo& version,
DictionaryValue* info) {
switch (version.running_status) {
......@@ -128,7 +144,8 @@ void UpdateVersionInfo(const ServiceWorkerVersionInfo& version,
}
info->SetString("script_url", version.script_url.spec());
info->SetString("version_id", base::Int64ToString(version.version_id));
info->SetInteger("process_id", version.process_id);
info->SetInteger("process_id",
static_cast<int>(GetRealProcessId(version.process_id)));
info->SetInteger("thread_id", version.thread_id);
info->SetInteger("devtools_agent_route_id", version.devtools_agent_route_id);
}
......
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