| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/mem_entry_impl.h" | 5 #include "net/disk_cache/memory/mem_entry_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // Returns a name for a child entry given the base_name of the parent and the | 38 // Returns a name for a child entry given the base_name of the parent and the |
| 39 // child_id. This name is only used for logging purposes. | 39 // child_id. This name is only used for logging purposes. |
| 40 // 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 |
| 41 // like Range_entry_name:YYY where YYY is the number of the particular child. | 41 // like Range_entry_name:YYY where YYY is the number of the particular child. |
| 42 std::string GenerateChildName(const std::string& base_name, int child_id) { | 42 std::string GenerateChildName(const std::string& base_name, int child_id) { |
| 43 return base::StringPrintf("Range_%s:%i", base_name.c_str(), child_id); | 43 return base::StringPrintf("Range_%s:%i", base_name.c_str(), child_id); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Returns NetLog parameters for the creation of a child MemEntryImpl. Separate | 46 // Returns NetLog parameters for the creation of a child MemEntryImpl. Separate |
| 47 // function needed because child entries don't suppport GetKey(). | 47 // function needed because child entries don't suppport GetKey(). |
| 48 base::Value* NetLogChildEntryCreationCallback( | 48 scoped_ptr<base::Value> NetLogChildEntryCreationCallback( |
| 49 const disk_cache::MemEntryImpl* parent, | 49 const disk_cache::MemEntryImpl* parent, |
| 50 int child_id, | 50 int child_id, |
| 51 net::NetLogCaptureMode /* capture_mode */) { | 51 net::NetLogCaptureMode /* capture_mode */) { |
| 52 base::DictionaryValue* dict = new base::DictionaryValue(); | 52 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 53 dict->SetString("key", GenerateChildName(parent->GetKey(), child_id)); | 53 dict->SetString("key", GenerateChildName(parent->GetKey(), child_id)); |
| 54 dict->SetBoolean("created", true); | 54 dict->SetBoolean("created", true); |
| 55 return dict; | 55 return dict.Pass(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 namespace disk_cache { | 60 namespace disk_cache { |
| 61 | 61 |
| 62 MemEntryImpl::MemEntryImpl(MemBackendImpl* backend) { | 62 MemEntryImpl::MemEntryImpl(MemBackendImpl* backend) { |
| 63 doomed_ = false; | 63 doomed_ = false; |
| 64 backend_ = backend; | 64 backend_ = backend; |
| 65 ref_count_ = 0; | 65 ref_count_ = 0; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 scanned_len += kMaxSparseEntrySize - current_child_offset; | 622 scanned_len += kMaxSparseEntrySize - current_child_offset; |
| 623 } | 623 } |
| 624 return scanned_len; | 624 return scanned_len; |
| 625 } | 625 } |
| 626 | 626 |
| 627 void MemEntryImpl::DetachChild(int child_id) { | 627 void MemEntryImpl::DetachChild(int child_id) { |
| 628 children_->erase(child_id); | 628 children_->erase(child_id); |
| 629 } | 629 } |
| 630 | 630 |
| 631 } // namespace disk_cache | 631 } // namespace disk_cache |
| OLD | NEW |