| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009-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/sparse_control.h" | 5 #include "net/disk_cache/sparse_control.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/stringprintf.h" |
| 11 #include "base/time.h" | 12 #include "base/time.h" |
| 12 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 13 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 14 #include "net/disk_cache/backend_impl.h" | 15 #include "net/disk_cache/backend_impl.h" |
| 15 #include "net/disk_cache/entry_impl.h" | 16 #include "net/disk_cache/entry_impl.h" |
| 16 #include "net/disk_cache/file.h" | 17 #include "net/disk_cache/file.h" |
| 17 | 18 |
| 18 using base::Time; | 19 using base::Time; |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 34 // The size of each data block (tracked by the child allocation bitmap). | 35 // The size of each data block (tracked by the child allocation bitmap). |
| 35 const int kBlockSize = 1024; | 36 const int kBlockSize = 1024; |
| 36 | 37 |
| 37 // Returns the name of of a child entry given the base_name and signature of the | 38 // Returns the name of of a child entry given the base_name and signature of the |
| 38 // parent and the child_id. | 39 // parent and the child_id. |
| 39 // If the entry is called entry_name, child entries will be named something | 40 // If the entry is called entry_name, child entries will be named something |
| 40 // like Range_entry_name:XXX:YYY where XXX is the entry signature and YYY is the | 41 // like Range_entry_name:XXX:YYY where XXX is the entry signature and YYY is the |
| 41 // number of the particular child. | 42 // number of the particular child. |
| 42 std::string GenerateChildName(const std::string& base_name, int64 signature, | 43 std::string GenerateChildName(const std::string& base_name, int64 signature, |
| 43 int64 child_id) { | 44 int64 child_id) { |
| 44 return StringPrintf("Range_%s:%" PRIx64 ":%" PRIx64, base_name.c_str(), | 45 return base::StringPrintf("Range_%s:%" PRIx64 ":%" PRIx64, base_name.c_str(), |
| 45 signature, child_id); | 46 signature, child_id); |
| 46 } | 47 } |
| 47 | 48 |
| 48 // This class deletes the children of a sparse entry. | 49 // This class deletes the children of a sparse entry. |
| 49 class ChildrenDeleter | 50 class ChildrenDeleter |
| 50 : public base::RefCounted<ChildrenDeleter>, | 51 : public base::RefCounted<ChildrenDeleter>, |
| 51 public disk_cache::FileIOCallback { | 52 public disk_cache::FileIOCallback { |
| 52 public: | 53 public: |
| 53 ChildrenDeleter(disk_cache::BackendImpl* backend, const std::string& name) | 54 ChildrenDeleter(disk_cache::BackendImpl* backend, const std::string& name) |
| 54 : backend_(backend->GetWeakPtr()), name_(name) {} | 55 : backend_(backend->GetWeakPtr()), name_(name) {} |
| 55 | 56 |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 net::CompletionCallback* c = abort_callbacks_[i]; | 753 net::CompletionCallback* c = abort_callbacks_[i]; |
| 753 if (i == abort_callbacks_.size() - 1) | 754 if (i == abort_callbacks_.size() - 1) |
| 754 abort_callbacks_.clear(); | 755 abort_callbacks_.clear(); |
| 755 | 756 |
| 756 entry_->Release(); // Don't touch object after this line. | 757 entry_->Release(); // Don't touch object after this line. |
| 757 c->Run(net::OK); | 758 c->Run(net::OK); |
| 758 } | 759 } |
| 759 } | 760 } |
| 760 | 761 |
| 761 } // namespace disk_cache | 762 } // namespace disk_cache |
| OLD | NEW |