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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 | 400 |
401 const bool index_file_exists = file_util::PathExists(index_filename); | 401 const bool index_file_exists = file_util::PathExists(index_filename); |
402 | 402 |
403 // Only load if the index is not stale. | 403 // Only load if the index is not stale. |
404 const bool index_stale = SimpleIndex::IsIndexFileStale(index_filename); | 404 const bool index_stale = SimpleIndex::IsIndexFileStale(index_filename); |
405 if (!index_stale) { | 405 if (!index_stale) { |
406 const base::TimeTicks start = base::TimeTicks::Now(); | 406 const base::TimeTicks start = base::TimeTicks::Now(); |
407 index_file_entries = SimpleIndexFile::LoadFromDisk(index_filename); | 407 index_file_entries = SimpleIndexFile::LoadFromDisk(index_filename); |
408 UMA_HISTOGRAM_TIMES("SimpleCache.IndexLoadTime", | 408 UMA_HISTOGRAM_TIMES("SimpleCache.IndexLoadTime", |
409 (base::TimeTicks::Now() - start)); | 409 (base::TimeTicks::Now() - start)); |
410 UMA_HISTOGRAM_COUNTS("SimpleCache.IndexEntriesLoaded", | |
411 index_file_entries->size()); | |
410 } | 412 } |
411 | 413 |
412 UMA_HISTOGRAM_BOOLEAN("SimpleCache.IndexStale", index_stale); | 414 UMA_HISTOGRAM_BOOLEAN("SimpleCache.IndexStale", index_stale); |
413 | 415 |
414 bool force_index_flush = false; | 416 bool force_index_flush = false; |
415 if (!index_file_entries) { | 417 if (!index_file_entries) { |
416 const base::TimeTicks start = base::TimeTicks::Now(); | 418 const base::TimeTicks start = base::TimeTicks::Now(); |
417 index_file_entries = SimpleIndex::RestoreFromDisk(index_filename); | 419 index_file_entries = SimpleIndex::RestoreFromDisk(index_filename); |
418 UMA_HISTOGRAM_TIMES("SimpleCache.IndexRestoreTime", | 420 UMA_HISTOGRAM_MEDIUM_TIMES("SimpleCache.IndexRestoreTime", |
419 (base::TimeTicks::Now() - start)); | 421 (base::TimeTicks::Now() - start)); |
jar (doing other things)
2013/06/05 18:17:54
nit: no need for redundant parens. Good macro do
pasko
2013/06/05 18:39:37
Done.
| |
422 UMA_HISTOGRAM_COUNTS("SimpleCache.IndexEntriesRestored", | |
423 index_file_entries->size()); | |
420 | 424 |
421 // When we restore from disk we write the merged index file to disk right | 425 // When we restore from disk we write the merged index file to disk right |
422 // away, this might save us from having to restore again next time. | 426 // away, this might save us from having to restore again next time. |
423 force_index_flush = true; | 427 force_index_flush = true; |
424 } | 428 } |
425 UMA_HISTOGRAM_BOOLEAN("SimpleCache.IndexCorrupt", | 429 UMA_HISTOGRAM_BOOLEAN("SimpleCache.IndexCorrupt", |
426 (!index_stale && force_index_flush)); | 430 (!index_stale && force_index_flush)); |
427 | 431 |
428 // Used in histograms. Please only add new values at the end. | 432 // Used in histograms. Please only add new values at the end. |
429 enum { | 433 enum { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 entries_set_); | 612 entries_set_); |
609 cache_thread_->PostTask(FROM_HERE, base::Bind( | 613 cache_thread_->PostTask(FROM_HERE, base::Bind( |
610 &SimpleIndex::WriteToDiskInternal, | 614 &SimpleIndex::WriteToDiskInternal, |
611 index_filename_, | 615 index_filename_, |
612 base::Passed(&pickle), | 616 base::Passed(&pickle), |
613 start, | 617 start, |
614 app_on_background_)); | 618 app_on_background_)); |
615 } | 619 } |
616 | 620 |
617 } // namespace disk_cache | 621 } // namespace disk_cache |
OLD | NEW |