Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 std::unique_ptr<ServiceWorkerFetchRequest> request, | 685 std::unique_ptr<ServiceWorkerFetchRequest> request, |
| 686 const ResponseCallback& callback) { | 686 const ResponseCallback& callback) { |
| 687 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); | 687 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); |
| 688 if (backend_state_ != BACKEND_OPEN) { | 688 if (backend_state_ != BACKEND_OPEN) { |
| 689 callback.Run(CACHE_STORAGE_ERROR_STORAGE, | 689 callback.Run(CACHE_STORAGE_ERROR_STORAGE, |
| 690 std::unique_ptr<ServiceWorkerResponse>(), | 690 std::unique_ptr<ServiceWorkerResponse>(), |
| 691 std::unique_ptr<storage::BlobDataHandle>()); | 691 std::unique_ptr<storage::BlobDataHandle>()); |
| 692 return; | 692 return; |
| 693 } | 693 } |
| 694 | 694 |
| 695 if (request->method == "HEAD") { | |
| 696 callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, | |
| 697 std::unique_ptr<ServiceWorkerResponse>(), | |
| 698 std::unique_ptr<storage::BlobDataHandle>()); | |
| 699 return; | |
| 700 } | |
| 701 | |
| 695 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( | 702 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( |
| 696 new disk_cache::Entry*()); | 703 new disk_cache::Entry*()); |
| 697 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); | 704 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); |
| 698 ServiceWorkerFetchRequest* request_ptr = request.get(); | 705 ServiceWorkerFetchRequest* request_ptr = request.get(); |
| 699 | 706 |
| 700 net::CompletionCallback open_entry_callback = base::Bind( | 707 net::CompletionCallback open_entry_callback = base::Bind( |
| 701 &CacheStorageCache::MatchDidOpenEntry, weak_ptr_factory_.GetWeakPtr(), | 708 &CacheStorageCache::MatchDidOpenEntry, weak_ptr_factory_.GetWeakPtr(), |
| 702 base::Passed(std::move(request)), callback, | 709 base::Passed(std::move(request)), callback, |
| 703 base::Passed(std::move(scoped_entry_ptr))); | 710 base::Passed(std::move(scoped_entry_ptr))); |
| 704 | 711 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 std::unique_ptr<ServiceWorkerFetchRequest> request, | 790 std::unique_ptr<ServiceWorkerFetchRequest> request, |
| 784 const CacheStorageCacheQueryParams& options, | 791 const CacheStorageCacheQueryParams& options, |
| 785 const ResponsesCallback& callback) { | 792 const ResponsesCallback& callback) { |
| 786 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); | 793 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); |
| 787 if (backend_state_ != BACKEND_OPEN) { | 794 if (backend_state_ != BACKEND_OPEN) { |
| 788 callback.Run(CACHE_STORAGE_ERROR_STORAGE, std::unique_ptr<Responses>(), | 795 callback.Run(CACHE_STORAGE_ERROR_STORAGE, std::unique_ptr<Responses>(), |
| 789 std::unique_ptr<BlobDataHandles>()); | 796 std::unique_ptr<BlobDataHandles>()); |
| 790 return; | 797 return; |
| 791 } | 798 } |
| 792 | 799 |
| 800 if (request && request->method == "HEAD") { | |
|
jkarlin
2016/08/04 14:50:40
The updated spec reads that if it's a HEAD and opt
jkarlin
2016/08/04 14:52:18
This should really be a check to make sure that it
jsbell
2016/08/04 23:49:17
Done and done.
| |
| 801 callback.Run(CACHE_STORAGE_OK, base::WrapUnique(new Responses), | |
| 802 base::WrapUnique(new BlobDataHandles)); | |
| 803 return; | |
| 804 } | |
| 805 | |
| 793 QueryCache(std::move(request), options, | 806 QueryCache(std::move(request), options, |
| 794 base::Bind(&CacheStorageCache::MatchAllDidQueryCache, | 807 base::Bind(&CacheStorageCache::MatchAllDidQueryCache, |
| 795 weak_ptr_factory_.GetWeakPtr(), callback)); | 808 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 796 } | 809 } |
| 797 | 810 |
| 798 void CacheStorageCache::MatchAllDidQueryCache( | 811 void CacheStorageCache::MatchAllDidQueryCache( |
| 799 const ResponsesCallback& callback, | 812 const ResponsesCallback& callback, |
| 800 CacheStorageError error, | 813 CacheStorageError error, |
| 801 std::unique_ptr<QueryCacheResults> query_cache_results) { | 814 std::unique_ptr<QueryCacheResults> query_cache_results) { |
| 802 if (error != CACHE_STORAGE_OK) { | 815 if (error != CACHE_STORAGE_OK) { |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1454 temp_entry, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); | 1467 temp_entry, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); |
| 1455 return blob_storage_context_->AddFinishedBlob(&blob_data); | 1468 return blob_storage_context_->AddFinishedBlob(&blob_data); |
| 1456 } | 1469 } |
| 1457 | 1470 |
| 1458 std::unique_ptr<CacheStorageCacheHandle> | 1471 std::unique_ptr<CacheStorageCacheHandle> |
| 1459 CacheStorageCache::CreateCacheHandle() { | 1472 CacheStorageCache::CreateCacheHandle() { |
| 1460 return cache_storage_->CreateCacheHandle(this); | 1473 return cache_storage_->CreateCacheHandle(this); |
| 1461 } | 1474 } |
| 1462 | 1475 |
| 1463 } // namespace content | 1476 } // namespace content |
| OLD | NEW |