OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_DISK_CACHE_FLASH_LOG_ENTRY_H_ |
| 6 #define NET_DISK_CACHE_FLASH_LOG_ENTRY_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "net/base/net_export.h" |
| 13 #include "net/disk_cache/flash/format.h" |
| 14 |
| 15 namespace net { |
| 16 class IOBuffer; |
| 17 }; |
| 18 |
| 19 namespace disk_cache { |
| 20 |
| 21 class LogStructuredStore; |
| 22 |
| 23 class NET_EXPORT_PRIVATE CacheEntry { |
| 24 public: |
| 25 explicit CacheEntry(LogStructuredStore* store); |
| 26 CacheEntry(LogStructuredStore* store, int32 id); |
| 27 ~CacheEntry(); |
| 28 |
| 29 bool Init(); |
| 30 bool Close(); |
| 31 |
| 32 int32 id() const; |
| 33 int32 GetDataSize(int index) const; |
| 34 |
| 35 int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len); |
| 36 int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len); |
| 37 |
| 38 private: |
| 39 struct Stream { |
| 40 Stream(); |
| 41 int offset; |
| 42 int size; |
| 43 std::vector<char> write_buffer; |
| 44 }; |
| 45 |
| 46 bool OnDisk() const; |
| 47 bool InvalidStream(int stream_index) const; |
| 48 int32 Size() const; |
| 49 bool Save(); |
| 50 |
| 51 LogStructuredStore* store_; |
| 52 int32 id_; |
| 53 Stream streams_[kFlashCacheEntryNumStreams]; |
| 54 bool init_; |
| 55 bool closed_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(CacheEntry); |
| 58 }; |
| 59 |
| 60 } // namespace disk_cache |
| 61 |
| 62 #endif // NET_DISK_CACHE_FLASH_LOG_ENTRY_H_ |
OLD | NEW |