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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 base::MessageLoopProxy::current(), | 485 base::MessageLoopProxy::current(), |
486 registration_id, origin, | 486 registration_id, origin, |
487 base::Bind(&ServiceWorkerStorage::DidDeleteRegistration, | 487 base::Bind(&ServiceWorkerStorage::DidDeleteRegistration, |
488 weak_factory_.GetWeakPtr(), params))); | 488 weak_factory_.GetWeakPtr(), params))); |
489 | 489 |
490 // The registration should no longer be findable. | 490 // The registration should no longer be findable. |
491 pending_deletions_.insert(registration_id); | 491 pending_deletions_.insert(registration_id); |
492 ServiceWorkerRegistration* registration = | 492 ServiceWorkerRegistration* registration = |
493 context_->GetLiveRegistration(registration_id); | 493 context_->GetLiveRegistration(registration_id); |
494 if (registration) | 494 if (registration) |
495 registration->set_is_deleted(); | 495 registration->SetIsDeleted(); |
496 } | 496 } |
497 | 497 |
498 scoped_ptr<ServiceWorkerResponseReader> | 498 scoped_ptr<ServiceWorkerResponseReader> |
499 ServiceWorkerStorage::CreateResponseReader(int64 response_id) { | 499 ServiceWorkerStorage::CreateResponseReader(int64 response_id) { |
500 return make_scoped_ptr( | 500 return make_scoped_ptr( |
501 new ServiceWorkerResponseReader(response_id, disk_cache())); | 501 new ServiceWorkerResponseReader(response_id, disk_cache())); |
502 } | 502 } |
503 | 503 |
504 scoped_ptr<ServiceWorkerResponseWriter> | 504 scoped_ptr<ServiceWorkerResponseWriter> |
505 ServiceWorkerStorage::CreateResponseWriter(int64 response_id) { | 505 ServiceWorkerStorage::CreateResponseWriter(int64 response_id) { |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 if (status != ServiceWorkerDatabase::STATUS_OK) { | 901 if (status != ServiceWorkerDatabase::STATUS_OK) { |
902 ScheduleDeleteAndStartOver(); | 902 ScheduleDeleteAndStartOver(); |
903 params.callback.Run(DatabaseStatusToStatusCode(status)); | 903 params.callback.Run(DatabaseStatusToStatusCode(status)); |
904 return; | 904 return; |
905 } | 905 } |
906 if (origin_is_deletable) | 906 if (origin_is_deletable) |
907 registered_origins_.erase(params.origin); | 907 registered_origins_.erase(params.origin); |
908 params.callback.Run(SERVICE_WORKER_OK); | 908 params.callback.Run(SERVICE_WORKER_OK); |
909 | 909 |
910 if (!context_ || !context_->GetLiveVersion(version_id)) | 910 if (!context_ || !context_->GetLiveVersion(version_id)) |
911 StartPurgingResources(newly_purgeable_resources); | 911 StartPurgingResources(newly_purgeable_resources); |
nhiroki
2014/08/06 06:57:27
(Or do we have to notify the listeners of OnRegist
| |
912 } | 912 } |
913 | 913 |
914 scoped_refptr<ServiceWorkerRegistration> | 914 scoped_refptr<ServiceWorkerRegistration> |
915 ServiceWorkerStorage::GetOrCreateRegistration( | 915 ServiceWorkerStorage::GetOrCreateRegistration( |
916 const ServiceWorkerDatabase::RegistrationData& data, | 916 const ServiceWorkerDatabase::RegistrationData& data, |
917 const ResourceList& resources) { | 917 const ResourceList& resources) { |
918 scoped_refptr<ServiceWorkerRegistration> registration = | 918 scoped_refptr<ServiceWorkerRegistration> registration = |
919 context_->GetLiveRegistration(data.registration_id); | 919 context_->GetLiveRegistration(data.registration_id); |
920 if (registration) | 920 if (registration) |
921 return registration; | 921 return registration; |
922 | 922 |
923 registration = new ServiceWorkerRegistration( | 923 registration = new ServiceWorkerRegistration( |
924 data.scope, data.script, data.registration_id, context_); | 924 data.scope, data.script, data.registration_id, context_); |
925 if (pending_deletions_.find(data.registration_id) != | 925 if (pending_deletions_.find(data.registration_id) != |
926 pending_deletions_.end()) { | 926 pending_deletions_.end()) { |
927 registration->set_is_deleted(); | 927 registration->SetIsDeleted(); |
928 } | 928 } |
929 scoped_refptr<ServiceWorkerVersion> version = | 929 scoped_refptr<ServiceWorkerVersion> version = |
930 context_->GetLiveVersion(data.version_id); | 930 context_->GetLiveVersion(data.version_id); |
931 if (!version) { | 931 if (!version) { |
932 version = new ServiceWorkerVersion(registration, data.version_id, context_); | 932 version = new ServiceWorkerVersion(registration, data.version_id, context_); |
933 version->SetStatus(data.is_active ? | 933 version->SetStatus(data.is_active ? |
934 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED); | 934 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED); |
935 version->script_cache_map()->SetResources(resources); | 935 version->script_cache_map()->SetResources(resources); |
936 } | 936 } |
937 | 937 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 // Give up the corruption recovery until the browser restarts. | 1346 // Give up the corruption recovery until the browser restarts. |
1347 LOG(ERROR) << "Failed to delete the diskcache."; | 1347 LOG(ERROR) << "Failed to delete the diskcache."; |
1348 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1348 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
1349 return; | 1349 return; |
1350 } | 1350 } |
1351 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1351 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
1352 callback.Run(SERVICE_WORKER_OK); | 1352 callback.Run(SERVICE_WORKER_OK); |
1353 } | 1353 } |
1354 | 1354 |
1355 } // namespace content | 1355 } // namespace content |
OLD | NEW |