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

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: fixing the branching issue 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
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 bool UpdateEntrySize(const std::string& key, uint64 entry_size);
51
50 private: 52 private:
51 // TODO(felipeg): This way we are storing the hash_key string twice (as the 53 // 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 54 // 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 55 // redefine the hash_map::operators and make the hash_map::key be part of the
54 // EntryMetadata itself. 56 // EntryMetadata itself.
55 typedef base::hash_map<std::string, SimpleIndexFile::EntryMetadata> EntrySet; 57 typedef base::hash_map<std::string, SimpleIndexFile::EntryMetadata> EntrySet;
56 58
57 void InsertInternal(const SimpleIndexFile::EntryMetadata& entry_metadata); 59 void InsertInternal(const SimpleIndexFile::EntryMetadata& entry_metadata);
58 60
59 // Enumerates all entries' files on disk and regenerates the index. 61 // Enumerates all entries' files on disk and regenerates the index.
60 bool RestoreFromDisk(); 62 bool RestoreFromDisk();
61 63
62 // |out_buffer| needs to be pre-allocated. The serialized index is stored in 64 // |out_buffer| needs to be pre-allocated. The serialized index is stored in
63 // |out_buffer|. 65 // |out_buffer|.
64 void Serialize(std::string* out_buffer); 66 void Serialize(std::string* out_buffer);
65 67
66 bool OpenIndexFile(); 68 bool OpenIndexFile();
67 bool CloseIndexFile(); 69 bool CloseIndexFile();
68 70
69 static void UpdateFile(const base::FilePath& index_filename, 71 static void UpdateFile(const base::FilePath& index_filename,
70 const base::FilePath& temp_filename, 72 const base::FilePath& temp_filename,
71 scoped_ptr<std::string> buffer); 73 scoped_ptr<std::string> buffer);
72 74
73 const base::FilePath path_; 75 const base::FilePath path_;
74 76
75 EntrySet entries_set_; 77 EntrySet entries_set_;
78 uint64 cache_size_; // Total cache storage size in bytes.
76 79
77 base::FilePath index_filename_; 80 base::FilePath index_filename_;
78 base::PlatformFile index_file_; 81 base::PlatformFile index_file_;
79 82
80 // We keep the thread from where Initialize() method has been called so that 83 // 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 84 // we run the Cleanup method in the same thread. Usually that should be the
82 // CacheThread. 85 // CacheThread.
83 scoped_refptr<base::TaskRunner> cache_thread_; 86 scoped_refptr<base::TaskRunner> cache_thread_;
84 }; 87 };
85 88
86 } // namespace disk_cache 89 } // namespace disk_cache
87 90
88 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 91 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698