| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/histogram.h" | 8 #include "base/histogram.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // using this file again. | 177 // using this file again. |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 return !have_space; | 180 return !have_space; |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace | 183 } // namespace |
| 184 | 184 |
| 185 namespace disk_cache { | 185 namespace disk_cache { |
| 186 | 186 |
| 187 BlockFiles::BlockFiles(const FilePath& path) |
| 188 : init_(false), zero_buffer_(NULL), path_(path) { |
| 189 } |
| 190 |
| 187 BlockFiles::~BlockFiles() { | 191 BlockFiles::~BlockFiles() { |
| 188 if (zero_buffer_) | 192 if (zero_buffer_) |
| 189 delete[] zero_buffer_; | 193 delete[] zero_buffer_; |
| 190 CloseFiles(); | 194 CloseFiles(); |
| 191 } | 195 } |
| 192 | 196 |
| 193 bool BlockFiles::Init(bool create_files) { | 197 bool BlockFiles::Init(bool create_files) { |
| 194 DCHECK(!init_); | 198 DCHECK(!init_); |
| 195 if (init_) | 199 if (init_) |
| 196 return false; | 200 return false; |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 605 } |
| 602 | 606 |
| 603 FilePath BlockFiles::Name(int index) { | 607 FilePath BlockFiles::Name(int index) { |
| 604 // The file format allows for 256 files. | 608 // The file format allows for 256 files. |
| 605 DCHECK(index < 256 || index >= 0); | 609 DCHECK(index < 256 || index >= 0); |
| 606 std::string tmp = base::StringPrintf("%s%d", kBlockName, index); | 610 std::string tmp = base::StringPrintf("%s%d", kBlockName, index); |
| 607 return path_.AppendASCII(tmp); | 611 return path_.AppendASCII(tmp); |
| 608 } | 612 } |
| 609 | 613 |
| 610 } // namespace disk_cache | 614 } // namespace disk_cache |
| OLD | NEW |