| 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> |
| 8 |
| 7 #include <string> | 9 #include <string> |
| 8 | 10 |
| 9 #include "base/barrier_closure.h" | 11 #include "base/barrier_closure.h" |
| 10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 11 #include "base/guid.h" | 13 #include "base/guid.h" |
| 14 #include "base/macros.h" |
| 12 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 14 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 15 #include "content/browser/cache_storage/cache_storage.pb.h" | 18 #include "content/browser/cache_storage/cache_storage.pb.h" |
| 16 #include "content/browser/cache_storage/cache_storage_blob_to_disk_cache.h" | 19 #include "content/browser/cache_storage/cache_storage_blob_to_disk_cache.h" |
| 17 #include "content/browser/cache_storage/cache_storage_scheduler.h" | 20 #include "content/browser/cache_storage/cache_storage_scheduler.h" |
| 18 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/common/referrer.h" | 22 #include "content/public/common/referrer.h" |
| 20 #include "net/base/completion_callback.h" | 23 #include "net/base/completion_callback.h" |
| 21 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 | 419 |
| 417 base::Closure pending_callback = | 420 base::Closure pending_callback = |
| 418 base::Bind(&CacheStorageCache::PendingClosure, | 421 base::Bind(&CacheStorageCache::PendingClosure, |
| 419 weak_ptr_factory_.GetWeakPtr(), callback); | 422 weak_ptr_factory_.GetWeakPtr(), callback); |
| 420 | 423 |
| 421 scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::CloseImpl, | 424 scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::CloseImpl, |
| 422 weak_ptr_factory_.GetWeakPtr(), | 425 weak_ptr_factory_.GetWeakPtr(), |
| 423 pending_callback)); | 426 pending_callback)); |
| 424 } | 427 } |
| 425 | 428 |
| 426 int64 CacheStorageCache::MemoryBackedSize() const { | 429 int64_t CacheStorageCache::MemoryBackedSize() const { |
| 427 if (backend_state_ != BACKEND_OPEN || !memory_only_) | 430 if (backend_state_ != BACKEND_OPEN || !memory_only_) |
| 428 return 0; | 431 return 0; |
| 429 | 432 |
| 430 scoped_ptr<disk_cache::Backend::Iterator> backend_iter = | 433 scoped_ptr<disk_cache::Backend::Iterator> backend_iter = |
| 431 backend_->CreateIterator(); | 434 backend_->CreateIterator(); |
| 432 disk_cache::Entry* entry = nullptr; | 435 disk_cache::Entry* entry = nullptr; |
| 433 | 436 |
| 434 int64 sum = 0; | 437 int64_t sum = 0; |
| 435 | 438 |
| 436 std::vector<disk_cache::Entry*> entries; | 439 std::vector<disk_cache::Entry*> entries; |
| 437 int rv = net::OK; | 440 int rv = net::OK; |
| 438 while ((rv = backend_iter->OpenNextEntry( | 441 while ((rv = backend_iter->OpenNextEntry( |
| 439 &entry, base::Bind(NotReachedCompletionCallback))) == net::OK) { | 442 &entry, base::Bind(NotReachedCompletionCallback))) == net::OK) { |
| 440 entries.push_back(entry); // Open the entries without mutating them. | 443 entries.push_back(entry); // Open the entries without mutating them. |
| 441 } | 444 } |
| 442 DCHECK_NE(net::ERR_IO_PENDING, rv) | 445 DCHECK_NE(net::ERR_IO_PENDING, rv) |
| 443 << "Memory cache operations should be synchronous."; | 446 << "Memory cache operations should be synchronous."; |
| 444 | 447 |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 storage::BlobDataBuilder blob_data(response->blob_uuid); | 1249 storage::BlobDataBuilder blob_data(response->blob_uuid); |
| 1247 | 1250 |
| 1248 disk_cache::Entry* temp_entry = entry.get(); | 1251 disk_cache::Entry* temp_entry = entry.get(); |
| 1249 blob_data.AppendDiskCacheEntry( | 1252 blob_data.AppendDiskCacheEntry( |
| 1250 new CacheStorageCacheDataHandle(this, entry.Pass()), temp_entry, | 1253 new CacheStorageCacheDataHandle(this, entry.Pass()), temp_entry, |
| 1251 INDEX_RESPONSE_BODY); | 1254 INDEX_RESPONSE_BODY); |
| 1252 return blob_storage_context_->AddFinishedBlob(&blob_data); | 1255 return blob_storage_context_->AddFinishedBlob(&blob_data); |
| 1253 } | 1256 } |
| 1254 | 1257 |
| 1255 } // namespace content | 1258 } // namespace content |
| OLD | NEW |