| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/disk_cache/simple/simple_index.h" | 5 #include "net/disk_cache/simple/simple_index.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 232 |
| 233 scoped_ptr<SimpleIndex::HashList> SimpleIndex::GetAllHashes() { | 233 scoped_ptr<SimpleIndex::HashList> SimpleIndex::GetAllHashes() { |
| 234 return GetEntriesBetween(base::Time(), base::Time()); | 234 return GetEntriesBetween(base::Time(), base::Time()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 int32 SimpleIndex::GetEntryCount() const { | 237 int32 SimpleIndex::GetEntryCount() const { |
| 238 // TODO(pasko): return a meaningful initial estimate before initialized. | 238 // TODO(pasko): return a meaningful initial estimate before initialized. |
| 239 return entries_set_.size(); | 239 return entries_set_.size(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 uint64 SimpleIndex::GetCacheSize() const { |
| 243 DCHECK(initialized_); |
| 244 return cache_size_; |
| 245 } |
| 246 |
| 242 void SimpleIndex::Insert(uint64 entry_hash) { | 247 void SimpleIndex::Insert(uint64 entry_hash) { |
| 243 DCHECK(io_thread_checker_.CalledOnValidThread()); | 248 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 244 // Upon insert we don't know yet the size of the entry. | 249 // Upon insert we don't know yet the size of the entry. |
| 245 // It will be updated later when the SimpleEntryImpl finishes opening or | 250 // It will be updated later when the SimpleEntryImpl finishes opening or |
| 246 // creating the new entry, and then UpdateEntrySize will be called. | 251 // creating the new entry, and then UpdateEntrySize will be called. |
| 247 InsertInEntrySet( | 252 InsertInEntrySet( |
| 248 entry_hash, EntryMetadata(base::Time::Now(), 0), &entries_set_); | 253 entry_hash, EntryMetadata(base::Time::Now(), 0), &entries_set_); |
| 249 if (!initialized_) | 254 if (!initialized_) |
| 250 removed_entries_.erase(entry_hash); | 255 removed_entries_.erase(entry_hash); |
| 251 PostponeWritingToDisk(); | 256 PostponeWritingToDisk(); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 start - last_write_to_disk_); | 476 start - last_write_to_disk_); |
| 472 } | 477 } |
| 473 } | 478 } |
| 474 last_write_to_disk_ = start; | 479 last_write_to_disk_ = start; |
| 475 | 480 |
| 476 index_file_->WriteToDisk(entries_set_, cache_size_, | 481 index_file_->WriteToDisk(entries_set_, cache_size_, |
| 477 start, app_on_background_, base::Closure()); | 482 start, app_on_background_, base::Closure()); |
| 478 } | 483 } |
| 479 | 484 |
| 480 } // namespace disk_cache | 485 } // namespace disk_cache |
| OLD | NEW |