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 #include <string> | 9 #include <string> |
9 #include <utility> | 10 #include <utility> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "content/browser/devtools/devtools_agent_host_impl.h" | 17 #include "content/browser/devtools/devtools_agent_host_impl.h" |
17 #include "content/browser/devtools/service_worker_devtools_manager.h" | 18 #include "content/browser/devtools/service_worker_devtools_manager.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 159 } |
159 | 160 |
160 ListValue* GetRegistrationListValue( | 161 ListValue* GetRegistrationListValue( |
161 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { | 162 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { |
162 ListValue* result = new ListValue(); | 163 ListValue* result = new ListValue(); |
163 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = | 164 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = |
164 registrations.begin(); | 165 registrations.begin(); |
165 it != registrations.end(); | 166 it != registrations.end(); |
166 ++it) { | 167 ++it) { |
167 const ServiceWorkerRegistrationInfo& registration = *it; | 168 const ServiceWorkerRegistrationInfo& registration = *it; |
168 DictionaryValue* registration_info = new DictionaryValue(); | 169 std::unique_ptr<class base::DictionaryValue> registration_info( |
| 170 new DictionaryValue()); |
169 registration_info->SetString("scope", registration.pattern.spec()); | 171 registration_info->SetString("scope", registration.pattern.spec()); |
170 registration_info->SetString( | 172 registration_info->SetString( |
171 "registration_id", base::Int64ToString(registration.registration_id)); | 173 "registration_id", base::Int64ToString(registration.registration_id)); |
172 | 174 |
173 if (registration.active_version.version_id != | 175 if (registration.active_version.version_id != |
174 kInvalidServiceWorkerVersionId) { | 176 kInvalidServiceWorkerVersionId) { |
175 DictionaryValue* active_info = new DictionaryValue(); | 177 DictionaryValue* active_info = new DictionaryValue(); |
176 UpdateVersionInfo(registration.active_version, active_info); | 178 UpdateVersionInfo(registration.active_version, active_info); |
177 registration_info->Set("active", active_info); | 179 registration_info->Set("active", active_info); |
178 } | 180 } |
179 | 181 |
180 if (registration.waiting_version.version_id != | 182 if (registration.waiting_version.version_id != |
181 kInvalidServiceWorkerVersionId) { | 183 kInvalidServiceWorkerVersionId) { |
182 DictionaryValue* waiting_info = new DictionaryValue(); | 184 DictionaryValue* waiting_info = new DictionaryValue(); |
183 UpdateVersionInfo(registration.waiting_version, waiting_info); | 185 UpdateVersionInfo(registration.waiting_version, waiting_info); |
184 registration_info->Set("waiting", waiting_info); | 186 registration_info->Set("waiting", waiting_info); |
185 } | 187 } |
186 | 188 |
187 result->Append(registration_info); | 189 result->Append(std::move(registration_info)); |
188 } | 190 } |
189 return result; | 191 return result; |
190 } | 192 } |
191 | 193 |
192 ListValue* GetVersionListValue( | 194 ListValue* GetVersionListValue( |
193 const std::vector<ServiceWorkerVersionInfo>& versions) { | 195 const std::vector<ServiceWorkerVersionInfo>& versions) { |
194 ListValue* result = new ListValue(); | 196 ListValue* result = new ListValue(); |
195 for (std::vector<ServiceWorkerVersionInfo>::const_iterator it = | 197 for (std::vector<ServiceWorkerVersionInfo>::const_iterator it = |
196 versions.begin(); | 198 versions.begin(); |
197 it != versions.end(); | 199 it != versions.end(); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 589 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
588 return; | 590 return; |
589 } | 591 } |
590 | 592 |
591 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here | 593 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here |
592 // because that reduces a status code to boolean. | 594 // because that reduces a status code to boolean. |
593 context->context()->UnregisterServiceWorker(scope, callback); | 595 context->context()->UnregisterServiceWorker(scope, callback); |
594 } | 596 } |
595 | 597 |
596 } // namespace content | 598 } // namespace content |
OLD | NEW |