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 ~Stream(); | |
42 int offset; | |
43 int size; | |
44 std::vector<char> write_buffer; | |
45 }; | |
46 | |
47 bool OnDisk() const; | |
48 bool InvalidStream(int stream_index) const; | |
49 int32 Size() const; | |
50 bool Save(); | |
51 | |
52 LogStructuredStore* store_; | |
53 int32 id_; | |
54 Stream streams_[kFlashCacheEntryNumStreams]; | |
55 bool init_; | |
56 bool closed_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(CacheEntry); | |
59 }; | |
60 | |
61 } // namespace disk_cache | |
62 | |
63 #endif // NET_DISK_CACHE_FLASH_LOG_ENTRY_H_ | |
OLD | NEW |