| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 response(std::move(response)), | 267 response(std::move(response)), |
| 268 blob_data_handle(std::move(blob_data_handle)), | 268 blob_data_handle(std::move(blob_data_handle)), |
| 269 callback(callback) {} | 269 callback(callback) {} |
| 270 | 270 |
| 271 // Input parameters to the Put function. | 271 // Input parameters to the Put function. |
| 272 std::unique_ptr<ServiceWorkerFetchRequest> request; | 272 std::unique_ptr<ServiceWorkerFetchRequest> request; |
| 273 std::unique_ptr<ServiceWorkerResponse> response; | 273 std::unique_ptr<ServiceWorkerResponse> response; |
| 274 std::unique_ptr<storage::BlobDataHandle> blob_data_handle; | 274 std::unique_ptr<storage::BlobDataHandle> blob_data_handle; |
| 275 CacheStorageCache::ErrorCallback callback; | 275 CacheStorageCache::ErrorCallback callback; |
| 276 disk_cache::ScopedEntryPtr cache_entry; | 276 disk_cache::ScopedEntryPtr cache_entry; |
| 277 int64_t available_bytes = 0; | |
| 278 | 277 |
| 279 private: | 278 private: |
| 280 DISALLOW_COPY_AND_ASSIGN(PutContext); | 279 DISALLOW_COPY_AND_ASSIGN(PutContext); |
| 281 }; | 280 }; |
| 282 | 281 |
| 283 // static | 282 // static |
| 284 scoped_refptr<CacheStorageCache> CacheStorageCache::CreateMemoryCache( | 283 scoped_refptr<CacheStorageCache> CacheStorageCache::CreateMemoryCache( |
| 285 const GURL& origin, | 284 const GURL& origin, |
| 286 const std::string& cache_name, | 285 const std::string& cache_name, |
| 287 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 286 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 weak_ptr_factory_.GetWeakPtr(), | 350 weak_ptr_factory_.GetWeakPtr(), |
| 352 base::Passed(std::move(context)))); | 351 base::Passed(std::move(context)))); |
| 353 } | 352 } |
| 354 | 353 |
| 355 void CacheStorageCache::WriteSideData(const ErrorCallback& callback, | 354 void CacheStorageCache::WriteSideData(const ErrorCallback& callback, |
| 356 const GURL& url, | 355 const GURL& url, |
| 357 base::Time expected_response_time, | 356 base::Time expected_response_time, |
| 358 scoped_refptr<net::IOBuffer> buffer, | 357 scoped_refptr<net::IOBuffer> buffer, |
| 359 int buf_len) { | 358 int buf_len) { |
| 360 if (!LazyInitialize()) { | 359 if (!LazyInitialize()) { |
| 361 callback.Run(CACHE_STORAGE_ERROR_STORAGE); | 360 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 361 FROM_HERE, base::Bind(callback, CACHE_STORAGE_ERROR_STORAGE)); |
| 362 return; | 362 return; |
| 363 } | 363 } |
| 364 ErrorCallback pending_callback = | |
| 365 base::Bind(&CacheStorageCache::PendingErrorCallback, | |
| 366 weak_ptr_factory_.GetWeakPtr(), callback); | |
| 367 | 364 |
| 368 scheduler_->ScheduleOperation(base::Bind( | 365 // GetUsageAndQuota is called before entering a scheduled operation since it |
| 369 &CacheStorageCache::WriteSideDataImpl, weak_ptr_factory_.GetWeakPtr(), | 366 // can call Size, another scheduled operation. |
| 370 pending_callback, url, expected_response_time, buffer, buf_len)); | 367 quota_manager_proxy_->GetUsageAndQuota( |
| 368 base::ThreadTaskRunnerHandle::Get().get(), origin_, |
| 369 storage::kStorageTypeTemporary, |
| 370 base::Bind(&CacheStorageCache::WriteSideDataDidGetQuota, |
| 371 weak_ptr_factory_.GetWeakPtr(), callback, url, |
| 372 expected_response_time, buffer, buf_len)); |
| 371 } | 373 } |
| 372 | 374 |
| 373 void CacheStorageCache::BatchOperation( | 375 void CacheStorageCache::BatchOperation( |
| 374 const std::vector<CacheStorageBatchOperation>& operations, | 376 const std::vector<CacheStorageBatchOperation>& operations, |
| 375 const ErrorCallback& callback) { | 377 const ErrorCallback& callback) { |
| 376 if (!LazyInitialize()) { | 378 if (!LazyInitialize()) { |
| 377 callback.Run(CACHE_STORAGE_ERROR_STORAGE); | 379 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 380 FROM_HERE, base::Bind(callback, CACHE_STORAGE_ERROR_STORAGE)); |
| 378 return; | 381 return; |
| 379 } | 382 } |
| 380 | 383 |
| 384 // Estimate the required size of the put operations. The size of the deletes |
| 385 // is unknown and not considered. |
| 386 int64_t space_required = 0; |
| 387 for (const auto& operation : operations) { |
| 388 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT) { |
| 389 space_required += |
| 390 operation.request.blob_size + operation.response.blob_size; |
| 391 } |
| 392 } |
| 393 if (space_required > 0) { |
| 394 // GetUsageAndQuota is called before entering a scheduled operation since it |
| 395 // can call Size, another scheduled operation. This is racy. The decision |
| 396 // to commit is made before the scheduled Put operation runs. By the time |
| 397 // Put runs, the cache might already be full and the origin will be larger |
| 398 // than it's supposed to be. |
| 399 quota_manager_proxy_->GetUsageAndQuota( |
| 400 base::ThreadTaskRunnerHandle::Get().get(), origin_, |
| 401 storage::kStorageTypeTemporary, |
| 402 base::Bind(&CacheStorageCache::BatchDidGetUsageAndQuota, |
| 403 weak_ptr_factory_.GetWeakPtr(), operations, callback, |
| 404 space_required)); |
| 405 return; |
| 406 } |
| 407 |
| 408 BatchDidGetUsageAndQuota(operations, callback, 0 /* space_required */, |
| 409 storage::kQuotaStatusOk, 0 /* usage */, |
| 410 0 /* quota */); |
| 411 } |
| 412 |
| 413 void CacheStorageCache::BatchDidGetUsageAndQuota( |
| 414 const std::vector<CacheStorageBatchOperation>& operations, |
| 415 const ErrorCallback& callback, |
| 416 int64_t space_required, |
| 417 storage::QuotaStatusCode status_code, |
| 418 int64_t usage, |
| 419 int64_t quota) { |
| 420 if (status_code != storage::kQuotaStatusOk || |
| 421 space_required > quota - usage) { |
| 422 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 423 FROM_HERE, base::Bind(callback, CACHE_STORAGE_ERROR_QUOTA_EXCEEDED)); |
| 424 return; |
| 425 } |
| 426 |
| 381 std::unique_ptr<ErrorCallback> callback_copy(new ErrorCallback(callback)); | 427 std::unique_ptr<ErrorCallback> callback_copy(new ErrorCallback(callback)); |
| 382 ErrorCallback* callback_ptr = callback_copy.get(); | 428 ErrorCallback* callback_ptr = callback_copy.get(); |
| 383 base::Closure barrier_closure = base::BarrierClosure( | 429 base::Closure barrier_closure = base::BarrierClosure( |
| 384 operations.size(), | 430 operations.size(), |
| 385 base::Bind(&CacheStorageCache::BatchDidAllOperations, this, | 431 base::Bind(&CacheStorageCache::BatchDidAllOperations, this, |
| 386 base::Passed(std::move(callback_copy)))); | 432 base::Passed(std::move(callback_copy)))); |
| 387 ErrorCallback completion_callback = | 433 ErrorCallback completion_callback = |
| 388 base::Bind(&CacheStorageCache::BatchDidOneOperation, this, | 434 base::Bind(&CacheStorageCache::BatchDidOneOperation, this, |
| 389 barrier_closure, callback_ptr); | 435 barrier_closure, callback_ptr); |
| 390 | 436 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 502 } |
| 457 | 503 |
| 458 void CacheStorageCache::Size(const SizeCallback& callback) { | 504 void CacheStorageCache::Size(const SizeCallback& callback) { |
| 459 if (!LazyInitialize()) { | 505 if (!LazyInitialize()) { |
| 460 // TODO(jkarlin): Delete caches that can't be initialized. | 506 // TODO(jkarlin): Delete caches that can't be initialized. |
| 461 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 507 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 462 base::Bind(callback, 0)); | 508 base::Bind(callback, 0)); |
| 463 return; | 509 return; |
| 464 } | 510 } |
| 465 | 511 |
| 466 if (initializing_) { | 512 SizeCallback pending_callback = |
| 467 // Note that Size doesn't use the scheduler, see header comments for why. | 513 base::Bind(&CacheStorageCache::PendingSizeCallback, |
| 468 pending_size_callbacks_.push_back(callback); | 514 weak_ptr_factory_.GetWeakPtr(), callback); |
| 469 return; | |
| 470 } | |
| 471 | 515 |
| 472 // Run immediately so that we don't deadlock on | 516 scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::SizeImpl, |
| 473 // CacheStorageCache::PutDidDelete's call to | 517 weak_ptr_factory_.GetWeakPtr(), |
| 474 // quota_manager_proxy_->GetUsageAndQuota. | 518 pending_callback)); |
| 475 SizeImpl(callback); | |
| 476 } | 519 } |
| 477 | 520 |
| 478 void CacheStorageCache::GetSizeThenClose(const SizeCallback& callback) { | 521 void CacheStorageCache::GetSizeThenClose(const SizeCallback& callback) { |
| 479 if (!LazyInitialize()) { | 522 if (!LazyInitialize()) { |
| 480 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 523 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 481 base::Bind(callback, 0)); | 524 base::Bind(callback, 0)); |
| 482 return; | 525 return; |
| 483 } | 526 } |
| 484 | 527 |
| 485 SizeCallback pending_callback = | 528 SizeCallback pending_callback = |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 } | 812 } |
| 770 | 813 |
| 771 std::unique_ptr<storage::BlobDataHandle> blob_data_handle = | 814 std::unique_ptr<storage::BlobDataHandle> blob_data_handle = |
| 772 PopulateResponseBody(std::move(entry), &response); | 815 PopulateResponseBody(std::move(entry), &response); |
| 773 | 816 |
| 774 context->out_responses->push_back(response); | 817 context->out_responses->push_back(response); |
| 775 context->out_blob_data_handles->push_back(*blob_data_handle); | 818 context->out_blob_data_handles->push_back(*blob_data_handle); |
| 776 MatchAllProcessNextEntry(std::move(context), iter + 1); | 819 MatchAllProcessNextEntry(std::move(context), iter + 1); |
| 777 } | 820 } |
| 778 | 821 |
| 822 void CacheStorageCache::WriteSideDataDidGetQuota( |
| 823 const ErrorCallback& callback, |
| 824 const GURL& url, |
| 825 base::Time expected_response_time, |
| 826 scoped_refptr<net::IOBuffer> buffer, |
| 827 int buf_len, |
| 828 storage::QuotaStatusCode status_code, |
| 829 int64_t usage, |
| 830 int64_t quota) { |
| 831 if (status_code != storage::kQuotaStatusOk || (buf_len > quota - usage)) { |
| 832 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 833 FROM_HERE, base::Bind(callback, CACHE_STORAGE_ERROR_QUOTA_EXCEEDED)); |
| 834 return; |
| 835 } |
| 836 |
| 837 ErrorCallback pending_callback = |
| 838 base::Bind(&CacheStorageCache::PendingErrorCallback, |
| 839 weak_ptr_factory_.GetWeakPtr(), callback); |
| 840 |
| 841 scheduler_->ScheduleOperation(base::Bind( |
| 842 &CacheStorageCache::WriteSideDataImpl, weak_ptr_factory_.GetWeakPtr(), |
| 843 pending_callback, url, expected_response_time, buffer, buf_len)); |
| 844 } |
| 845 |
| 779 void CacheStorageCache::WriteSideDataImpl(const ErrorCallback& callback, | 846 void CacheStorageCache::WriteSideDataImpl(const ErrorCallback& callback, |
| 780 const GURL& url, | 847 const GURL& url, |
| 781 base::Time expected_response_time, | 848 base::Time expected_response_time, |
| 782 scoped_refptr<net::IOBuffer> buffer, | 849 scoped_refptr<net::IOBuffer> buffer, |
| 783 int buf_len) { | 850 int buf_len) { |
| 784 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); | 851 DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); |
| 785 if (backend_state_ != BACKEND_OPEN) { | 852 if (backend_state_ != BACKEND_OPEN) { |
| 786 callback.Run(CACHE_STORAGE_ERROR_STORAGE); | 853 callback.Run(CACHE_STORAGE_ERROR_STORAGE); |
| 787 return; | 854 return; |
| 788 } | 855 } |
| 789 | 856 |
| 790 quota_manager_proxy_->GetUsageAndQuota( | |
| 791 base::ThreadTaskRunnerHandle::Get().get(), origin_, | |
| 792 storage::kStorageTypeTemporary, | |
| 793 base::Bind(&CacheStorageCache::WriteSideDataDidGetUsageAndQuota, | |
| 794 weak_ptr_factory_.GetWeakPtr(), callback, url, | |
| 795 expected_response_time, buffer, buf_len)); | |
| 796 } | |
| 797 | |
| 798 void CacheStorageCache::WriteSideDataDidGetUsageAndQuota( | |
| 799 const ErrorCallback& callback, | |
| 800 const GURL& url, | |
| 801 base::Time expected_response_time, | |
| 802 scoped_refptr<net::IOBuffer> buffer, | |
| 803 int buf_len, | |
| 804 storage::QuotaStatusCode status_code, | |
| 805 int64_t usage, | |
| 806 int64_t quota) { | |
| 807 if (status_code != storage::kQuotaStatusOk || quota - usage < buf_len) { | |
| 808 callback.Run(CACHE_STORAGE_ERROR_QUOTA_EXCEEDED); | |
| 809 return; | |
| 810 } | |
| 811 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( | 857 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( |
| 812 new disk_cache::Entry*()); | 858 new disk_cache::Entry*()); |
| 813 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); | 859 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); |
| 814 net::CompletionCallback open_entry_callback = base::Bind( | 860 net::CompletionCallback open_entry_callback = base::Bind( |
| 815 &CacheStorageCache::WriteSideDataDidOpenEntry, | 861 &CacheStorageCache::WriteSideDataDidOpenEntry, |
| 816 weak_ptr_factory_.GetWeakPtr(), callback, expected_response_time, buffer, | 862 weak_ptr_factory_.GetWeakPtr(), callback, expected_response_time, buffer, |
| 817 buf_len, base::Passed(std::move(scoped_entry_ptr))); | 863 buf_len, base::Passed(std::move(scoped_entry_ptr))); |
| 818 | 864 |
| 819 int rv = backend_->OpenEntry(url.spec(), entry_ptr, open_entry_callback); | 865 int rv = backend_->OpenEntry(url.spec(), entry_ptr, open_entry_callback); |
| 820 if (rv != net::ERR_IO_PENDING) | 866 if (rv != net::ERR_IO_PENDING) |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 base::Passed(std::move(put_context)))); | 1000 base::Passed(std::move(put_context)))); |
| 955 } | 1001 } |
| 956 | 1002 |
| 957 void CacheStorageCache::PutDidDelete(std::unique_ptr<PutContext> put_context, | 1003 void CacheStorageCache::PutDidDelete(std::unique_ptr<PutContext> put_context, |
| 958 CacheStorageError delete_error) { | 1004 CacheStorageError delete_error) { |
| 959 if (backend_state_ != BACKEND_OPEN) { | 1005 if (backend_state_ != BACKEND_OPEN) { |
| 960 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); | 1006 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); |
| 961 return; | 1007 return; |
| 962 } | 1008 } |
| 963 | 1009 |
| 964 quota_manager_proxy_->GetUsageAndQuota( | |
| 965 base::ThreadTaskRunnerHandle::Get().get(), origin_, | |
| 966 storage::kStorageTypeTemporary, | |
| 967 base::Bind(&CacheStorageCache::PutDidGetUsageAndQuota, | |
| 968 weak_ptr_factory_.GetWeakPtr(), | |
| 969 base::Passed(std::move(put_context)))); | |
| 970 } | |
| 971 | |
| 972 void CacheStorageCache::PutDidGetUsageAndQuota( | |
| 973 std::unique_ptr<PutContext> put_context, | |
| 974 storage::QuotaStatusCode status_code, | |
| 975 int64_t usage, | |
| 976 int64_t quota) { | |
| 977 if (backend_state_ != BACKEND_OPEN) { | |
| 978 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); | |
| 979 return; | |
| 980 } | |
| 981 | |
| 982 if (status_code != storage::kQuotaStatusOk) { | |
| 983 put_context->callback.Run(CACHE_STORAGE_ERROR_QUOTA_EXCEEDED); | |
| 984 return; | |
| 985 } | |
| 986 | |
| 987 put_context->available_bytes = quota - usage; | |
| 988 | |
| 989 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( | 1010 std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( |
| 990 new disk_cache::Entry*()); | 1011 new disk_cache::Entry*()); |
| 991 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); | 1012 disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); |
| 992 ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); | 1013 ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); |
| 993 disk_cache::Backend* backend_ptr = backend_.get(); | 1014 disk_cache::Backend* backend_ptr = backend_.get(); |
| 994 | 1015 |
| 995 net::CompletionCallback create_entry_callback = base::Bind( | 1016 net::CompletionCallback create_entry_callback = base::Bind( |
| 996 &CacheStorageCache::PutDidCreateEntry, weak_ptr_factory_.GetWeakPtr(), | 1017 &CacheStorageCache::PutDidCreateEntry, weak_ptr_factory_.GetWeakPtr(), |
| 997 base::Passed(std::move(scoped_entry_ptr)), | 1018 base::Passed(std::move(scoped_entry_ptr)), |
| 998 base::Passed(std::move(put_context))); | 1019 base::Passed(std::move(put_context))); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 | 1069 |
| 1049 std::unique_ptr<std::string> serialized(new std::string()); | 1070 std::unique_ptr<std::string> serialized(new std::string()); |
| 1050 if (!metadata.SerializeToString(serialized.get())) { | 1071 if (!metadata.SerializeToString(serialized.get())) { |
| 1051 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); | 1072 put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); |
| 1052 return; | 1073 return; |
| 1053 } | 1074 } |
| 1054 | 1075 |
| 1055 scoped_refptr<net::StringIOBuffer> buffer( | 1076 scoped_refptr<net::StringIOBuffer> buffer( |
| 1056 new net::StringIOBuffer(std::move(serialized))); | 1077 new net::StringIOBuffer(std::move(serialized))); |
| 1057 | 1078 |
| 1058 int64_t bytes_to_write = buffer->size() + put_context->response->blob_size; | |
| 1059 if (put_context->available_bytes < bytes_to_write) { | |
| 1060 put_context->callback.Run(CACHE_STORAGE_ERROR_QUOTA_EXCEEDED); | |
| 1061 return; | |
| 1062 } | |
| 1063 | |
| 1064 // Get a temporary copy of the entry pointer before passing it in base::Bind. | 1079 // Get a temporary copy of the entry pointer before passing it in base::Bind. |
| 1065 disk_cache::Entry* temp_entry_ptr = put_context->cache_entry.get(); | 1080 disk_cache::Entry* temp_entry_ptr = put_context->cache_entry.get(); |
| 1066 | 1081 |
| 1067 net::CompletionCallback write_headers_callback = base::Bind( | 1082 net::CompletionCallback write_headers_callback = base::Bind( |
| 1068 &CacheStorageCache::PutDidWriteHeaders, weak_ptr_factory_.GetWeakPtr(), | 1083 &CacheStorageCache::PutDidWriteHeaders, weak_ptr_factory_.GetWeakPtr(), |
| 1069 base::Passed(std::move(put_context)), buffer->size()); | 1084 base::Passed(std::move(put_context)), buffer->size()); |
| 1070 | 1085 |
| 1071 rv = temp_entry_ptr->WriteData(INDEX_HEADERS, 0 /* offset */, buffer.get(), | 1086 rv = temp_entry_ptr->WriteData(INDEX_HEADERS, 0 /* offset */, buffer.get(), |
| 1072 buffer->size(), write_headers_callback, | 1087 buffer->size(), write_headers_callback, |
| 1073 true /* truncate */); | 1088 true /* truncate */); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 | 1444 |
| 1430 void CacheStorageCache::InitGotCacheSize(CacheStorageError cache_create_error, | 1445 void CacheStorageCache::InitGotCacheSize(CacheStorageError cache_create_error, |
| 1431 int cache_size) { | 1446 int cache_size) { |
| 1432 cache_size_ = cache_size; | 1447 cache_size_ = cache_size; |
| 1433 initializing_ = false; | 1448 initializing_ = false; |
| 1434 backend_state_ = (cache_create_error == CACHE_STORAGE_OK && backend_ && | 1449 backend_state_ = (cache_create_error == CACHE_STORAGE_OK && backend_ && |
| 1435 backend_state_ == BACKEND_UNINITIALIZED) | 1450 backend_state_ == BACKEND_UNINITIALIZED) |
| 1436 ? BACKEND_OPEN | 1451 ? BACKEND_OPEN |
| 1437 : BACKEND_CLOSED; | 1452 : BACKEND_CLOSED; |
| 1438 | 1453 |
| 1439 for (const SizeCallback& callback : pending_size_callbacks_) | |
| 1440 SizeImpl(callback); | |
| 1441 pending_size_callbacks_.clear(); | |
| 1442 | |
| 1443 UMA_HISTOGRAM_ENUMERATION("ServiceWorkerCache.InitBackendResult", | 1454 UMA_HISTOGRAM_ENUMERATION("ServiceWorkerCache.InitBackendResult", |
| 1444 cache_create_error, CACHE_STORAGE_ERROR_LAST + 1); | 1455 cache_create_error, CACHE_STORAGE_ERROR_LAST + 1); |
| 1445 | 1456 |
| 1446 scheduler_->CompleteOperationAndRunNext(); | 1457 scheduler_->CompleteOperationAndRunNext(); |
| 1447 } | 1458 } |
| 1448 | 1459 |
| 1449 void CacheStorageCache::PendingClosure(const base::Closure& callback) { | 1460 void CacheStorageCache::PendingClosure(const base::Closure& callback) { |
| 1450 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); | 1461 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); |
| 1451 | 1462 |
| 1452 callback.Run(); | 1463 callback.Run(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 storage::BlobDataBuilder blob_data(response->blob_uuid); | 1549 storage::BlobDataBuilder blob_data(response->blob_uuid); |
| 1539 | 1550 |
| 1540 disk_cache::Entry* temp_entry = entry.get(); | 1551 disk_cache::Entry* temp_entry = entry.get(); |
| 1541 blob_data.AppendDiskCacheEntryWithSideData( | 1552 blob_data.AppendDiskCacheEntryWithSideData( |
| 1542 new CacheStorageCacheDataHandle(this, std::move(entry)), temp_entry, | 1553 new CacheStorageCacheDataHandle(this, std::move(entry)), temp_entry, |
| 1543 INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); | 1554 INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); |
| 1544 return blob_storage_context_->AddFinishedBlob(&blob_data); | 1555 return blob_storage_context_->AddFinishedBlob(&blob_data); |
| 1545 } | 1556 } |
| 1546 | 1557 |
| 1547 } // namespace content | 1558 } // namespace content |
| OLD | NEW |