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