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 #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/storage_partition.h" | 25 #include "content/public/browser/storage_partition.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_ui.h" | 27 #include "content/public/browser/web_ui.h" |
28 #include "content/public/browser/web_ui_data_source.h" | 28 #include "content/public/browser/web_ui_data_source.h" |
| 29 #include "content/public/common/push_event_payload.h" |
29 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
30 | 31 |
31 using base::DictionaryValue; | 32 using base::DictionaryValue; |
32 using base::FundamentalValue; | 33 using base::FundamentalValue; |
33 using base::ListValue; | 34 using base::ListValue; |
34 using base::StringValue; | 35 using base::StringValue; |
35 using base::Value; | 36 using base::Value; |
36 using base::WeakPtr; | 37 using base::WeakPtr; |
37 | 38 |
38 namespace content { | 39 namespace content { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 callback)); | 104 callback)); |
104 return; | 105 return; |
105 } | 106 } |
106 | 107 |
107 scoped_refptr<ServiceWorkerVersion> version = | 108 scoped_refptr<ServiceWorkerVersion> version = |
108 context->GetLiveVersion(version_id); | 109 context->GetLiveVersion(version_id); |
109 if (!version.get()) { | 110 if (!version.get()) { |
110 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); | 111 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); |
111 return; | 112 return; |
112 } | 113 } |
113 std::string data = "Test push message from ServiceWorkerInternals."; | 114 PushEventPayload payload; |
114 version->DispatchPushEvent(callback, data); | 115 payload.setData("Test push message from ServiceWorkerInternals."); |
| 116 version->DispatchPushEvent(callback, payload); |
115 } | 117 } |
116 | 118 |
117 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, | 119 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, |
118 DictionaryValue* info) { | 120 DictionaryValue* info) { |
119 switch (version.running_status) { | 121 switch (version.running_status) { |
120 case ServiceWorkerVersion::STOPPED: | 122 case ServiceWorkerVersion::STOPPED: |
121 info->SetString("running_status", "STOPPED"); | 123 info->SetString("running_status", "STOPPED"); |
122 break; | 124 break; |
123 case ServiceWorkerVersion::STARTING: | 125 case ServiceWorkerVersion::STARTING: |
124 info->SetString("running_status", "STARTING"); | 126 info->SetString("running_status", "STARTING"); |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 616 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
615 return; | 617 return; |
616 } | 618 } |
617 | 619 |
618 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here | 620 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here |
619 // because that reduces a status code to boolean. | 621 // because that reduces a status code to boolean. |
620 context->context()->UnregisterServiceWorker(scope, callback); | 622 context->context()->UnregisterServiceWorker(scope, callback); |
621 } | 623 } |
622 | 624 |
623 } // namespace content | 625 } // namespace content |
OLD | NEW |