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

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

Issue 2204683002: Cache API should not match() HEAD requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add keys()/delete() tests, fix found issues Created 4 years, 4 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 std::unique_ptr<ServiceWorkerFetchRequest> request, 586 std::unique_ptr<ServiceWorkerFetchRequest> request,
587 const CacheStorageCacheQueryParams& options, 587 const CacheStorageCacheQueryParams& options,
588 const QueryCacheResultsCallback& callback) { 588 const QueryCacheResultsCallback& callback) {
589 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); 589 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_);
590 if (backend_state_ != BACKEND_OPEN) { 590 if (backend_state_ != BACKEND_OPEN) {
591 callback.Run(CACHE_STORAGE_ERROR_STORAGE, 591 callback.Run(CACHE_STORAGE_ERROR_STORAGE,
592 std::unique_ptr<QueryCacheResults>()); 592 std::unique_ptr<QueryCacheResults>());
593 return; 593 return;
594 } 594 }
595 595
596 if (!options.ignore_method && request && !request->method.empty() &&
597 request->method != "GET") {
598 callback.Run(CACHE_STORAGE_OK, base::WrapUnique(new QueryCacheResults(
jkarlin 2016/08/10 13:22:45 base::MakeUnique<QueryCacheResults>(std::move(requ
jsbell 2016/08/10 17:18:09 Done.
599 std::move(request), options, callback)));
600 return;
601 }
602
596 std::unique_ptr<QueryCacheResults> query_cache_results( 603 std::unique_ptr<QueryCacheResults> query_cache_results(
597 new QueryCacheResults(std::move(request), options, callback)); 604 new QueryCacheResults(std::move(request), options, callback));
598 OpenAllEntries(base::Bind(&CacheStorageCache::QueryCacheDidOpenAllEntries, 605 OpenAllEntries(base::Bind(&CacheStorageCache::QueryCacheDidOpenAllEntries,
599 weak_ptr_factory_.GetWeakPtr(), 606 weak_ptr_factory_.GetWeakPtr(),
600 base::Passed(std::move(query_cache_results)))); 607 base::Passed(std::move(query_cache_results))));
601 } 608 }
602 609
603 void CacheStorageCache::QueryCacheDidOpenAllEntries( 610 void CacheStorageCache::QueryCacheDidOpenAllEntries(
604 std::unique_ptr<QueryCacheResults> query_cache_results, 611 std::unique_ptr<QueryCacheResults> query_cache_results,
605 std::unique_ptr<OpenAllEntriesContext> entries_context, 612 std::unique_ptr<OpenAllEntriesContext> entries_context,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 std::unique_ptr<ServiceWorkerFetchRequest> request, 692 std::unique_ptr<ServiceWorkerFetchRequest> request,
686 const ResponseCallback& callback) { 693 const ResponseCallback& callback) {
687 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); 694 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_);
688 if (backend_state_ != BACKEND_OPEN) { 695 if (backend_state_ != BACKEND_OPEN) {
689 callback.Run(CACHE_STORAGE_ERROR_STORAGE, 696 callback.Run(CACHE_STORAGE_ERROR_STORAGE,
690 std::unique_ptr<ServiceWorkerResponse>(), 697 std::unique_ptr<ServiceWorkerResponse>(),
691 std::unique_ptr<storage::BlobDataHandle>()); 698 std::unique_ptr<storage::BlobDataHandle>());
692 return; 699 return;
693 } 700 }
694 701
702 if (request->method == "HEAD") {
jkarlin 2016/08/10 13:22:44 Should this be "if (request->method != "GET")" ?
jsbell 2016/08/10 17:18:09 Done.
703 callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND,
704 std::unique_ptr<ServiceWorkerResponse>(),
705 std::unique_ptr<storage::BlobDataHandle>());
706 return;
707 }
708
695 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( 709 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr(
696 new disk_cache::Entry*()); 710 new disk_cache::Entry*());
697 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); 711 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get();
698 ServiceWorkerFetchRequest* request_ptr = request.get(); 712 ServiceWorkerFetchRequest* request_ptr = request.get();
699 713
700 net::CompletionCallback open_entry_callback = base::Bind( 714 net::CompletionCallback open_entry_callback = base::Bind(
701 &CacheStorageCache::MatchDidOpenEntry, weak_ptr_factory_.GetWeakPtr(), 715 &CacheStorageCache::MatchDidOpenEntry, weak_ptr_factory_.GetWeakPtr(),
702 base::Passed(std::move(request)), callback, 716 base::Passed(std::move(request)), callback,
703 base::Passed(std::move(scoped_entry_ptr))); 717 base::Passed(std::move(scoped_entry_ptr)));
704 718
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 temp_entry, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); 1468 temp_entry, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA);
1455 return blob_storage_context_->AddFinishedBlob(&blob_data); 1469 return blob_storage_context_->AddFinishedBlob(&blob_data);
1456 } 1470 }
1457 1471
1458 std::unique_ptr<CacheStorageCacheHandle> 1472 std::unique_ptr<CacheStorageCacheHandle>
1459 CacheStorageCache::CreateCacheHandle() { 1473 CacheStorageCache::CreateCacheHandle() {
1460 return cache_storage_->CreateCacheHandle(this); 1474 return cache_storage_->CreateCacheHandle(this);
1461 } 1475 }
1462 1476
1463 } // namespace content 1477 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698