Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: net/disk_cache/flash/log_store.h

Issue 11532011: Renamed classes for consistency. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: test 2. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/flash/format.h ('k') | net/disk_cache/flash/log_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_STRUCTURED_STORE_H_ 5 #ifndef NET_DISK_CACHE_FLASH_LOG_STORE_H_
6 #define NET_DISK_CACHE_FLASH_LOG_STRUCTURED_STORE_H_ 6 #define NET_DISK_CACHE_FLASH_LOG_STORE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
14 14
15 namespace disk_cache { 15 namespace disk_cache {
16 16
17 class Segment; 17 class Segment;
18 class Storage; 18 class Storage;
19 19
20 // This class implements a general purpose store for storing and retrieving 20 // This class implements a general purpose store for storing and retrieving
21 // entries consisting of arbitrary binary data. The store has log semantics, 21 // entries consisting of arbitrary binary data. The store has log semantics,
22 // i.e. it's not possible to overwrite data in place. In order to update an 22 // i.e. it's not possible to overwrite data in place. In order to update an
23 // entry, a new version must be written. Only one entry can be written to at 23 // entry, a new version must be written. Only one entry can be written to at
24 // any given time, while concurrent reading of multiple entries is supported. 24 // any given time, while concurrent reading of multiple entries is supported.
25 class NET_EXPORT_PRIVATE LogStructuredStore { 25 class NET_EXPORT_PRIVATE LogStore {
26 public: 26 public:
27 explicit LogStructuredStore(Storage* storage); 27 explicit LogStore(Storage* storage);
28 ~LogStructuredStore(); 28 ~LogStore();
29 29
30 // Performs initialization. Must be the first function called and further 30 // Performs initialization. Must be the first function called and further
31 // calls should be made only if it is successful. 31 // calls should be made only if it is successful.
32 bool Init(); 32 bool Init();
33 33
34 // Closes the store. Should be the last function called before destruction. 34 // Closes the store. Should be the last function called before destruction.
35 bool Close(); 35 bool Close();
36 36
37 // Creates an entry of |size| bytes. The id of the created entry is stored in 37 // Creates an entry of |size| bytes. The id of the created entry is stored in
38 // |entry_id|. 38 // |entry_id|.
(...skipping 10 matching lines...) Expand all
49 // Reads |size| bytes starting from |offset| into |buffer|, where |offset| is 49 // Reads |size| bytes starting from |offset| into |buffer|, where |offset| is
50 // relative to the entry's content, from an entry identified by |entry_id|. 50 // relative to the entry's content, from an entry identified by |entry_id|.
51 bool ReadData(int32 entry_id, void* buffer, int32 size, int32 offset) const; 51 bool ReadData(int32 entry_id, void* buffer, int32 size, int32 offset) const;
52 52
53 // Closes an entry that was either opened with OpenEntry or created with 53 // Closes an entry that was either opened with OpenEntry or created with
54 // CreateEntry. 54 // CreateEntry.
55 void CloseEntry(int32 id); 55 void CloseEntry(int32 id);
56 56
57 private: 57 private:
58 FRIEND_TEST_ALL_PREFIXES(FlashCacheTest, 58 FRIEND_TEST_ALL_PREFIXES(FlashCacheTest,
59 LogStructuredStoreReadFromClosedSegment); 59 LogStoreReadFromClosedSegment);
60 FRIEND_TEST_ALL_PREFIXES(FlashCacheTest, 60 FRIEND_TEST_ALL_PREFIXES(FlashCacheTest,
61 LogStructuredStoreSegmentSelectionIsFifo); 61 LogStoreSegmentSelectionIsFifo);
62 FRIEND_TEST_ALL_PREFIXES(FlashCacheTest, 62 FRIEND_TEST_ALL_PREFIXES(FlashCacheTest,
63 LogStructuredStoreInUseSegmentIsSkipped); 63 LogStoreInUseSegmentIsSkipped);
64 FRIEND_TEST_ALL_PREFIXES(FlashCacheTest, 64 FRIEND_TEST_ALL_PREFIXES(FlashCacheTest,
65 LogStructuredStoreReadFromCurrentAfterClose); 65 LogStoreReadFromCurrentAfterClose);
66 66
67 int32 GetNextSegmentIndex(); 67 int32 GetNextSegmentIndex();
68 bool InUse(int32 segment_index) const; 68 bool InUse(int32 segment_index) const;
69 69
70 Storage* storage_; 70 Storage* storage_;
71 71
72 int32 num_segments_; 72 int32 num_segments_;
73 73
74 // Currently open segments, either for reading or writing. There can only be 74 // Currently open segments, either for reading or writing. There can only be
75 // one segment open for writing, and multiple open for reading. 75 // one segment open for writing, and multiple open for reading.
(...skipping 11 matching lines...) Expand all
87 int32 current_entry_id_; 87 int32 current_entry_id_;
88 88
89 // Number of bytes left to be written to the entry identified by 89 // Number of bytes left to be written to the entry identified by
90 // |current_entry_id_|. Its value makes sense iff |current_entry_id_| is not 90 // |current_entry_id_|. Its value makes sense iff |current_entry_id_| is not
91 // -1. 91 // -1.
92 int32 current_entry_num_bytes_left_to_write_; 92 int32 current_entry_num_bytes_left_to_write_;
93 93
94 bool init_; // Init was called. 94 bool init_; // Init was called.
95 bool closed_; // Close was called. 95 bool closed_; // Close was called.
96 96
97 DISALLOW_COPY_AND_ASSIGN(LogStructuredStore); 97 DISALLOW_COPY_AND_ASSIGN(LogStore);
98 }; 98 };
99 99
100 } // namespace disk_cache 100 } // namespace disk_cache
101 101
102 #endif // NET_DISK_CACHE_FLASH_LOG_STRUCTURED_STORE_H_ 102 #endif // NET_DISK_CACHE_FLASH_LOG_STORE_H_
OLDNEW
« no previous file with comments | « net/disk_cache/flash/format.h ('k') | net/disk_cache/flash/log_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698