| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_dispatcher_host.h" | 5 #include "content/browser/cache_storage/cache_storage_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 std::unique_ptr<ServiceWorkerResponse> response, | 452 std::unique_ptr<ServiceWorkerResponse> response, |
| 453 std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { | 453 std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { |
| 454 std::unique_ptr<CacheStorageCache::Responses> responses( | 454 std::unique_ptr<CacheStorageCache::Responses> responses( |
| 455 new CacheStorageCache::Responses); | 455 new CacheStorageCache::Responses); |
| 456 std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles( | 456 std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles( |
| 457 new CacheStorageCache::BlobDataHandles); | 457 new CacheStorageCache::BlobDataHandles); |
| 458 if (error == CACHE_STORAGE_OK) { | 458 if (error == CACHE_STORAGE_OK) { |
| 459 DCHECK(response); | 459 DCHECK(response); |
| 460 responses->push_back(*response); | 460 responses->push_back(*response); |
| 461 if (blob_data_handle) | 461 if (blob_data_handle) |
| 462 blob_data_handles->push_back(*blob_data_handle); | 462 blob_data_handles->push_back(std::move(blob_data_handle)); |
| 463 } | 463 } |
| 464 OnCacheMatchAllCallback(thread_id, request_id, std::move(cache_handle), error, | 464 OnCacheMatchAllCallback(thread_id, request_id, std::move(cache_handle), error, |
| 465 std::move(responses), std::move(blob_data_handles)); | 465 std::move(responses), std::move(blob_data_handles)); |
| 466 } | 466 } |
| 467 | 467 |
| 468 void CacheStorageDispatcherHost::OnCacheMatchAllCallback( | 468 void CacheStorageDispatcherHost::OnCacheMatchAllCallback( |
| 469 int thread_id, | 469 int thread_id, |
| 470 int request_id, | 470 int request_id, |
| 471 std::unique_ptr<CacheStorageCacheHandle> cache_handle, | 471 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 472 CacheStorageError error, | 472 CacheStorageError error, |
| 473 std::unique_ptr<CacheStorageCache::Responses> responses, | 473 std::unique_ptr<CacheStorageCache::Responses> responses, |
| 474 std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles) { | 474 std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles) { |
| 475 if (error != CACHE_STORAGE_OK && error != CACHE_STORAGE_ERROR_NOT_FOUND) { | 475 if (error != CACHE_STORAGE_OK && error != CACHE_STORAGE_ERROR_NOT_FOUND) { |
| 476 Send(new CacheStorageMsg_CacheMatchAllError( | 476 Send(new CacheStorageMsg_CacheMatchAllError( |
| 477 thread_id, request_id, ToWebServiceWorkerCacheError(error))); | 477 thread_id, request_id, ToWebServiceWorkerCacheError(error))); |
| 478 return; | 478 return; |
| 479 } | 479 } |
| 480 | 480 |
| 481 for (const storage::BlobDataHandle& handle : *blob_data_handles) | 481 for (const auto& handle : *blob_data_handles) { |
| 482 StoreBlobDataHandle(handle); | 482 if (handle) |
| 483 StoreBlobDataHandle(*handle); |
| 484 } |
| 483 | 485 |
| 484 Send(new CacheStorageMsg_CacheMatchAllSuccess(thread_id, request_id, | 486 Send(new CacheStorageMsg_CacheMatchAllSuccess(thread_id, request_id, |
| 485 *responses)); | 487 *responses)); |
| 486 } | 488 } |
| 487 | 489 |
| 488 void CacheStorageDispatcherHost::OnCacheKeysCallback( | 490 void CacheStorageDispatcherHost::OnCacheKeysCallback( |
| 489 int thread_id, | 491 int thread_id, |
| 490 int request_id, | 492 int request_id, |
| 491 std::unique_ptr<CacheStorageCacheHandle> cache_handle, | 493 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 492 CacheStorageError error, | 494 CacheStorageError error, |
| 493 std::unique_ptr<CacheStorageCache::Requests> requests) { | 495 std::unique_ptr<CacheStorageCache::Requests> requests) { |
| 494 if (error != CACHE_STORAGE_OK) { | 496 if (error != CACHE_STORAGE_OK) { |
| 495 Send(new CacheStorageMsg_CacheKeysError( | 497 Send(new CacheStorageMsg_CacheKeysError( |
| 496 thread_id, request_id, ToWebServiceWorkerCacheError(error))); | 498 thread_id, request_id, ToWebServiceWorkerCacheError(error))); |
| 497 return; | 499 return; |
| 498 } | 500 } |
| 499 | 501 |
| 500 CacheStorageCache::Requests out; | 502 Send(new CacheStorageMsg_CacheKeysSuccess(thread_id, request_id, *requests)); |
| 501 | |
| 502 for (CacheStorageCache::Requests::const_iterator it = requests->begin(); | |
| 503 it != requests->end(); ++it) { | |
| 504 ServiceWorkerFetchRequest request(it->url, it->method, it->headers, | |
| 505 it->referrer, it->is_reload); | |
| 506 out.push_back(request); | |
| 507 } | |
| 508 | |
| 509 Send(new CacheStorageMsg_CacheKeysSuccess(thread_id, request_id, out)); | |
| 510 } | 503 } |
| 511 | 504 |
| 512 void CacheStorageDispatcherHost::OnCacheBatchCallback( | 505 void CacheStorageDispatcherHost::OnCacheBatchCallback( |
| 513 int thread_id, | 506 int thread_id, |
| 514 int request_id, | 507 int request_id, |
| 515 std::unique_ptr<CacheStorageCacheHandle> cache_handle, | 508 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 516 CacheStorageError error) { | 509 CacheStorageError error) { |
| 517 if (error != CACHE_STORAGE_OK) { | 510 if (error != CACHE_STORAGE_OK) { |
| 518 Send(new CacheStorageMsg_CacheBatchError( | 511 Send(new CacheStorageMsg_CacheBatchError( |
| 519 thread_id, request_id, ToWebServiceWorkerCacheError(error))); | 512 thread_id, request_id, ToWebServiceWorkerCacheError(error))); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 547 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); | 540 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); |
| 548 if (it == blob_handle_store_.end()) | 541 if (it == blob_handle_store_.end()) |
| 549 return; | 542 return; |
| 550 DCHECK(!it->second.empty()); | 543 DCHECK(!it->second.empty()); |
| 551 it->second.pop_front(); | 544 it->second.pop_front(); |
| 552 if (it->second.empty()) | 545 if (it->second.empty()) |
| 553 blob_handle_store_.erase(it); | 546 blob_handle_store_.erase(it); |
| 554 } | 547 } |
| 555 | 548 |
| 556 } // namespace content | 549 } // namespace content |
| OLD | NEW |