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 <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 285 |
286 struct CacheStorageCache::QueryCacheContext { | 286 struct CacheStorageCache::QueryCacheContext { |
287 QueryCacheContext(std::unique_ptr<ServiceWorkerFetchRequest> request, | 287 QueryCacheContext(std::unique_ptr<ServiceWorkerFetchRequest> request, |
288 const CacheStorageCacheQueryParams& options, | 288 const CacheStorageCacheQueryParams& options, |
289 const QueryCacheCallback& callback) | 289 const QueryCacheCallback& callback) |
290 : request(std::move(request)), | 290 : request(std::move(request)), |
291 options(options), | 291 options(options), |
292 callback(callback), | 292 callback(callback), |
293 matches(base::MakeUnique<QueryCacheResults>()) {} | 293 matches(base::MakeUnique<QueryCacheResults>()) {} |
294 | 294 |
| 295 ~QueryCacheContext() { |
| 296 // If the CacheStorageCache is deleted before a backend operation to open |
| 297 // an entry completes, the callback won't be run and the resulting entry |
| 298 // will be leaked unless we close it here. |
| 299 if (enumerated_entry) { |
| 300 enumerated_entry->Close(); |
| 301 enumerated_entry = nullptr; |
| 302 } |
| 303 } |
| 304 |
295 // Input to QueryCache | 305 // Input to QueryCache |
296 std::unique_ptr<ServiceWorkerFetchRequest> request; | 306 std::unique_ptr<ServiceWorkerFetchRequest> request; |
297 CacheStorageCacheQueryParams options; | 307 CacheStorageCacheQueryParams options; |
298 QueryCacheCallback callback; | 308 QueryCacheCallback callback; |
299 QueryCacheType query_type; | 309 QueryCacheType query_type; |
300 size_t estimated_out_bytes = 0; | 310 size_t estimated_out_bytes = 0; |
301 | 311 |
302 // Iteration state | 312 // Iteration state |
303 std::unique_ptr<disk_cache::Backend::Iterator> backend_iterator; | 313 std::unique_ptr<disk_cache::Backend::Iterator> backend_iterator; |
304 disk_cache::Entry* enumerated_entry = nullptr; | 314 disk_cache::Entry* enumerated_entry = nullptr; |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 temp_entry, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); | 1491 temp_entry, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); |
1482 return blob_storage_context_->AddFinishedBlob(&blob_data); | 1492 return blob_storage_context_->AddFinishedBlob(&blob_data); |
1483 } | 1493 } |
1484 | 1494 |
1485 std::unique_ptr<CacheStorageCacheHandle> | 1495 std::unique_ptr<CacheStorageCacheHandle> |
1486 CacheStorageCache::CreateCacheHandle() { | 1496 CacheStorageCache::CreateCacheHandle() { |
1487 return cache_storage_->CreateCacheHandle(this); | 1497 return cache_storage_->CreateCacheHandle(this); |
1488 } | 1498 } |
1489 | 1499 |
1490 } // namespace content | 1500 } // namespace content |
OLD | NEW |