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

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

Issue 17507006: Disk cache v3 ref2 Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Incl IndexTable cl Created 7 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
« no previous file with comments | « net/disk_cache/mapped_file_win.cc ('k') | net/disk_cache/storage_block-inl.h » ('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 // 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 9
10 #include "net/disk_cache/addr.h" 10 #include "net/disk_cache/addr.h"
(...skipping 12 matching lines...) Expand all
23 // StorageBlock<TypeB> b(file, address); 23 // StorageBlock<TypeB> b(file, address);
24 // a.Load(); 24 // a.Load();
25 // DoSomething(a.Data()); 25 // DoSomething(a.Data());
26 // b.SetData(a.Data()); 26 // b.SetData(a.Data());
27 // ModifySomething(b.Data()); 27 // ModifySomething(b.Data());
28 // // Data modified on the previous call will be saved by b's destructor. 28 // // Data modified on the previous call will be saved by b's destructor.
29 // b.set_modified(); 29 // b.set_modified();
30 template<typename T> 30 template<typename T>
31 class StorageBlock : public FileBlock { 31 class StorageBlock : public FileBlock {
32 public: 32 public:
33 StorageBlock();
33 StorageBlock(MappedFile* file, Addr address); 34 StorageBlock(MappedFile* file, Addr address);
34 virtual ~StorageBlock(); 35 virtual ~StorageBlock();
35 36
36 // FileBlock interface. 37 // FileBlock interface.
37 virtual void* buffer() const; 38 virtual void* buffer() const;
38 virtual size_t size() const; 39 virtual size_t size() const;
39 virtual int offset() const; 40 virtual int offset() const;
40 41
41 // Allows the overide of dummy values passed on the constructor. 42 // Allows the overide of dummy values passed on the constructor.
42 bool LazyInit(MappedFile* file, Addr address); 43 bool LazyInit(MappedFile* file, Addr address);
(...skipping 10 matching lines...) Expand all
53 54
54 // 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.
55 void set_modified(); 56 void set_modified();
56 57
57 // Forgets that the data was modified, so it's not lazily saved. 58 // Forgets that the data was modified, so it's not lazily saved.
58 void clear_modified(); 59 void clear_modified();
59 60
60 // Gets a pointer to the internal storage (allocates storage if needed). 61 // Gets a pointer to the internal storage (allocates storage if needed).
61 T* Data(); 62 T* Data();
62 63
64 // Returns the internal storage, if any.
65 T* ReleaseData();
66
63 // Returns true if there is data associated with this object. 67 // Returns true if there is data associated with this object.
64 bool HasData() const; 68 bool HasData() const;
65 69
66 // Returns true if the internal hash is correct. 70 // Returns true if the internal hash is correct.
67 bool VerifyHash() const; 71 bool VerifyHash() const;
68 72
73 // Updates the internal hash value.
74 void UpdateHash();
75
69 // Returns true if this object owns the data buffer, false if it is shared. 76 // Returns true if this object owns the data buffer, false if it is shared.
70 bool own_data() const; 77 bool own_data() const;
71 78
72 const Addr address() const; 79 const Addr address() const;
73 80
74 // Loads and store the data. 81 // Loads and store the data.
75 bool Load(); 82 bool Load();
76 bool Store(); 83 bool Store();
77 bool Load(FileIOCallback* callback, bool* completed); 84 bool Load(FileIOCallback* callback, bool* completed);
78 bool Store(FileIOCallback* callback, bool* completed); 85 bool Store(FileIOCallback* callback, bool* completed);
79 86
80 private: 87 private:
81 void AllocateData(); 88 void AllocateData();
82 void DeleteData(); 89 void DeleteData();
83 uint32 CalculateHash() const; 90 uint32 CalculateHash() const;
84 91
85 T* data_; 92 T* data_;
86 MappedFile* file_; 93 MappedFile* file_;
87 Addr address_; 94 Addr address_;
88 bool modified_; 95 bool modified_;
89 bool own_data_; // Is data_ owned by this object or shared with someone else. 96 bool own_data_; // Is data_ owned by this object or shared with someone else.
90 bool extended_; // Used to store an entry of more than one block. 97 bool extended_; // Used to store an entry of more than one block.
91 98
92 DISALLOW_COPY_AND_ASSIGN(StorageBlock); 99 DISALLOW_COPY_AND_ASSIGN(StorageBlock);
93 }; 100 };
94 101
95 } // namespace disk_cache 102 } // namespace disk_cache
96 103
97 #endif // NET_DISK_CACHE_STORAGE_BLOCK_H_ 104 #endif // NET_DISK_CACHE_STORAGE_BLOCK_H_
OLDNEW
« no previous file with comments | « net/disk_cache/mapped_file_win.cc ('k') | net/disk_cache/storage_block-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698