| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 std::unique_ptr<ServiceWorkerFetchRequest> request, | 589 std::unique_ptr<ServiceWorkerFetchRequest> request, |
| 590 const CacheStorageCacheQueryParams& options, | 590 const CacheStorageCacheQueryParams& options, |
| 591 const QueryCacheResultsCallback& callback) { | 591 const QueryCacheResultsCallback& callback) { |
| 592 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); | 592 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); |
| 593 if (backend_state_ != BACKEND_OPEN) { | 593 if (backend_state_ != BACKEND_OPEN) { |
| 594 callback.Run(CACHE_STORAGE_ERROR_STORAGE, | 594 callback.Run(CACHE_STORAGE_ERROR_STORAGE, |
| 595 std::unique_ptr<QueryCacheResults>()); | 595 std::unique_ptr<QueryCacheResults>()); |
| 596 return; | 596 return; |
| 597 } | 597 } |
| 598 | 598 |
| 599 if (!options.ignore_method && request && !request->method.empty() && |
| 600 request->method != "GET") { |
| 601 callback.Run(CACHE_STORAGE_OK, base::MakeUnique<QueryCacheResults>( |
| 602 std::move(request), options, callback)); |
| 603 return; |
| 604 } |
| 605 |
| 599 std::unique_ptr<QueryCacheResults> query_cache_results( | 606 std::unique_ptr<QueryCacheResults> query_cache_results( |
| 600 new QueryCacheResults(std::move(request), options, callback)); | 607 new QueryCacheResults(std::move(request), options, callback)); |
| 601 OpenAllEntries(base::Bind(&CacheStorageCache::QueryCacheDidOpenAllEntries, | 608 OpenAllEntries(base::Bind(&CacheStorageCache::QueryCacheDidOpenAllEntries, |
| 602 weak_ptr_factory_.GetWeakPtr(), | 609 weak_ptr_factory_.GetWeakPtr(), |
| 603 base::Passed(std::move(query_cache_results)))); | 610 base::Passed(std::move(query_cache_results)))); |
| 604 } | 611 } |
| 605 | 612 |
| 606 void CacheStorageCache::QueryCacheDidOpenAllEntries( | 613 void CacheStorageCache::QueryCacheDidOpenAllEntries( |
| 607 std::unique_ptr<QueryCacheResults> query_cache_results, | 614 std::unique_ptr<QueryCacheResults> query_cache_results, |
| 608 std::unique_ptr<OpenAllEntriesContext> entries_context, | 615 std::unique_ptr<OpenAllEntriesContext> entries_context, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 std::unique_ptr<ServiceWorkerFetchRequest> request, | 702 std::unique_ptr<ServiceWorkerFetchRequest> request, |
| 696 const ResponseCallback& callback) { | 703 const ResponseCallback& callback) { |
| 697 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); | 704 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); |
| 698 if (backend_state_ != BACKEND_OPEN) { | 705 if (backend_state_ != BACKEND_OPEN) { |
| 699 callback.Run(CACHE_STORAGE_ERROR_STORAGE, | 706 callback.Run(CACHE_STORAGE_ERROR_STORAGE, |
| 700 std::unique_ptr<ServiceWorkerResponse>(), | 707 std::unique_ptr<ServiceWorkerResponse>(), |
| 701 std::unique_ptr<storage::BlobDataHandle>()); | 708 std::unique_ptr<storage::BlobDataHandle>()); |
| 702 return; | 709 return; |
| 703 } | 710 } |
| 704 | 711 |
| 712 if (!request->method.empty() && request->method != "GET") { |
| 713 callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, |
| 714 std::unique_ptr<ServiceWorkerResponse>(), |
| 715 std::unique_ptr<storage::BlobDataHandle>()); |
| 716 return; |
| 717 } |
| 718 |
| 705 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( | 719 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( |
| 706 new disk_cache::Entry*()); | 720 new disk_cache::Entry*()); |
| 707 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); | 721 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); |
| 708 ServiceWorkerFetchRequest* request_ptr = request.get(); | 722 ServiceWorkerFetchRequest* request_ptr = request.get(); |
| 709 | 723 |
| 710 net::CompletionCallback open_entry_callback = base::Bind( | 724 net::CompletionCallback open_entry_callback = base::Bind( |
| 711 &CacheStorageCache::MatchDidOpenEntry, weak_ptr_factory_.GetWeakPtr(), | 725 &CacheStorageCache::MatchDidOpenEntry, weak_ptr_factory_.GetWeakPtr(), |
| 712 base::Passed(std::move(request)), callback, | 726 base::Passed(std::move(request)), callback, |
| 713 base::Passed(std::move(scoped_entry_ptr))); | 727 base::Passed(std::move(scoped_entry_ptr))); |
| 714 | 728 |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 temp_entry, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); | 1479 temp_entry, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); |
| 1466 return blob_storage_context_->AddFinishedBlob(&blob_data); | 1480 return blob_storage_context_->AddFinishedBlob(&blob_data); |
| 1467 } | 1481 } |
| 1468 | 1482 |
| 1469 std::unique_ptr<CacheStorageCacheHandle> | 1483 std::unique_ptr<CacheStorageCacheHandle> |
| 1470 CacheStorageCache::CreateCacheHandle() { | 1484 CacheStorageCache::CreateCacheHandle() { |
| 1471 return cache_storage_->CreateCacheHandle(this); | 1485 return cache_storage_->CreateCacheHandle(this); |
| 1472 } | 1486 } |
| 1473 | 1487 |
| 1474 } // namespace content | 1488 } // namespace content |
| OLD | NEW |