Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: content/browser/service_worker/service_worker_internals_ui.cc

Issue 1645453002: ServiceWorker: Show real process IDs in chrome://serviceworker-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/browser/service_worker/service_worker_internals_ui.h" 5 #include "content/browser/service_worker/service_worker_internals_ui.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "content/browser/devtools/devtools_agent_host_impl.h" 16 #include "content/browser/devtools/devtools_agent_host_impl.h"
17 #include "content/browser/devtools/service_worker_devtools_manager.h" 17 #include "content/browser/devtools/service_worker_devtools_manager.h"
18 #include "content/browser/service_worker/service_worker_context_observer.h" 18 #include "content/browser/service_worker/service_worker_context_observer.h"
19 #include "content/browser/service_worker/service_worker_context_wrapper.h" 19 #include "content/browser/service_worker/service_worker_context_wrapper.h"
20 #include "content/browser/service_worker/service_worker_registration.h" 20 #include "content/browser/service_worker/service_worker_registration.h"
21 #include "content/browser/service_worker/service_worker_version.h" 21 #include "content/browser/service_worker/service_worker_version.h"
22 #include "content/grit/content_resources.h" 22 #include "content/grit/content_resources.h"
23 #include "content/public/browser/browser_context.h" 23 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/render_process_host.h"
25 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
28 #include "content/public/browser/web_ui_data_source.h" 29 #include "content/public/browser/web_ui_data_source.h"
30 #include "content/public/common/child_process_host.h"
29 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
30 32
31 using base::DictionaryValue; 33 using base::DictionaryValue;
32 using base::FundamentalValue; 34 using base::FundamentalValue;
33 using base::ListValue; 35 using base::ListValue;
34 using base::StringValue; 36 using base::StringValue;
35 using base::Value; 37 using base::Value;
36 using base::WeakPtr; 38 using base::WeakPtr;
37 39
38 namespace content { 40 namespace content {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 84
83 scoped_refptr<ServiceWorkerVersion> version = 85 scoped_refptr<ServiceWorkerVersion> version =
84 context->GetLiveVersion(version_id); 86 context->GetLiveVersion(version_id);
85 if (!version.get()) { 87 if (!version.get()) {
86 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); 88 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND);
87 return; 89 return;
88 } 90 }
89 (*version.get().*method)(callback); 91 (*version.get().*method)(callback);
90 } 92 }
91 93
94 base::ProcessId GetRealProcessId(int process_host_id) {
95 if (process_host_id == ChildProcessHost::kInvalidUniqueID)
96 return base::kNullProcessId;
97
98 RenderProcessHost* rph = RenderProcessHost::FromID(process_host_id);
99 if (!rph)
100 return base::kNullProcessId;
101
102 base::ProcessHandle handle = rph->GetHandle();
103 if (handle == base::kNullProcessHandle)
104 return base::kNullProcessId;
105 return base::Process(handle).Pid();
106 }
107
92 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, 108 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version,
93 DictionaryValue* info) { 109 DictionaryValue* info) {
94 switch (version.running_status) { 110 switch (version.running_status) {
95 case ServiceWorkerVersion::STOPPED: 111 case ServiceWorkerVersion::STOPPED:
96 info->SetString("running_status", "STOPPED"); 112 info->SetString("running_status", "STOPPED");
97 break; 113 break;
98 case ServiceWorkerVersion::STARTING: 114 case ServiceWorkerVersion::STARTING:
99 info->SetString("running_status", "STARTING"); 115 info->SetString("running_status", "STARTING");
100 break; 116 break;
101 case ServiceWorkerVersion::RUNNING: 117 case ServiceWorkerVersion::RUNNING:
(...skipping 19 matching lines...) Expand all
121 break; 137 break;
122 case ServiceWorkerVersion::ACTIVATED: 138 case ServiceWorkerVersion::ACTIVATED:
123 info->SetString("status", "ACTIVATED"); 139 info->SetString("status", "ACTIVATED");
124 break; 140 break;
125 case ServiceWorkerVersion::REDUNDANT: 141 case ServiceWorkerVersion::REDUNDANT:
126 info->SetString("status", "REDUNDANT"); 142 info->SetString("status", "REDUNDANT");
127 break; 143 break;
128 } 144 }
129 info->SetString("script_url", version.script_url.spec()); 145 info->SetString("script_url", version.script_url.spec());
130 info->SetString("version_id", base::Int64ToString(version.version_id)); 146 info->SetString("version_id", base::Int64ToString(version.version_id));
131 info->SetInteger("process_id", version.process_id); 147 info->SetInteger("process_id",
148 static_cast<int>(GetRealProcessId(version.process_id)));
132 info->SetInteger("thread_id", version.thread_id); 149 info->SetInteger("thread_id", version.thread_id);
133 info->SetInteger("devtools_agent_route_id", version.devtools_agent_route_id); 150 info->SetInteger("devtools_agent_route_id", version.devtools_agent_route_id);
134 } 151 }
135 152
136 ListValue* GetRegistrationListValue( 153 ListValue* GetRegistrationListValue(
137 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { 154 const std::vector<ServiceWorkerRegistrationInfo>& registrations) {
138 ListValue* result = new ListValue(); 155 ListValue* result = new ListValue();
139 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = 156 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it =
140 registrations.begin(); 157 registrations.begin();
141 it != registrations.end(); 158 it != registrations.end();
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 callback.Run(SERVICE_WORKER_ERROR_ABORT); 579 callback.Run(SERVICE_WORKER_ERROR_ABORT);
563 return; 580 return;
564 } 581 }
565 582
566 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here 583 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here
567 // because that reduces a status code to boolean. 584 // because that reduces a status code to boolean.
568 context->context()->UnregisterServiceWorker(scope, callback); 585 context->context()->UnregisterServiceWorker(scope, callback);
569 } 586 }
570 587
571 } // namespace content 588 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698