Index: net/disk_cache/v3/entry_operation.h |
=================================================================== |
--- net/disk_cache/v3/entry_operation.h (revision 0) |
+++ net/disk_cache/v3/entry_operation.h (revision 0) |
@@ -0,0 +1,115 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NET_DISK_CACHE_V3_ENTRY_OPERATION_H_ |
+#define NET_DISK_CACHE_V3_ENTRY_OPERATION_H_ |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "net/base/net_log.h" |
+#include "net/disk_cache/disk_cache.h" |
+#include "net/disk_cache/v3/storage_block.h" |
+#include "net/disk_cache/v3/disk_format_v3.h" |
+ |
+namespace disk_cache { |
+ |
+ |
+// This class implements the Entry interface. An object of this |
+// class represents a single entry on the cache. |
+class EntryOperation : public base::RefCounted<EntryOperation> { |
+ friend class base::RefCounted<EntryOperation>; |
+ public: |
+ enum OperationType { |
+ |
+ }; |
+ |
+ EntryOperation(BackendImplV3* backend, Addr address, bool read_only); |
+ EntryOperation(BackendImplV3* backend, Addr address, const std::string& key, |
+ scoped_ptr<EntryRecord> record); |
+ |
+ |
+ private: |
+ ~EntryOperation(); |
+ |
+ // Do all the work for ReadDataImpl and WriteDataImpl. Implemented as |
+ // separate functions to make logging of results simpler. |
+ int InternalReadData(int index, int offset, IOBuffer* buf, |
+ int buf_len, const CompletionCallback& callback); |
+ int InternalWriteData(int index, int offset, IOBuffer* buf, int buf_len, |
+ const CompletionCallback& callback, bool truncate); |
+ |
+ // Initializes the storage for an internal or external data block. |
+ bool CreateDataBlock(int index, int size); |
+ |
+ // Initializes the storage for an internal or external generic block. |
+ bool CreateBlock(int size, Addr* address); |
+ |
+ // Deletes the data pointed by address, maybe backed by files_[index]. |
+ // Note that most likely the caller should delete (and store) the reference to |
+ // |address| *before* calling this method because we don't want to have an |
+ // entry using an address that is already free. |
+ void DeleteData(Addr address, int index); |
+ |
+ // Updates ranking information. |
+ void UpdateRank(bool modified); |
+ |
+ // Returns a pointer to the file that stores the given address. |
+ File* GetBackingFile(Addr address, int index); |
+ |
+ // Returns a pointer to the file that stores external data. |
+ File* GetExternalFile(Addr address, int index); |
+ |
+ // Prepares the target file or buffer for a write of buf_len bytes at the |
+ // given offset. |
+ bool PrepareTarget(int index, int offset, int buf_len, bool truncate); |
+ |
+ // Adjusts the internal buffer and file handle for a write that truncates this |
+ // stream. |
+ bool HandleTruncation(int index, int offset, int buf_len); |
+ |
+ // Copies data from disk to the internal buffer. |
+ bool CopyToLocalBuffer(int index); |
+ |
+ // Reads from a block data file to this object's memory buffer. |
+ bool MoveToLocalBuffer(int index); |
+ |
+ // Loads the external file to this object's memory buffer. |
+ bool ImportSeparateFile(int index, int new_size); |
+ |
+ // Makes sure that the internal buffer can handle the a write of |buf_len| |
+ // bytes to |offset|. |
+ bool PrepareBuffer(int index, int offset, int buf_len); |
+ |
+ // Flushes the in-memory data to the backing storage. The data destination |
+ // is determined based on the current data length and |min_len|. |
+ bool Flush(int index, int min_len); |
+ |
+ // Updates the size of a given data stream. |
+ void UpdateSize(int index, int old_size, int new_size); |
+ |
+ // Initializes the sparse control object. Returns a net error code. |
+ int InitSparseData(); |
+ |
+ // Adds the provided |flags| to the current EntryFlags for this entry. |
+ void SetEntryFlags(uint32 flags); |
+ |
+ // Returns the current EntryFlags for this entry. |
+ uint32 GetEntryFlags(); |
+ |
+ // Gets the data stored at the given index. If the information is in memory, |
+ // a buffer will be allocated and the data will be copied to it (the caller |
+ // can find out the size of the buffer before making this call). Otherwise, |
+ // the cache address of the data will be returned, and that address will be |
+ // removed from the regular book keeping of this entry so the caller is |
+ // responsible for deleting the block (or file) from the backing store at some |
+ // point; there is no need to report any storage-size change, only to do the |
+ // actual cleanup. |
+ void GetData(int index, char** buffer, Addr* address); |
+ |
+ |
+ DISALLOW_COPY_AND_ASSIGN(EntryOperation); |
+}; |
+ |
+} // namespace disk_cache |
+ |
+#endif // NET_DISK_CACHE_V3_ENTRY_OPERATION_H_ |
Property changes on: net\disk_cache\v3\entry_operation.h |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |