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_file.h" | 5 #include "net/disk_cache/simple/simple_index_file.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 | 159 |
160 // static | 160 // static |
161 void SimpleIndexFile::SyncLoadIndexEntries( | 161 void SimpleIndexFile::SyncLoadIndexEntries( |
162 const base::FilePath& index_file_path, | 162 const base::FilePath& index_file_path, |
163 scoped_refptr<base::SingleThreadTaskRunner> response_thread, | 163 scoped_refptr<base::SingleThreadTaskRunner> response_thread, |
164 const IndexCompletionCallback& completion_callback) { | 164 const IndexCompletionCallback& completion_callback) { |
165 // TODO(felipeg): probably could load a stale index and use it for something. | 165 // TODO(felipeg): probably could load a stale index and use it for something. |
166 scoped_ptr<SimpleIndex::EntrySet> index_file_entries; | 166 scoped_ptr<SimpleIndex::EntrySet> index_file_entries; |
167 | 167 |
168 const bool index_file_exists = file_util::PathExists(index_file_path); | 168 const bool index_file_exists = base::PathExists(index_file_path); |
169 | 169 |
170 // Only load if the index is not stale. | 170 // Only load if the index is not stale. |
171 const bool index_stale = IsIndexFileStale(index_file_path); | 171 const bool index_stale = IsIndexFileStale(index_file_path); |
172 if (!index_stale) { | 172 if (!index_stale) { |
173 const base::TimeTicks start = base::TimeTicks::Now(); | 173 const base::TimeTicks start = base::TimeTicks::Now(); |
174 index_file_entries = SyncLoadFromDisk(index_file_path); | 174 index_file_entries = SyncLoadFromDisk(index_file_path); |
175 UMA_HISTOGRAM_TIMES("SimpleCache.IndexLoadTime", | 175 UMA_HISTOGRAM_TIMES("SimpleCache.IndexLoadTime", |
176 base::TimeTicks::Now() - start); | 176 base::TimeTicks::Now() - start); |
177 UMA_HISTOGRAM_COUNTS("SimpleCache.IndexEntriesLoaded", | 177 UMA_HISTOGRAM_COUNTS("SimpleCache.IndexEntriesLoaded", |
178 index_file_entries ? index_file_entries->size() : 0); | 178 index_file_entries ? index_file_entries->size() : 0); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 if (!simple_util::GetMTime(index_filename, &index_mtime)) | 380 if (!simple_util::GetMTime(index_filename, &index_mtime)) |
381 return true; | 381 return true; |
382 // Index file last_modified must be equal to the directory last_modified since | 382 // Index file last_modified must be equal to the directory last_modified since |
383 // the last operation we do is ReplaceFile in the | 383 // the last operation we do is ReplaceFile in the |
384 // SimpleIndexFile::WriteToDisk(). | 384 // SimpleIndexFile::WriteToDisk(). |
385 // If not true, we need to restore the index. | 385 // If not true, we need to restore the index. |
386 return index_mtime < dir_mtime; | 386 return index_mtime < dir_mtime; |
387 } | 387 } |
388 | 388 |
389 } // namespace disk_cache | 389 } // namespace disk_cache |
OLD | NEW |