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