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

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

Issue 2039743003: Introduce ServiceWorker.ActivatedWorkerPreparationForMainFrame.Time UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated falken's comment Created 4 years, 6 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
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/embedded_worker_status.h"
18 #include "content/browser/service_worker/service_worker_context_observer.h" 19 #include "content/browser/service_worker/service_worker_context_observer.h"
19 #include "content/browser/service_worker/service_worker_context_wrapper.h" 20 #include "content/browser/service_worker/service_worker_context_wrapper.h"
20 #include "content/browser/service_worker/service_worker_registration.h" 21 #include "content/browser/service_worker/service_worker_registration.h"
21 #include "content/browser/service_worker/service_worker_version.h" 22 #include "content/browser/service_worker/service_worker_version.h"
22 #include "content/grit/content_resources.h" 23 #include "content/grit/content_resources.h"
23 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/storage_partition.h" 27 #include "content/public/browser/storage_partition.h"
27 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // of the process handle and the render host still retains it. Therefore, we 107 // of the process handle and the render host still retains it. Therefore, we
107 // cannot create a base::Process object, which provides a proper way to get a 108 // cannot create a base::Process object, which provides a proper way to get a
108 // process id, from the handle. For a stopgap, we use this deprecated 109 // process id, from the handle. For a stopgap, we use this deprecated
109 // function that does not require the ownership (http://crbug.com/417532). 110 // function that does not require the ownership (http://crbug.com/417532).
110 return base::GetProcId(handle); 111 return base::GetProcId(handle);
111 } 112 }
112 113
113 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, 114 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version,
114 DictionaryValue* info) { 115 DictionaryValue* info) {
115 switch (version.running_status) { 116 switch (version.running_status) {
116 case ServiceWorkerVersion::STOPPED: 117 case EmbeddedWorkerStatus::STOPPED:
117 info->SetString("running_status", "STOPPED"); 118 info->SetString("running_status", "STOPPED");
118 break; 119 break;
119 case ServiceWorkerVersion::STARTING: 120 case EmbeddedWorkerStatus::STARTING:
120 info->SetString("running_status", "STARTING"); 121 info->SetString("running_status", "STARTING");
121 break; 122 break;
122 case ServiceWorkerVersion::RUNNING: 123 case EmbeddedWorkerStatus::RUNNING:
123 info->SetString("running_status", "RUNNING"); 124 info->SetString("running_status", "RUNNING");
124 break; 125 break;
125 case ServiceWorkerVersion::STOPPING: 126 case EmbeddedWorkerStatus::STOPPING:
126 info->SetString("running_status", "STOPPING"); 127 info->SetString("running_status", "STOPPING");
127 break; 128 break;
128 } 129 }
129 130
130 switch (version.status) { 131 switch (version.status) {
131 case ServiceWorkerVersion::NEW: 132 case ServiceWorkerVersion::NEW:
132 info->SetString("status", "NEW"); 133 info->SetString("status", "NEW");
133 break; 134 break;
134 case ServiceWorkerVersion::INSTALLING: 135 case ServiceWorkerVersion::INSTALLING:
135 info->SetString("status", "INSTALLING"); 136 info->SetString("status", "INSTALLING");
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } // namespace 247 } // namespace
247 248
248 class ServiceWorkerInternalsUI::PartitionObserver 249 class ServiceWorkerInternalsUI::PartitionObserver
249 : public ServiceWorkerContextObserver { 250 : public ServiceWorkerContextObserver {
250 public: 251 public:
251 PartitionObserver(int partition_id, WebUI* web_ui) 252 PartitionObserver(int partition_id, WebUI* web_ui)
252 : partition_id_(partition_id), web_ui_(web_ui) {} 253 : partition_id_(partition_id), web_ui_(web_ui) {}
253 ~PartitionObserver() override {} 254 ~PartitionObserver() override {}
254 // ServiceWorkerContextObserver overrides: 255 // ServiceWorkerContextObserver overrides:
255 void OnRunningStateChanged(int64_t version_id, 256 void OnRunningStateChanged(int64_t version_id,
256 ServiceWorkerVersion::RunningStatus) override { 257 EmbeddedWorkerStatus) override {
257 DCHECK_CURRENTLY_ON(BrowserThread::UI); 258 DCHECK_CURRENTLY_ON(BrowserThread::UI);
258 web_ui_->CallJavascriptFunctionUnsafe( 259 web_ui_->CallJavascriptFunctionUnsafe(
259 "serviceworker.onRunningStateChanged", FundamentalValue(partition_id_), 260 "serviceworker.onRunningStateChanged", FundamentalValue(partition_id_),
260 StringValue(base::Int64ToString(version_id))); 261 StringValue(base::Int64ToString(version_id)));
261 } 262 }
262 void OnVersionStateChanged(int64_t version_id, 263 void OnVersionStateChanged(int64_t version_id,
263 ServiceWorkerVersion::Status) override { 264 ServiceWorkerVersion::Status) override {
264 DCHECK_CURRENTLY_ON(BrowserThread::UI); 265 DCHECK_CURRENTLY_ON(BrowserThread::UI);
265 web_ui_->CallJavascriptFunctionUnsafe( 266 web_ui_->CallJavascriptFunctionUnsafe(
266 "serviceworker.onVersionStateChanged", FundamentalValue(partition_id_), 267 "serviceworker.onVersionStateChanged", FundamentalValue(partition_id_),
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 callback.Run(SERVICE_WORKER_ERROR_ABORT); 587 callback.Run(SERVICE_WORKER_ERROR_ABORT);
587 return; 588 return;
588 } 589 }
589 590
590 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here 591 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here
591 // because that reduces a status code to boolean. 592 // because that reduces a status code to boolean.
592 context->context()->UnregisterServiceWorker(scope, callback); 593 context->context()->UnregisterServiceWorker(scope, callback);
593 } 594 }
594 595
595 } // namespace content 596 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698