Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: net/disk_cache/memory/mem_entry_impl.cc

Issue 1135373002: Updated NetLog::ParametersCallback & all related calbacks returning value as scoped_ptr<base::Value… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cert/x509_certificate_net_log_param.cc ('k') | net/disk_cache/net_log_parameters.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 558
559 bool MemEntryImpl::InitChildEntry(MemEntryImpl* parent, int child_id, 559 bool MemEntryImpl::InitChildEntry(MemEntryImpl* parent, int child_id,
560 net::NetLog* net_log) { 560 net::NetLog* net_log) {
561 DCHECK(!parent_); 561 DCHECK(!parent_);
562 DCHECK(!child_id_); 562 DCHECK(!child_id_);
563 563
564 net_log_ = net::BoundNetLog::Make(net_log, 564 net_log_ = net::BoundNetLog::Make(net_log,
565 net::NetLog::SOURCE_MEMORY_CACHE_ENTRY); 565 net::NetLog::SOURCE_MEMORY_CACHE_ENTRY);
566 net_log_.BeginEvent( 566 net_log_.BeginEvent(
567 net::NetLog::TYPE_DISK_CACHE_MEM_ENTRY_IMPL, 567 net::NetLog::TYPE_DISK_CACHE_MEM_ENTRY_IMPL,
568 base::Bind(&NetLogChildEntryCreationCallback, parent, child_id_)); 568 base::Bind(NetLogChildEntryCreationCallback, parent, child_id_));
569 569
570 parent_ = parent; 570 parent_ = parent;
571 child_id_ = child_id; 571 child_id_ = child_id;
572 Time current = Time::Now(); 572 Time current = Time::Now();
573 last_modified_ = current; 573 last_modified_ = current;
574 last_used_ = current; 574 last_used_ = current;
575 // Insert this to the backend's ranking list. 575 // Insert this to the backend's ranking list.
576 backend_->InsertIntoRankingList(this); 576 backend_->InsertIntoRankingList(this);
577 return true; 577 return true;
578 } 578 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « net/cert/x509_certificate_net_log_param.cc ('k') | net/disk_cache/net_log_parameters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698