| 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 <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 159 } |
| 160 | 160 |
| 161 ListValue* GetRegistrationListValue( | 161 ListValue* GetRegistrationListValue( |
| 162 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { | 162 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { |
| 163 ListValue* result = new ListValue(); | 163 ListValue* result = new ListValue(); |
| 164 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = | 164 for (std::vector<ServiceWorkerRegistrationInfo>::const_iterator it = |
| 165 registrations.begin(); | 165 registrations.begin(); |
| 166 it != registrations.end(); | 166 it != registrations.end(); |
| 167 ++it) { | 167 ++it) { |
| 168 const ServiceWorkerRegistrationInfo& registration = *it; | 168 const ServiceWorkerRegistrationInfo& registration = *it; |
| 169 std::unique_ptr<class base::DictionaryValue> registration_info( | 169 std::unique_ptr<DictionaryValue> registration_info(new DictionaryValue()); |
| 170 new DictionaryValue()); | |
| 171 registration_info->SetString("scope", registration.pattern.spec()); | 170 registration_info->SetString("scope", registration.pattern.spec()); |
| 172 registration_info->SetString( | 171 registration_info->SetString( |
| 173 "registration_id", base::Int64ToString(registration.registration_id)); | 172 "registration_id", base::Int64ToString(registration.registration_id)); |
| 174 | 173 |
| 175 if (registration.active_version.version_id != | 174 if (registration.active_version.version_id != |
| 176 kInvalidServiceWorkerVersionId) { | 175 kInvalidServiceWorkerVersionId) { |
| 177 DictionaryValue* active_info = new DictionaryValue(); | 176 DictionaryValue* active_info = new DictionaryValue(); |
| 178 UpdateVersionInfo(registration.active_version, active_info); | 177 UpdateVersionInfo(registration.active_version, active_info); |
| 179 registration_info->Set("active", active_info); | 178 registration_info->Set("active", active_info); |
| 180 } | 179 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 191 return result; | 190 return result; |
| 192 } | 191 } |
| 193 | 192 |
| 194 ListValue* GetVersionListValue( | 193 ListValue* GetVersionListValue( |
| 195 const std::vector<ServiceWorkerVersionInfo>& versions) { | 194 const std::vector<ServiceWorkerVersionInfo>& versions) { |
| 196 ListValue* result = new ListValue(); | 195 ListValue* result = new ListValue(); |
| 197 for (std::vector<ServiceWorkerVersionInfo>::const_iterator it = | 196 for (std::vector<ServiceWorkerVersionInfo>::const_iterator it = |
| 198 versions.begin(); | 197 versions.begin(); |
| 199 it != versions.end(); | 198 it != versions.end(); |
| 200 ++it) { | 199 ++it) { |
| 201 DictionaryValue* info = new DictionaryValue(); | 200 std::unique_ptr<DictionaryValue> info(new DictionaryValue()); |
| 202 UpdateVersionInfo(*it, info); | 201 UpdateVersionInfo(*it, info.get()); |
| 203 result->Append(info); | 202 result->Append(std::move(info)); |
| 204 } | 203 } |
| 205 return result; | 204 return result; |
| 206 } | 205 } |
| 207 | 206 |
| 208 void DidGetStoredRegistrationsOnIOThread( | 207 void DidGetStoredRegistrationsOnIOThread( |
| 209 scoped_refptr<ServiceWorkerContextWrapper> context, | 208 scoped_refptr<ServiceWorkerContextWrapper> context, |
| 210 const GetRegistrationsCallback& callback, | 209 const GetRegistrationsCallback& callback, |
| 211 ServiceWorkerStatusCode status, | 210 ServiceWorkerStatusCode status, |
| 212 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { | 211 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { |
| 213 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 212 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 589 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| 591 return; | 590 return; |
| 592 } | 591 } |
| 593 | 592 |
| 594 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here | 593 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here |
| 595 // because that reduces a status code to boolean. | 594 // because that reduces a status code to boolean. |
| 596 context->context()->UnregisterServiceWorker(scope, callback); | 595 context->context()->UnregisterServiceWorker(scope, callback); |
| 597 } | 596 } |
| 598 | 597 |
| 599 } // namespace content | 598 } // namespace content |
| OLD | NEW |