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

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

Issue 12847012: Adding disk_cache::Entry implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 7 years, 8 months 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
OLDNEW
(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_INTERNAL_ENTRY_H_
6 #define NET_DISK_CACHE_FLASH_INTERNAL_ENTRY_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/completion_callback.h"
13 #include "net/base/net_export.h"
14 #include "net/disk_cache/flash/format.h"
15
16 namespace net {
17
18 class IOBuffer;
19
20 } // namespace net
21
22 namespace disk_cache {
23
24 struct KeyAndStreamSizes {
25 KeyAndStreamSizes();
26 std::string key;
27 int stream_sizes[kFlashLogStoreEntryNumStreams];
28 };
29
30 class LogStore;
31 class LogStoreEntry;
32
33 // Actual entry implementation that does all the work of reading, writing and
34 // storing data. FlashEntryImpl contains a pair of InternalEntry objects, each
rvargas (doing something else) 2013/04/06 01:25:23 nit: don't document the caller of this code... com
agayev 2013/04/06 03:24:29 Done.
35 // living in a separate thread. Only one of these is used throughout the
36 // lifetime of FlashEntryImpl depending on whether it refers to a new entry or
37 // an old entry.
38 class NET_EXPORT_PRIVATE InternalEntry
39 : public base::RefCountedThreadSafe<InternalEntry> {
40 friend class base::RefCountedThreadSafe<InternalEntry>;
41 public:
42 InternalEntry(const std::string& key, LogStore* store);
43 InternalEntry(int32 id, LogStore* store);
44 ~InternalEntry();
45
46 scoped_ptr<KeyAndStreamSizes> Init();
47 int32 GetDataSize(int index) const;
48 int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len,
49 const net::CompletionCallback& callback);
50 int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len,
51 const net::CompletionCallback& callback);
52 void Close();
53
54 private:
55 bool WriteKey(LogStoreEntry* entry, const std::string& key);
56 bool ReadKey(LogStoreEntry* entry, std::string* key);
57
58 LogStore* store_;
59 scoped_ptr<LogStoreEntry> entry_;
60
61 DISALLOW_COPY_AND_ASSIGN(InternalEntry);
62 };
63
64 } // namespace disk_cache
65
66 #endif // NET_DISK_CACHE_FLASH_INTERNAL_ENTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698