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

Side by Side Diff: net/disk_cache/simple/simple_index.h

Issue 13913010: Add Cache size to the Simple Index. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: syncing Created 7 years, 8 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/simple/simple_entry_impl.cc ('k') | net/disk_cache/simple/simple_index.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) 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 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 29 matching lines...) Expand all
40 void Remove(const std::string& key); 40 void Remove(const std::string& key);
41 41
42 bool Has(const std::string& key) const; 42 bool Has(const std::string& key) const;
43 43
44 // Update the last used time of the entry with the given key and return true 44 // Update the last used time of the entry with the given key and return true
45 // iff the entry exist in the index. 45 // iff the entry exist in the index.
46 bool UseIfExists(const std::string& key); 46 bool UseIfExists(const std::string& key);
47 47
48 void Cleanup(); 48 void Cleanup();
49 49
50 // Update the size (in bytes) of an entry, in the metadata stored in the
51 // index. This should be the total disk-file size including all streams of the
52 // entry.
53 bool UpdateEntrySize(const std::string& key, uint64 entry_size);
54
50 private: 55 private:
51 // TODO(felipeg): This way we are storing the hash_key string twice (as the 56 // TODO(felipeg): This way we are storing the hash_key string twice (as the
52 // hash_map::key and as a member of EntryMetadata. We could save space if we 57 // hash_map::key and as a member of EntryMetadata. We could save space if we
53 // redefine the hash_map::operators and make the hash_map::key be part of the 58 // redefine the hash_map::operators and make the hash_map::key be part of the
54 // EntryMetadata itself. 59 // EntryMetadata itself.
55 typedef base::hash_map<std::string, SimpleIndexFile::EntryMetadata> EntrySet; 60 typedef base::hash_map<std::string, SimpleIndexFile::EntryMetadata> EntrySet;
56 61
57 void InsertInternal(const SimpleIndexFile::EntryMetadata& entry_metadata); 62 void InsertInternal(const SimpleIndexFile::EntryMetadata& entry_metadata);
58 63
59 // Enumerates all entries' files on disk and regenerates the index. 64 // Enumerates all entries' files on disk and regenerates the index.
60 bool RestoreFromDisk(); 65 bool RestoreFromDisk();
61 66
62 // |out_buffer| needs to be pre-allocated. The serialized index is stored in 67 // |out_buffer| needs to be pre-allocated. The serialized index is stored in
63 // |out_buffer|. 68 // |out_buffer|.
64 void Serialize(std::string* out_buffer); 69 void Serialize(std::string* out_buffer);
65 70
66 bool OpenIndexFile(); 71 bool OpenIndexFile();
67 bool CloseIndexFile(); 72 bool CloseIndexFile();
68 73
69 static void UpdateFile(const base::FilePath& index_filename, 74 static void UpdateFile(const base::FilePath& index_filename,
70 const base::FilePath& temp_filename, 75 const base::FilePath& temp_filename,
71 scoped_ptr<std::string> buffer); 76 scoped_ptr<std::string> buffer);
72 77
73 const base::FilePath path_; 78 const base::FilePath path_;
74 79
75 EntrySet entries_set_; 80 EntrySet entries_set_;
81 uint64 cache_size_; // Total cache storage size in bytes.
76 82
77 base::FilePath index_filename_; 83 base::FilePath index_filename_;
78 base::PlatformFile index_file_; 84 base::PlatformFile index_file_;
79 85
80 // We keep the thread from where Initialize() method has been called so that 86 // We keep the thread from where Initialize() method has been called so that
81 // we run the Cleanup method in the same thread. Usually that should be the 87 // we run the Cleanup method in the same thread. Usually that should be the
82 // CacheThread. 88 // CacheThread.
83 scoped_refptr<base::TaskRunner> cache_thread_; 89 scoped_refptr<base::TaskRunner> cache_thread_;
84 }; 90 };
85 91
86 } // namespace disk_cache 92 } // namespace disk_cache
87 93
88 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 94 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_entry_impl.cc ('k') | net/disk_cache/simple/simple_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698