Chromium Code Reviews| 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 return cache_size_; | |
|
pasko
2015/10/09 15:52:03
DCHECK(initialized_) please
msramek
2015/10/13 09:45:06
Done.
| |
| 244 } | |
| 245 | |
| 242 void SimpleIndex::Insert(uint64 entry_hash) { | 246 void SimpleIndex::Insert(uint64 entry_hash) { |
| 243 DCHECK(io_thread_checker_.CalledOnValidThread()); | 247 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 244 // Upon insert we don't know yet the size of the entry. | 248 // Upon insert we don't know yet the size of the entry. |
| 245 // It will be updated later when the SimpleEntryImpl finishes opening or | 249 // It will be updated later when the SimpleEntryImpl finishes opening or |
| 246 // creating the new entry, and then UpdateEntrySize will be called. | 250 // creating the new entry, and then UpdateEntrySize will be called. |
| 247 InsertInEntrySet( | 251 InsertInEntrySet( |
| 248 entry_hash, EntryMetadata(base::Time::Now(), 0), &entries_set_); | 252 entry_hash, EntryMetadata(base::Time::Now(), 0), &entries_set_); |
| 249 if (!initialized_) | 253 if (!initialized_) |
| 250 removed_entries_.erase(entry_hash); | 254 removed_entries_.erase(entry_hash); |
| 251 PostponeWritingToDisk(); | 255 PostponeWritingToDisk(); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 start - last_write_to_disk_); | 475 start - last_write_to_disk_); |
| 472 } | 476 } |
| 473 } | 477 } |
| 474 last_write_to_disk_ = start; | 478 last_write_to_disk_ = start; |
| 475 | 479 |
| 476 index_file_->WriteToDisk(entries_set_, cache_size_, | 480 index_file_->WriteToDisk(entries_set_, cache_size_, |
| 477 start, app_on_background_, base::Closure()); | 481 start, app_on_background_, base::Closure()); |
| 478 } | 482 } |
| 479 | 483 |
| 480 } // namespace disk_cache | 484 } // namespace disk_cache |
| OLD | NEW |