Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: content/browser/service_worker/service_worker_database.cc

Issue 355163003: Don't prematurely delete script resources when registration is deleted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: redesign Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_database.h" 5 #include "content/browser/service_worker/service_worker_database.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 registration.last_update_check = time; 591 registration.last_update_check = time;
592 592
593 leveldb::WriteBatch batch; 593 leveldb::WriteBatch batch;
594 PutRegistrationDataToBatch(registration, &batch); 594 PutRegistrationDataToBatch(registration, &batch);
595 return WriteBatch(&batch); 595 return WriteBatch(&batch);
596 } 596 }
597 597
598 ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteRegistration( 598 ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteRegistration(
599 int64 registration_id, 599 int64 registration_id,
600 const GURL& origin, 600 const GURL& origin,
601 int64* version_id,
601 std::vector<int64>* newly_purgeable_resources) { 602 std::vector<int64>* newly_purgeable_resources) {
602 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 603 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
603 Status status = LazyOpen(false); 604 Status status = LazyOpen(false);
604 if (IsNewOrNonexistentDatabase(status)) 605 if (IsNewOrNonexistentDatabase(status))
605 return STATUS_OK; 606 return STATUS_OK;
606 if (status != STATUS_OK) 607 if (status != STATUS_OK)
607 return status; 608 return status;
608 if (!origin.is_valid()) 609 if (!origin.is_valid())
609 return STATUS_ERROR_FAILED; 610 return STATUS_ERROR_FAILED;
610 611
(...skipping 12 matching lines...) Expand all
623 batch.Delete(CreateUniqueOriginKey(origin)); 624 batch.Delete(CreateUniqueOriginKey(origin));
624 } 625 }
625 626
626 // Delete a registration specified by |registration_id|. 627 // Delete a registration specified by |registration_id|.
627 batch.Delete(CreateRegistrationKey(registration_id, origin)); 628 batch.Delete(CreateRegistrationKey(registration_id, origin));
628 629
629 // Delete resource records associated with the registration. 630 // Delete resource records associated with the registration.
630 for (std::vector<RegistrationData>::const_iterator itr = 631 for (std::vector<RegistrationData>::const_iterator itr =
631 registrations.begin(); itr != registrations.end(); ++itr) { 632 registrations.begin(); itr != registrations.end(); ++itr) {
632 if (itr->registration_id == registration_id) { 633 if (itr->registration_id == registration_id) {
634 *version_id = itr->version_id;
633 status = DeleteResourceRecords( 635 status = DeleteResourceRecords(
634 itr->version_id, newly_purgeable_resources, &batch); 636 itr->version_id, newly_purgeable_resources, &batch);
635 if (status != STATUS_OK) 637 if (status != STATUS_OK)
636 return status; 638 return status;
637 break; 639 break;
638 } 640 }
639 } 641 }
640 642
641 return WriteBatch(&batch); 643 return WriteBatch(&batch);
642 } 644 }
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 const tracked_objects::Location& from_here, 1106 const tracked_objects::Location& from_here,
1105 Status status) { 1107 Status status) {
1106 if (status != ServiceWorkerDatabase::STATUS_OK) 1108 if (status != ServiceWorkerDatabase::STATUS_OK)
1107 Disable(from_here, status); 1109 Disable(from_here, status);
1108 UMA_HISTOGRAM_ENUMERATION(kWriteResultHistogramLabel, 1110 UMA_HISTOGRAM_ENUMERATION(kWriteResultHistogramLabel,
1109 status, 1111 status,
1110 ServiceWorkerDatabase::STATUS_ERROR_MAX); 1112 ServiceWorkerDatabase::STATUS_ERROR_MAX);
1111 } 1113 }
1112 1114
1113 } // namespace content 1115 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698