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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 namespace disk_cache { | 42 namespace disk_cache { |
43 | 43 |
44 SimpleIndex::SimpleIndex( | 44 SimpleIndex::SimpleIndex( |
45 const scoped_refptr<base::TaskRunner>& cache_thread, | 45 const scoped_refptr<base::TaskRunner>& cache_thread, |
46 const base::FilePath& path) | 46 const base::FilePath& path) |
47 : path_(path), | 47 : path_(path), |
48 cache_thread_(cache_thread) { | 48 cache_thread_(cache_thread) { |
49 index_filename_ = path_.AppendASCII("simple-index"); | 49 index_filename_ = path_.AppendASCII("index"); |
50 } | 50 } |
51 | 51 |
52 bool SimpleIndex::Initialize() { | 52 bool SimpleIndex::Initialize() { |
53 if (!OpenIndexFile()) | 53 if (!OpenIndexFile()) |
54 return RestoreFromDisk(); | 54 return RestoreFromDisk(); |
55 uLong incremental_crc = crc32(0L, Z_NULL, 0); | 55 uLong incremental_crc = crc32(0L, Z_NULL, 0); |
56 int64 index_file_offset = 0; | 56 int64 index_file_offset = 0; |
57 SimpleIndexFile::Header header; | 57 SimpleIndexFile::Header header; |
58 if (base::ReadPlatformFile(index_file_, | 58 if (base::ReadPlatformFile(index_file_, |
59 index_file_offset, | 59 index_file_offset, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 << temp_filename.value(); | 249 << temp_filename.value(); |
250 file_util::Delete(temp_filename, /* recursive = */ false); | 250 file_util::Delete(temp_filename, /* recursive = */ false); |
251 return; | 251 return; |
252 } | 252 } |
253 // Swap temp and index_file. | 253 // Swap temp and index_file. |
254 bool result = file_util::ReplaceFile(temp_filename, index_filename); | 254 bool result = file_util::ReplaceFile(temp_filename, index_filename); |
255 DCHECK(result); | 255 DCHECK(result); |
256 } | 256 } |
257 | 257 |
258 } // namespace disk_cache | 258 } // namespace disk_cache |
OLD | NEW |