| 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_synchronous_entry.h" | 5 #include "net/disk_cache/simple/simple_synchronous_entry.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <functional> | 9 #include <functional> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 GetFilenameFromEntryHashAndIndex(entry_hash, i)); | 250 GetFilenameFromEntryHashAndIndex(entry_hash, i)); |
| 251 if (!base::DeleteFile(to_delete, false)) { | 251 if (!base::DeleteFile(to_delete, false)) { |
| 252 result = false; | 252 result = false; |
| 253 DLOG(ERROR) << "Could not delete " << to_delete.MaybeAsASCII(); | 253 DLOG(ERROR) << "Could not delete " << to_delete.MaybeAsASCII(); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 return result; | 256 return result; |
| 257 } | 257 } |
| 258 | 258 |
| 259 // static | 259 // static |
| 260 void SimpleSynchronousEntry::DoomEntry( | 260 int SimpleSynchronousEntry::DoomEntry( |
| 261 const FilePath& path, | 261 const FilePath& path, |
| 262 const std::string& key, | 262 const std::string& key, |
| 263 uint64 entry_hash, | 263 uint64 entry_hash) { |
| 264 int* out_result) { | |
| 265 DCHECK_EQ(entry_hash, GetEntryHashKey(key)); | 264 DCHECK_EQ(entry_hash, GetEntryHashKey(key)); |
| 266 bool deleted_well = DeleteFilesForEntryHash(path, entry_hash); | 265 const bool deleted_well = DeleteFilesForEntryHash(path, entry_hash); |
| 267 *out_result = deleted_well ? net::OK : net::ERR_FAILED; | 266 return deleted_well ? net::OK : net::ERR_FAILED; |
| 268 } | 267 } |
| 269 | 268 |
| 270 // static | 269 // static |
| 271 int SimpleSynchronousEntry::DoomEntrySet( | 270 int SimpleSynchronousEntry::DoomEntrySet( |
| 272 scoped_ptr<std::vector<uint64> > key_hashes, | 271 scoped_ptr<std::vector<uint64> > key_hashes, |
| 273 const FilePath& path) { | 272 const FilePath& path) { |
| 274 const size_t did_delete_count = std::count_if( | 273 const size_t did_delete_count = std::count_if( |
| 275 key_hashes->begin(), key_hashes->end(), std::bind1st( | 274 key_hashes->begin(), key_hashes->end(), std::bind1st( |
| 276 std::ptr_fun(SimpleSynchronousEntry::DeleteFilesForEntryHash), path)); | 275 std::ptr_fun(SimpleSynchronousEntry::DeleteFilesForEntryHash), path)); |
| 277 return (did_delete_count == key_hashes->size()) ? net::OK : net::ERR_FAILED; | 276 return (did_delete_count == key_hashes->size()) ? net::OK : net::ERR_FAILED; |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 initialized_ = true; | 655 initialized_ = true; |
| 657 return net::OK; | 656 return net::OK; |
| 658 } | 657 } |
| 659 | 658 |
| 660 void SimpleSynchronousEntry::Doom() const { | 659 void SimpleSynchronousEntry::Doom() const { |
| 661 // TODO(gavinp): Consider if we should guard against redundant Doom() calls. | 660 // TODO(gavinp): Consider if we should guard against redundant Doom() calls. |
| 662 DeleteFilesForEntryHash(path_, entry_hash_); | 661 DeleteFilesForEntryHash(path_, entry_hash_); |
| 663 } | 662 } |
| 664 | 663 |
| 665 } // namespace disk_cache | 664 } // namespace disk_cache |
| OLD | NEW |