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

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

Issue 8658001: Disk cache: Add a hash to the entry's internal data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // See net/disk_cache/disk_cache.h for the public interface. 5 // See net/disk_cache/disk_cache.h for the public interface.
6 6
7 #ifndef NET_DISK_CACHE_STORAGE_BLOCK_H__ 7 #ifndef NET_DISK_CACHE_STORAGE_BLOCK_H__
8 #define NET_DISK_CACHE_STORAGE_BLOCK_H__ 8 #define NET_DISK_CACHE_STORAGE_BLOCK_H__
9 #pragma once 9 #pragma once
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Sets the object to lazily save the in-memory data on destruction. 55 // Sets the object to lazily save the in-memory data on destruction.
56 void set_modified(); 56 void set_modified();
57 57
58 // Gets a pointer to the internal storage (allocates storage if needed). 58 // Gets a pointer to the internal storage (allocates storage if needed).
59 T* Data(); 59 T* Data();
60 60
61 // Returns true if there is data associated with this object. 61 // Returns true if there is data associated with this object.
62 bool HasData() const; 62 bool HasData() const;
63 63
64 // Returns true if the internal hash is correct.
65 bool VerifyHash() const;
66
64 // Returns true if this object owns the data buffer, false if it is shared. 67 // Returns true if this object owns the data buffer, false if it is shared.
65 bool own_data() const; 68 bool own_data() const;
66 69
67 const Addr address() const; 70 const Addr address() const;
68 71
69 // Loads and store the data. 72 // Loads and store the data.
70 bool Load(); 73 bool Load();
71 bool Store(); 74 bool Store();
72 75
73 private: 76 private:
74 void AllocateData(); 77 void AllocateData();
75 void DeleteData(); 78 void DeleteData();
79 uint32 CalculateHash() const;
76 80
77 T* data_; 81 T* data_;
78 MappedFile* file_; 82 MappedFile* file_;
79 Addr address_; 83 Addr address_;
80 bool modified_; 84 bool modified_;
81 bool own_data_; // Is data_ owned by this object or shared with someone else. 85 bool own_data_; // Is data_ owned by this object or shared with someone else.
82 bool extended_; // Used to store an entry of more than one block. 86 bool extended_; // Used to store an entry of more than one block.
83 87
84 DISALLOW_COPY_AND_ASSIGN(StorageBlock); 88 DISALLOW_COPY_AND_ASSIGN(StorageBlock);
85 }; 89 };
86 90
87 typedef StorageBlock<EntryStore> CacheEntryBlock; 91 typedef StorageBlock<EntryStore> CacheEntryBlock;
88 typedef StorageBlock<RankingsNode> CacheRankingsBlock; 92 typedef StorageBlock<RankingsNode> CacheRankingsBlock;
89 93
90 } // namespace disk_cache 94 } // namespace disk_cache
91 95
92 #endif // NET_DISK_CACHE_STORAGE_BLOCK_H__ 96 #endif // NET_DISK_CACHE_STORAGE_BLOCK_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698