OLD | NEW |
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 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "content/browser/devtools/devtools_agent_host_impl.h" | 18 #include "content/browser/devtools/devtools_agent_host_impl.h" |
19 #include "content/browser/devtools/service_worker_devtools_agent_host.h" | 19 #include "content/browser/devtools/service_worker_devtools_agent_host.h" |
20 #include "content/browser/devtools/service_worker_devtools_manager.h" | 20 #include "content/browser/devtools/service_worker_devtools_manager.h" |
21 #include "content/browser/service_worker/embedded_worker_status.h" | 21 #include "content/browser/service_worker/embedded_worker_status.h" |
22 #include "content/browser/service_worker/service_worker_context_observer.h" | 22 #include "content/browser/service_worker/service_worker_context_core_observer.h" |
23 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 23 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
24 #include "content/browser/service_worker/service_worker_registration.h" | 24 #include "content/browser/service_worker/service_worker_registration.h" |
25 #include "content/browser/service_worker/service_worker_version.h" | 25 #include "content/browser/service_worker/service_worker_version.h" |
26 #include "content/grit/content_resources.h" | 26 #include "content/grit/content_resources.h" |
27 #include "content/public/browser/browser_context.h" | 27 #include "content/public/browser/browser_context.h" |
28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
30 #include "content/public/browser/storage_partition.h" | 30 #include "content/public/browser/storage_partition.h" |
31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
32 #include "content/public/browser/web_ui.h" | 32 #include "content/public/browser/web_ui.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 args.push_back(GetRegistrationListValue(stored_registrations)); | 262 args.push_back(GetRegistrationListValue(stored_registrations)); |
263 args.push_back(base::MakeUnique<Value>(partition_id)); | 263 args.push_back(base::MakeUnique<Value>(partition_id)); |
264 args.push_back(base::MakeUnique<Value>(context_path.value())); | 264 args.push_back(base::MakeUnique<Value>(context_path.value())); |
265 internals->web_ui()->CallJavascriptFunctionUnsafe( | 265 internals->web_ui()->CallJavascriptFunctionUnsafe( |
266 "serviceworker.onPartitionData", ConvertToRawPtrVector(args)); | 266 "serviceworker.onPartitionData", ConvertToRawPtrVector(args)); |
267 } | 267 } |
268 | 268 |
269 } // namespace | 269 } // namespace |
270 | 270 |
271 class ServiceWorkerInternalsUI::PartitionObserver | 271 class ServiceWorkerInternalsUI::PartitionObserver |
272 : public ServiceWorkerContextObserver { | 272 : public ServiceWorkerContextCoreObserver { |
273 public: | 273 public: |
274 PartitionObserver(int partition_id, WebUI* web_ui) | 274 PartitionObserver(int partition_id, WebUI* web_ui) |
275 : partition_id_(partition_id), web_ui_(web_ui) {} | 275 : partition_id_(partition_id), web_ui_(web_ui) {} |
276 ~PartitionObserver() override {} | 276 ~PartitionObserver() override {} |
277 // ServiceWorkerContextObserver overrides: | 277 // ServiceWorkerContextCoreObserver overrides: |
278 void OnRunningStateChanged(int64_t version_id, | 278 void OnRunningStateChanged(int64_t version_id, |
279 EmbeddedWorkerStatus) override { | 279 EmbeddedWorkerStatus) override { |
280 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 280 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
281 web_ui_->CallJavascriptFunctionUnsafe( | 281 web_ui_->CallJavascriptFunctionUnsafe( |
282 "serviceworker.onRunningStateChanged", Value(partition_id_), | 282 "serviceworker.onRunningStateChanged", Value(partition_id_), |
283 Value(base::Int64ToString(version_id))); | 283 Value(base::Int64ToString(version_id))); |
284 } | 284 } |
285 void OnVersionStateChanged(int64_t version_id, | 285 void OnVersionStateChanged(int64_t version_id, |
286 ServiceWorkerVersion::Status) override { | 286 ServiceWorkerVersion::Status) override { |
287 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 287 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 610 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
611 return; | 611 return; |
612 } | 612 } |
613 | 613 |
614 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here | 614 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here |
615 // because that reduces a status code to boolean. | 615 // because that reduces a status code to boolean. |
616 context->context()->UnregisterServiceWorker(scope, callback); | 616 context->context()->UnregisterServiceWorker(scope, callback); |
617 } | 617 } |
618 | 618 |
619 } // namespace content | 619 } // namespace content |
OLD | NEW |