| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_storage.h" | 5 #include "content/browser/service_worker/service_worker_storage.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 TRACE_EVENT_INSTANT1( | 147 TRACE_EVENT_INSTANT1( |
| 148 "ServiceWorker", | 148 "ServiceWorker", |
| 149 "ServiceWorkerStorage::FindRegistrationForDocument:LazyInitialize", | 149 "ServiceWorkerStorage::FindRegistrationForDocument:LazyInitialize", |
| 150 TRACE_EVENT_SCOPE_THREAD, | 150 TRACE_EVENT_SCOPE_THREAD, |
| 151 "URL", document_url.spec()); | 151 "URL", document_url.spec()); |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 DCHECK_EQ(INITIALIZED, state_); | 154 DCHECK_EQ(INITIALIZED, state_); |
| 155 | 155 |
| 156 // See if there are any stored registrations for the origin. | 156 // See if there are any stored registrations for the origin. |
| 157 if (!ContainsKey(registered_origins_, document_url.GetOrigin())) { | 157 if (!base::ContainsKey(registered_origins_, document_url.GetOrigin())) { |
| 158 // Look for something currently being installed. | 158 // Look for something currently being installed. |
| 159 scoped_refptr<ServiceWorkerRegistration> installing_registration = | 159 scoped_refptr<ServiceWorkerRegistration> installing_registration = |
| 160 FindInstallingRegistrationForDocument(document_url); | 160 FindInstallingRegistrationForDocument(document_url); |
| 161 ServiceWorkerStatusCode status = installing_registration | 161 ServiceWorkerStatusCode status = installing_registration |
| 162 ? SERVICE_WORKER_OK | 162 ? SERVICE_WORKER_OK |
| 163 : SERVICE_WORKER_ERROR_NOT_FOUND; | 163 : SERVICE_WORKER_ERROR_NOT_FOUND; |
| 164 TRACE_EVENT_INSTANT2( | 164 TRACE_EVENT_INSTANT2( |
| 165 "ServiceWorker", | 165 "ServiceWorker", |
| 166 "ServiceWorkerStorage::FindRegistrationForDocument:CheckInstalling", | 166 "ServiceWorkerStorage::FindRegistrationForDocument:CheckInstalling", |
| 167 TRACE_EVENT_SCOPE_THREAD, | 167 TRACE_EVENT_SCOPE_THREAD, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 weak_factory_.GetWeakPtr(), scope, callback))) { | 201 weak_factory_.GetWeakPtr(), scope, callback))) { |
| 202 if (state_ != INITIALIZING) { | 202 if (state_ != INITIALIZING) { |
| 203 CompleteFindSoon(FROM_HERE, scoped_refptr<ServiceWorkerRegistration>(), | 203 CompleteFindSoon(FROM_HERE, scoped_refptr<ServiceWorkerRegistration>(), |
| 204 SERVICE_WORKER_ERROR_ABORT, callback); | 204 SERVICE_WORKER_ERROR_ABORT, callback); |
| 205 } | 205 } |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 DCHECK_EQ(INITIALIZED, state_); | 208 DCHECK_EQ(INITIALIZED, state_); |
| 209 | 209 |
| 210 // See if there are any stored registrations for the origin. | 210 // See if there are any stored registrations for the origin. |
| 211 if (!ContainsKey(registered_origins_, scope.GetOrigin())) { | 211 if (!base::ContainsKey(registered_origins_, scope.GetOrigin())) { |
| 212 // Look for something currently being installed. | 212 // Look for something currently being installed. |
| 213 scoped_refptr<ServiceWorkerRegistration> installing_registration = | 213 scoped_refptr<ServiceWorkerRegistration> installing_registration = |
| 214 FindInstallingRegistrationForPattern(scope); | 214 FindInstallingRegistrationForPattern(scope); |
| 215 ServiceWorkerStatusCode installing_status = | 215 ServiceWorkerStatusCode installing_status = |
| 216 installing_registration ? SERVICE_WORKER_OK | 216 installing_registration ? SERVICE_WORKER_OK |
| 217 : SERVICE_WORKER_ERROR_NOT_FOUND; | 217 : SERVICE_WORKER_ERROR_NOT_FOUND; |
| 218 CompleteFindSoon(FROM_HERE, std::move(installing_registration), | 218 CompleteFindSoon(FROM_HERE, std::move(installing_registration), |
| 219 installing_status, callback); | 219 installing_status, callback); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 weak_factory_.GetWeakPtr(), registration_id, origin, callback))) { | 255 weak_factory_.GetWeakPtr(), registration_id, origin, callback))) { |
| 256 if (state_ != INITIALIZING) { | 256 if (state_ != INITIALIZING) { |
| 257 CompleteFindNow(scoped_refptr<ServiceWorkerRegistration>(), | 257 CompleteFindNow(scoped_refptr<ServiceWorkerRegistration>(), |
| 258 SERVICE_WORKER_ERROR_ABORT, callback); | 258 SERVICE_WORKER_ERROR_ABORT, callback); |
| 259 } | 259 } |
| 260 return; | 260 return; |
| 261 } | 261 } |
| 262 DCHECK_EQ(INITIALIZED, state_); | 262 DCHECK_EQ(INITIALIZED, state_); |
| 263 | 263 |
| 264 // See if there are any stored registrations for the origin. | 264 // See if there are any stored registrations for the origin. |
| 265 if (!ContainsKey(registered_origins_, origin)) { | 265 if (!base::ContainsKey(registered_origins_, origin)) { |
| 266 // Look for something currently being installed. | 266 // Look for something currently being installed. |
| 267 scoped_refptr<ServiceWorkerRegistration> installing_registration = | 267 scoped_refptr<ServiceWorkerRegistration> installing_registration = |
| 268 FindInstallingRegistrationForId(registration_id); | 268 FindInstallingRegistrationForId(registration_id); |
| 269 CompleteFindNow(installing_registration, | 269 CompleteFindNow(installing_registration, |
| 270 installing_registration ? SERVICE_WORKER_OK | 270 installing_registration ? SERVICE_WORKER_OK |
| 271 : SERVICE_WORKER_ERROR_NOT_FOUND, | 271 : SERVICE_WORKER_ERROR_NOT_FOUND, |
| 272 callback); | 272 callback); |
| 273 return; | 273 return; |
| 274 } | 274 } |
| 275 | 275 |
| (...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1770 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
| 1771 return; | 1771 return; |
| 1772 } | 1772 } |
| 1773 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1773 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
| 1774 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( | 1774 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( |
| 1775 ServiceWorkerMetrics::DELETE_OK); | 1775 ServiceWorkerMetrics::DELETE_OK); |
| 1776 callback.Run(SERVICE_WORKER_OK); | 1776 callback.Run(SERVICE_WORKER_OK); |
| 1777 } | 1777 } |
| 1778 | 1778 |
| 1779 } // namespace content | 1779 } // namespace content |
| OLD | NEW |