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

Side by Side Diff: content/browser/cache_storage/cache_storage_cache.cc

Issue 1694213002: CacheStorage: Add ignoreSearch option to cache.delete(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary check Created 4 years, 9 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
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/cache_storage/cache_storage_cache.h" 5 #include "content/browser/cache_storage/cache_storage_cache.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) { 806 void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) {
807 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); 807 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_);
808 if (backend_state_ != BACKEND_OPEN) { 808 if (backend_state_ != BACKEND_OPEN) {
809 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); 809 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE);
810 return; 810 return;
811 } 811 }
812 812
813 scoped_ptr<ServiceWorkerFetchRequest> request_copy( 813 scoped_ptr<ServiceWorkerFetchRequest> request_copy(
814 new ServiceWorkerFetchRequest(*put_context->request)); 814 new ServiceWorkerFetchRequest(*put_context->request));
815 815
816 DeleteImpl(std::move(request_copy), 816 DeleteImpl(std::move(request_copy), CacheStorageCacheQueryParams(),
817 base::Bind(&CacheStorageCache::PutDidDelete, 817 base::Bind(&CacheStorageCache::PutDidDelete,
818 weak_ptr_factory_.GetWeakPtr(), 818 weak_ptr_factory_.GetWeakPtr(),
819 base::Passed(std::move(put_context)))); 819 base::Passed(std::move(put_context))));
820 } 820 }
821 821
822 void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context, 822 void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context,
823 CacheStorageError delete_error) { 823 CacheStorageError delete_error) {
824 if (backend_state_ != BACKEND_OPEN) { 824 if (backend_state_ != BACKEND_OPEN) {
825 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); 825 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE);
826 return; 826 return;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest( 1028 scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest(
1029 operation.request.url, operation.request.method, 1029 operation.request.url, operation.request.method,
1030 operation.request.headers, operation.request.referrer, 1030 operation.request.headers, operation.request.referrer,
1031 operation.request.is_reload)); 1031 operation.request.is_reload));
1032 1032
1033 ErrorCallback pending_callback = 1033 ErrorCallback pending_callback =
1034 base::Bind(&CacheStorageCache::PendingErrorCallback, 1034 base::Bind(&CacheStorageCache::PendingErrorCallback,
1035 weak_ptr_factory_.GetWeakPtr(), callback); 1035 weak_ptr_factory_.GetWeakPtr(), callback);
1036 scheduler_->ScheduleOperation( 1036 scheduler_->ScheduleOperation(
1037 base::Bind(&CacheStorageCache::DeleteImpl, weak_ptr_factory_.GetWeakPtr(), 1037 base::Bind(&CacheStorageCache::DeleteImpl, weak_ptr_factory_.GetWeakPtr(),
1038 base::Passed(std::move(request)), pending_callback)); 1038 base::Passed(std::move(request)), operation.match_params,
1039 pending_callback));
1039 } 1040 }
1040 1041
1041 void CacheStorageCache::DeleteImpl( 1042 void CacheStorageCache::DeleteImpl(
1042 scoped_ptr<ServiceWorkerFetchRequest> request, 1043 scoped_ptr<ServiceWorkerFetchRequest> request,
1044 const CacheStorageCacheQueryParams& match_params,
1043 const ErrorCallback& callback) { 1045 const ErrorCallback& callback) {
1044 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); 1046 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_);
1045 if (backend_state_ != BACKEND_OPEN) { 1047 if (backend_state_ != BACKEND_OPEN) {
1046 callback.Run(CACHE_STORAGE_ERROR_STORAGE); 1048 callback.Run(CACHE_STORAGE_ERROR_STORAGE);
1047 return; 1049 return;
1048 } 1050 }
1051
1052 if (match_params.ignore_search) {
1053 OpenAllEntries(base::Bind(&CacheStorageCache::DeleteDidOpenAllEntries,
1054 weak_ptr_factory_.GetWeakPtr(),
1055 base::Passed(std::move(request)), callback));
1056 return;
1057 }
1058
1049 scoped_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*); 1059 scoped_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*);
1050 1060
1051 disk_cache::Entry** entry_ptr = entry.get(); 1061 disk_cache::Entry** entry_ptr = entry.get();
1052 1062
1053 ServiceWorkerFetchRequest* request_ptr = request.get(); 1063 ServiceWorkerFetchRequest* request_ptr = request.get();
1054 1064
1055 net::CompletionCallback open_entry_callback = base::Bind( 1065 net::CompletionCallback open_entry_callback = base::Bind(
1056 &CacheStorageCache::DeleteDidOpenEntry, weak_ptr_factory_.GetWeakPtr(), 1066 &CacheStorageCache::DeleteDidOpenEntry, weak_ptr_factory_.GetWeakPtr(),
1057 origin_, base::Passed(std::move(request)), callback, 1067 origin_, base::Passed(std::move(request)), callback,
1058 base::Passed(std::move(entry))); 1068 base::Passed(std::move(entry)));
1059 1069
1060 int rv = backend_->OpenEntry(request_ptr->url.spec(), entry_ptr, 1070 int rv = backend_->OpenEntry(request_ptr->url.spec(), entry_ptr,
1061 open_entry_callback); 1071 open_entry_callback);
1062 if (rv != net::ERR_IO_PENDING) 1072 if (rv != net::ERR_IO_PENDING)
1063 open_entry_callback.Run(rv); 1073 open_entry_callback.Run(rv);
1064 } 1074 }
1065 1075
1076 void CacheStorageCache::DeleteDidOpenAllEntries(
1077 scoped_ptr<ServiceWorkerFetchRequest> request,
1078 const ErrorCallback& callback,
1079 scoped_ptr<OpenAllEntriesContext> entries_context,
1080 CacheStorageError error) {
1081 if (error != CACHE_STORAGE_OK) {
1082 callback.Run(error);
1083 return;
1084 }
1085
1086 GURL request_url_without_query = RemoveQueryParam(request->url);
1087 for (Entries::iterator iter = entries_context->entries.begin();
1088 iter != entries_context->entries.end(); iter++) {
1089 disk_cache::Entry* entry(*iter);
1090 if (request_url_without_query == RemoveQueryParam(GURL(entry->GetKey())))
1091 entry->Doom();
1092 }
1093
1094 entries_context.reset();
1095
1096 UpdateCacheSize();
1097 callback.Run(CACHE_STORAGE_OK);
1098 }
1099
1066 void CacheStorageCache::DeleteDidOpenEntry( 1100 void CacheStorageCache::DeleteDidOpenEntry(
1067 const GURL& origin, 1101 const GURL& origin,
1068 scoped_ptr<ServiceWorkerFetchRequest> request, 1102 scoped_ptr<ServiceWorkerFetchRequest> request,
1069 const CacheStorageCache::ErrorCallback& callback, 1103 const CacheStorageCache::ErrorCallback& callback,
1070 scoped_ptr<disk_cache::Entry*> entry_ptr, 1104 scoped_ptr<disk_cache::Entry*> entry_ptr,
1071 int rv) { 1105 int rv) {
1072 if (rv != net::OK) { 1106 if (rv != net::OK) {
1073 callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND); 1107 callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND);
1074 return; 1108 return;
1075 } 1109 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 storage::BlobDataBuilder blob_data(response->blob_uuid); 1392 storage::BlobDataBuilder blob_data(response->blob_uuid);
1359 1393
1360 disk_cache::Entry* temp_entry = entry.get(); 1394 disk_cache::Entry* temp_entry = entry.get();
1361 blob_data.AppendDiskCacheEntry( 1395 blob_data.AppendDiskCacheEntry(
1362 new CacheStorageCacheDataHandle(this, std::move(entry)), temp_entry, 1396 new CacheStorageCacheDataHandle(this, std::move(entry)), temp_entry,
1363 INDEX_RESPONSE_BODY); 1397 INDEX_RESPONSE_BODY);
1364 return blob_storage_context_->AddFinishedBlob(&blob_data); 1398 return blob_storage_context_->AddFinishedBlob(&blob_data);
1365 } 1399 }
1366 1400
1367 } // namespace content 1401 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.h ('k') | content/browser/cache_storage/cache_storage_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698