OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/block_files.h" | 5 #include "net/disk_cache/block_files.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "net/disk_cache/cache_util.h" | 13 #include "net/disk_cache/cache_util.h" |
14 #include "net/disk_cache/file_lock.h" | 14 #include "net/disk_cache/file_lock.h" |
15 #include "net/disk_cache/trace.h" | 15 #include "net/disk_cache/trace.h" |
16 | 16 |
17 using base::TimeTicks; | 17 using base::TimeTicks; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const char* kBlockName = "data_"; | 21 const char* kBlockName = "data_"; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 if (zero_buffer_) | 194 if (zero_buffer_) |
195 delete[] zero_buffer_; | 195 delete[] zero_buffer_; |
196 CloseFiles(); | 196 CloseFiles(); |
197 } | 197 } |
198 | 198 |
199 bool BlockFiles::Init(bool create_files) { | 199 bool BlockFiles::Init(bool create_files) { |
200 DCHECK(!init_); | 200 DCHECK(!init_); |
201 if (init_) | 201 if (init_) |
202 return false; | 202 return false; |
203 | 203 |
204 thread_checker_.reset(new ThreadChecker); | 204 thread_checker_.reset(new base::ThreadChecker); |
205 | 205 |
206 block_files_.resize(kFirstAdditionalBlockFile); | 206 block_files_.resize(kFirstAdditionalBlockFile); |
207 for (int i = 0; i < kFirstAdditionalBlockFile; i++) { | 207 for (int i = 0; i < kFirstAdditionalBlockFile; i++) { |
208 if (create_files) | 208 if (create_files) |
209 if (!CreateBlockFile(i, static_cast<FileType>(i + 1), true)) | 209 if (!CreateBlockFile(i, static_cast<FileType>(i + 1), true)) |
210 return false; | 210 return false; |
211 | 211 |
212 if (!OpenBlockFile(i)) | 212 if (!OpenBlockFile(i)) |
213 return false; | 213 return false; |
214 | 214 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } | 612 } |
613 | 613 |
614 FilePath BlockFiles::Name(int index) { | 614 FilePath BlockFiles::Name(int index) { |
615 // The file format allows for 256 files. | 615 // The file format allows for 256 files. |
616 DCHECK(index < 256 || index >= 0); | 616 DCHECK(index < 256 || index >= 0); |
617 std::string tmp = base::StringPrintf("%s%d", kBlockName, index); | 617 std::string tmp = base::StringPrintf("%s%d", kBlockName, index); |
618 return path_.AppendASCII(tmp); | 618 return path_.AppendASCII(tmp); |
619 } | 619 } |
620 | 620 |
621 } // namespace disk_cache | 621 } // namespace disk_cache |
OLD | NEW |