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

Side by Side Diff: net/disk_cache/mem_entry_impl.h

Issue 6613027: Adds memory cache logging, and updates disk cache logging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Oops Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/mem_backend_impl.cc ('k') | net/disk_cache/mem_entry_impl.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) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 #ifndef NET_DISK_CACHE_MEM_ENTRY_IMPL_H_ 5 #ifndef NET_DISK_CACHE_MEM_ENTRY_IMPL_H_
6 #define NET_DISK_CACHE_MEM_ENTRY_IMPL_H_ 6 #define NET_DISK_CACHE_MEM_ENTRY_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
11 #include "net/base/net_log.h"
11 #include "net/disk_cache/disk_cache.h" 12 #include "net/disk_cache/disk_cache.h"
12 #include "testing/gtest/include/gtest/gtest_prod.h" 13 #include "testing/gtest/include/gtest/gtest_prod.h"
13 14
14 namespace disk_cache { 15 namespace disk_cache {
15 16
16 class MemBackendImpl; 17 class MemBackendImpl;
17 18
18 // This class implements the Entry interface for the memory-only cache. An 19 // This class implements the Entry interface for the memory-only cache. An
19 // object of this class represents a single entry on the cache. We use two 20 // object of this class represents a single entry on the cache. We use two
20 // types of entries, parent and child to support sparse caching. 21 // types of entries, parent and child to support sparse caching.
(...skipping 26 matching lines...) Expand all
47 public: 48 public:
48 enum EntryType { 49 enum EntryType {
49 kParentEntry, 50 kParentEntry,
50 kChildEntry, 51 kChildEntry,
51 }; 52 };
52 53
53 explicit MemEntryImpl(MemBackendImpl* backend); 54 explicit MemEntryImpl(MemBackendImpl* backend);
54 55
55 // Performs the initialization of a EntryImpl that will be added to the 56 // Performs the initialization of a EntryImpl that will be added to the
56 // cache. 57 // cache.
57 bool CreateEntry(const std::string& key); 58 bool CreateEntry(const std::string& key, net::NetLog* net_log);
58 59
59 // Permanently destroys this entry. 60 // Permanently destroys this entry.
60 void InternalDoom(); 61 void InternalDoom();
61 62
62 void Open(); 63 void Open();
63 bool InUse(); 64 bool InUse();
64 65
65 MemEntryImpl* next() const { 66 MemEntryImpl* next() const {
66 return next_; 67 return next_;
67 } 68 }
68 69
69 MemEntryImpl* prev() const { 70 MemEntryImpl* prev() const {
70 return prev_; 71 return prev_;
71 } 72 }
72 73
73 void set_next(MemEntryImpl* next) { 74 void set_next(MemEntryImpl* next) {
74 next_ = next; 75 next_ = next;
75 } 76 }
76 77
77 void set_prev(MemEntryImpl* prev) { 78 void set_prev(MemEntryImpl* prev) {
78 prev_ = prev; 79 prev_ = prev;
79 } 80 }
80 81
81 EntryType type() const { 82 EntryType type() const {
82 return parent_ ? kChildEntry : kParentEntry; 83 return parent_ ? kChildEntry : kParentEntry;
83 } 84 }
84 85
86 std::string& key() {
87 return key_;
88 }
89
90 net::BoundNetLog& net_log() {
91 return net_log_;
92 }
93
85 // Entry interface. 94 // Entry interface.
86 virtual void Doom(); 95 virtual void Doom();
87 virtual void Close(); 96 virtual void Close();
88 virtual std::string GetKey() const; 97 virtual std::string GetKey() const;
89 virtual base::Time GetLastUsed() const; 98 virtual base::Time GetLastUsed() const;
90 virtual base::Time GetLastModified() const; 99 virtual base::Time GetLastModified() const;
91 virtual int32 GetDataSize(int index) const; 100 virtual int32 GetDataSize(int index) const;
92 virtual int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len, 101 virtual int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len,
93 net::CompletionCallback* completion_callback); 102 net::CompletionCallback* completion_callback);
94 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, 103 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len,
(...skipping 11 matching lines...) Expand all
106 115
107 private: 116 private:
108 typedef base::hash_map<int, MemEntryImpl*> EntryMap; 117 typedef base::hash_map<int, MemEntryImpl*> EntryMap;
109 118
110 enum { 119 enum {
111 NUM_STREAMS = 3 120 NUM_STREAMS = 3
112 }; 121 };
113 122
114 ~MemEntryImpl(); 123 ~MemEntryImpl();
115 124
125 // Do all the work for corresponding public functions. Implemented as
126 // separate functions to make logging of results simpler.
127 int InternalReadData(int index, int offset, net::IOBuffer* buf, int buf_len);
128 int InternalWriteData(int index, int offset, net::IOBuffer* buf, int buf_len,
129 bool truncate);
130 int InternalReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len);
131 int InternalWriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len);
132
116 // Old Entry interface. 133 // Old Entry interface.
117 int GetAvailableRange(int64 offset, int len, int64* start); 134 int GetAvailableRange(int64 offset, int len, int64* start);
118 135
119 // Grows and cleans up the data buffer. 136 // Grows and cleans up the data buffer.
120 void PrepareTarget(int index, int offset, int buf_len); 137 void PrepareTarget(int index, int offset, int buf_len);
121 138
122 // Updates ranking information. 139 // Updates ranking information.
123 void UpdateRank(bool modified); 140 void UpdateRank(bool modified);
124 141
125 // Initializes the children map and sparse info. This method is only called 142 // Initializes the children map and sparse info. This method is only called
126 // on a parent entry. 143 // on a parent entry.
127 bool InitSparseInfo(); 144 bool InitSparseInfo();
128 145
129 // Performs the initialization of a MemEntryImpl as a child entry. 146 // Performs the initialization of a MemEntryImpl as a child entry.
130 // |parent| is the pointer to the parent entry. |child_id| is the ID of 147 // |parent| is the pointer to the parent entry. |child_id| is the ID of
131 // the new child. 148 // the new child.
132 bool InitChildEntry(MemEntryImpl* parent, int child_id); 149 bool InitChildEntry(MemEntryImpl* parent, int child_id, net::NetLog* net_log);
133 150
134 // Returns an entry responsible for |offset|. The returned entry can be a 151 // Returns an entry responsible for |offset|. The returned entry can be a
135 // child entry or this entry itself if |offset| points to the first range. 152 // child entry or this entry itself if |offset| points to the first range.
136 // If such entry does not exist and |create| is true, a new child entry is 153 // If such entry does not exist and |create| is true, a new child entry is
137 // created. 154 // created.
138 MemEntryImpl* OpenChild(int64 offset, bool create); 155 MemEntryImpl* OpenChild(int64 offset, bool create);
139 156
140 // Finds the first child located within the range [|offset|, |offset + len|). 157 // Finds the first child located within the range [|offset|, |offset + len|).
141 // Returns the number of bytes ahead of |offset| to reach the first available 158 // Returns the number of bytes ahead of |offset| to reach the first available
142 // bytes in the entry. The first child found is output to |child|. 159 // bytes in the entry. The first child found is output to |child|.
(...skipping 13 matching lines...) Expand all
156 MemEntryImpl* next_; // Pointers for the LRU list. 173 MemEntryImpl* next_; // Pointers for the LRU list.
157 MemEntryImpl* prev_; 174 MemEntryImpl* prev_;
158 MemEntryImpl* parent_; // Pointer to the parent entry. 175 MemEntryImpl* parent_; // Pointer to the parent entry.
159 scoped_ptr<EntryMap> children_; 176 scoped_ptr<EntryMap> children_;
160 177
161 base::Time last_modified_; // LRU information. 178 base::Time last_modified_; // LRU information.
162 base::Time last_used_; 179 base::Time last_used_;
163 MemBackendImpl* backend_; // Back pointer to the cache. 180 MemBackendImpl* backend_; // Back pointer to the cache.
164 bool doomed_; // True if this entry was removed from the cache. 181 bool doomed_; // True if this entry was removed from the cache.
165 182
183 net::BoundNetLog net_log_;
184
166 DISALLOW_COPY_AND_ASSIGN(MemEntryImpl); 185 DISALLOW_COPY_AND_ASSIGN(MemEntryImpl);
167 }; 186 };
168 187
169 } // namespace disk_cache 188 } // namespace disk_cache
170 189
171 #endif // NET_DISK_CACHE_MEM_ENTRY_IMPL_H_ 190 #endif // NET_DISK_CACHE_MEM_ENTRY_IMPL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/mem_backend_impl.cc ('k') | net/disk_cache/mem_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698