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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/disk_cache/flash/internal_entry.h
diff --git a/net/disk_cache/flash/internal_entry.h b/net/disk_cache/flash/internal_entry.h
new file mode 100644
index 0000000000000000000000000000000000000000..4b61485c870bd9189ac946337be5a9c495698f9a
--- /dev/null
+++ b/net/disk_cache/flash/internal_entry.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_DISK_CACHE_FLASH_INTERNAL_ENTRY_H_
+#define NET_DISK_CACHE_FLASH_INTERNAL_ENTRY_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/base/completion_callback.h"
+#include "net/base/net_export.h"
+#include "net/disk_cache/flash/format.h"
+
+namespace net {
+
+class IOBuffer;
+
+} // namespace net
+
+namespace disk_cache {
+
+struct KeyAndStreamSizes {
+ KeyAndStreamSizes();
+ std::string key;
+ int stream_sizes[kFlashLogStoreEntryNumStreams];
+};
+
+class LogStore;
+class LogStoreEntry;
+
+// Actual entry implementation that does all the work of reading, writing and
+// 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.
+// living in a separate thread. Only one of these is used throughout the
+// lifetime of FlashEntryImpl depending on whether it refers to a new entry or
+// an old entry.
+class NET_EXPORT_PRIVATE InternalEntry
+ : public base::RefCountedThreadSafe<InternalEntry> {
+ friend class base::RefCountedThreadSafe<InternalEntry>;
+ public:
+ InternalEntry(const std::string& key, LogStore* store);
+ InternalEntry(int32 id, LogStore* store);
+ ~InternalEntry();
+
+ scoped_ptr<KeyAndStreamSizes> Init();
+ int32 GetDataSize(int index) const;
+ int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback);
+ int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback);
+ void Close();
+
+ private:
+ bool WriteKey(LogStoreEntry* entry, const std::string& key);
+ bool ReadKey(LogStoreEntry* entry, std::string* key);
+
+ LogStore* store_;
+ scoped_ptr<LogStoreEntry> entry_;
+
+ DISALLOW_COPY_AND_ASSIGN(InternalEntry);
+};
+
+} // namespace disk_cache
+
+#endif // NET_DISK_CACHE_FLASH_INTERNAL_ENTRY_H_

Powered by Google App Engine
This is Rietveld 408576698