// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // See net/disk_cache/disk_cache.h for the public interface. #ifndef NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_ #define NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_ #include <stddef.h> #include <stdint.h> #include "base/memory/raw_ptr.h" #include "net/disk_cache/blockfile/addr.h" #include "net/disk_cache/blockfile/mapped_file.h" namespace disk_cache { // This class encapsulates common behavior of a single "block" of data that is // stored on a block-file. It implements the FileBlock interface, so it can be // serialized directly to the backing file. // This object provides a memory buffer for the related data, and it can be used // to actually share that memory with another instance of the class. // // The following example shows how to share storage with another object: // StorageBlock<TypeA> a(file, address); // StorageBlock<TypeB> b(file, address); // a.Load(); // DoSomething(a.Data()); // b.SetData(a.Data()); // ModifySomething(b.Data()); // // Data modified on the previous call will be saved by b's destructor. // b.set_modified(); template<typename T> class StorageBlock : public FileBlock { … }; } // namespace disk_cache #endif // NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_