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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 namespace disk_cache { | 41 namespace disk_cache { |
42 | 42 |
43 SimpleIndex::SimpleIndex( | 43 SimpleIndex::SimpleIndex( |
44 const scoped_refptr<base::TaskRunner>& cache_thread, | 44 const scoped_refptr<base::TaskRunner>& cache_thread, |
45 const base::FilePath& path) | 45 const base::FilePath& path) |
46 : path_(path), | 46 : path_(path), |
47 cache_thread_(cache_thread) { | 47 cache_thread_(cache_thread) { |
48 index_filename_ = path_.AppendASCII("simple-index"); | 48 index_filename_ = path_.AppendASCII("index"); |
49 } | 49 } |
50 | 50 |
51 bool SimpleIndex::Initialize() { | 51 bool SimpleIndex::Initialize() { |
52 if (!OpenIndexFile()) | 52 if (!OpenIndexFile()) |
53 return RestoreFromDisk(); | 53 return RestoreFromDisk(); |
54 uLong incremental_crc = crc32(0L, Z_NULL, 0); | 54 uLong incremental_crc = crc32(0L, Z_NULL, 0); |
55 int64 index_file_offset = 0; | 55 int64 index_file_offset = 0; |
56 SimpleIndexFile::Header metadata; | 56 SimpleIndexFile::Header metadata; |
57 if (base::ReadPlatformFile(index_file_, | 57 if (base::ReadPlatformFile(index_file_, |
58 index_file_offset, | 58 index_file_offset, |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 file_util::Delete(temp_filename, /* recursive = */ false); | 222 file_util::Delete(temp_filename, /* recursive = */ false); |
223 return; | 223 return; |
224 } | 224 } |
225 | 225 |
226 // Swap temp and index_file. | 226 // Swap temp and index_file. |
227 bool result = file_util::ReplaceFile(temp_filename, index_filename); | 227 bool result = file_util::ReplaceFile(temp_filename, index_filename); |
228 DCHECK(result); | 228 DCHECK(result); |
229 } | 229 } |
230 | 230 |
231 } // namespace disk_cache | 231 } // namespace disk_cache |
OLD | NEW |