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

Unified Diff: net/disk_cache/v3/backend_work_item.h

Issue 15203004: Disk cache: Reference CL for the implementation of file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: IndexTable review Created 7 years, 1 month 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
« no previous file with comments | « net/disk_cache/v3/backend_impl_v3.cc ('k') | net/disk_cache/v3/backend_work_item.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/v3/backend_work_item.h
===================================================================
--- net/disk_cache/v3/backend_work_item.h (revision 0)
+++ net/disk_cache/v3/backend_work_item.h (revision 0)
@@ -0,0 +1,197 @@
+// 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_V3_BACKEND_WORK_ITEM_H_
+#define NET_DISK_CACHE_V3_BACKEND_WORK_ITEM_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "net/base/completion_callback.h"
+#include "net/base/io_buffer.h"
+#include "net/disk_cache/storage_block.h"
+#include "net/disk_cache/v3/backend_impl_v3.h"
+#include "net/disk_cache/v3/entry_impl_v3.h"
+#include "net/disk_cache/v3/index_table.h"
+
+namespace disk_cache {
+
+struct EntryRecord;
+struct EntrySet;
+struct IndexBitmap;
+struct IndexBucket;
+struct IndexHeaderV3;
+typedef StorageBlock<EntryRecord> CacheEntryBlockV3;
+typedef StorageBlock<ShortEntryRecord> CacheShortEntryBlock;
+
+struct InitResult {
+ IndexTableInitData index_data;
+ BlockFilesBitmaps block_bitmaps;
+ scoped_ptr<char[]> stats_data;
+};
+
+class BackendImplV3::WorkItem : public base::RefCountedThreadSafe<WorkItem> {
+ public:
+ enum WorkType {
+ WORK_INIT,
+ WORK_CLEANUP,
+ WORK_RESTART,
+ WORK_GROW_INDEX,
+ WORK_GROW_FILES,
+ WORK_WRITE_INDEX,
+ WORK_OPEN_ENTRY,
+ WORK_READ_DATA,
+ WORK_WRITE_DATA,
+ WORK_MOVE_DATA,
+ WORK_TRUNCATE,
+ WORK_DELETE,
+ WORK_CLOSE,
+ WORK_NONE
+ };
+
+ enum Flags {
+ WORK_FOR_DOOM = 1 << 0,
+ WORK_FOR_RESURRECT = 1 << 1,
+ WORK_FOR_EVICT = 1 << 2,
+ WORK_NO_COPY = 1 << 3, // Don't copy old data on eviction.
+ WORK_FOR_UPDATE = 1 << 4,
+ WORK_FOR_ITERATION = 1 << 5,
+ WORK_FOR_DOOM_RANGE = 1 << 6,
+ WORK_COMPLETE = 1 << 7
+ };
+
+ explicit WorkItem(WorkType type);
+
+ void Start(BackendImplV3::Worker* worker);
+ void DoLoop(int result);
+ void OnDone();
+
+
+ // Getters.
+ WorkType type() const { return type_; }
+ const net::CompletionCallback& user_callback() const {
+ return user_callback_;
+ }
+ int result() const { return result_; }
+ uint32 flags() const { return flags_; }
+ scoped_ptr<InitResult> init_result() { return init_result_.Pass(); }
+ EntrySet* entries() { return &entries_; }
+ const std::string& key() const { return key_; }
+ Entry** entry_buffer() { return entry_buffer_; }
+ scoped_ptr<EntryRecord> entry_record() { return entry_record_.Pass(); }
+ scoped_ptr<ShortEntryRecord> short_entry_record() {
+ return short_entry_record_.Pass();
+ }
+ EntryImplV3* owner_entry() { return owner_entry_.get(); }
+ base::Time initial_time() const { return initial_time_; }
+ base::Time end_time() const { return end_time_; }
+ IndexIterator* iterator() { return iterator_.get(); }
+ IndexIterator* ReleaseIterator() { return iterator_.release(); }
+ void** iter_buffer() const { return iter_buffer_; }
+
+ // Setters.
+ void set_user_callback(const net::CompletionCallback& callback) {
+ user_callback_ = callback;
+ }
+ void set_closure(const base::Callback<void(WorkItem*)>& closure) {
+ closure_ = closure;
+ }
+ void set_flags(uint32 flags) { flags_ = flags; }
+ void set_entries(EntrySet entries) { entries_ = entries; }
+ void set_key(const std::string& key) { key_ = key; }
+ void set_entry_buffer(Entry** entry_buffer) { entry_buffer_ = entry_buffer; }
+ void set_buffer(net::IOBuffer* buffer) { buffer_ = buffer; }
+ void set_buffer_len(int buffer_len) { buffer_len_ = buffer_len; }
+ void set_address(Addr address) { address_ = address; }
+ void set_address2(Addr address) { address2_ = address; }
+ void set_offset(int offset) { offset_ = offset; }
+ void set_owner_entry(EntryImplV3* entry) { owner_entry_ = entry; }
+ void set_initial_time(base::Time time) { initial_time_ = time; }
+ void set_end_time(base::Time time) { end_time_ = time; }
+ void set_iterator(scoped_ptr<IndexIterator> iterator) {
+ iterator_ = iterator.Pass();
+ }
+ void set_iter_buffer(void** iter) { iter_buffer_ = iter; }
+
+ private:
+ friend class base::RefCountedThreadSafe<WorkItem>;
+
+ enum State {
+ STATE_NONE,
+ STATE_OPEN_ENTRY,
+ STATE_OPEN_ENTRY_COMPLETE,
+ STATE_READ_KEY,
+ STATE_READ_KEY_COMPLETE,
+ STATE_READ_DATA,
+ STATE_READ_DATA_COMPLETE,
+ STATE_WRITE_DATA,
+ STATE_WRITE_DATA_COMPLETE,
+ STATE_MOVE_DATA,
+ STATE_TRUNCATE_DATA,
+ STATE_COPY_ENTRY,
+ STATE_COPY_ENTRY_COMPLETE
+ };
+
+ ~WorkItem();
+
+ void CompleteItem(int result);
+ int DoOpenEntry();
+ int DoOpenEntryComplete(int result);
+ int DoReadKey();
+ int DoReadKeyComplete();
+ int DoReadData();
+ int DoReadDataComplete(int result);
+ int DoWriteData();
+ int DoWriteDataComplete(int result);
+ int DoMoveData();
+ int DoTruncateData();
+ int DoCopyEntry();
+ int DoCopyEntryComplete(int result);
+
+ int LoadEntryBlock(Addr address);
+ int LoadShortEntryBlock(Addr address);
+
+ WorkType type_;
+ net::CompletionCallback user_callback_;
+ base::Callback<void(WorkItem*)> closure_;
+ int result_;
+ scoped_refptr<BackendImplV3::Worker> worker_;
+ State next_state_;
+
+ // Init.
+ uint32 flags_;
+ scoped_ptr<InitResult> init_result_;
+
+ // Open.
+ EntrySet entries_;
+ std::string key_;
+ Entry** entry_buffer_;
+ scoped_ptr<EntryRecord> entry_record_;
+ scoped_ptr<ShortEntryRecord> short_entry_record_;
+ scoped_ptr<CacheEntryBlockV3> entry_block_;
+ scoped_ptr<CacheShortEntryBlock> short_entry_block_;
+
+ // Read/Write.
+ scoped_refptr<net::IOBuffer> buffer_;
+ int buffer_len_;
+ Addr address_;
+ Addr address2_;
+ int offset_;
+ scoped_refptr<EntryImplV3> owner_entry_;
+
+ // Iteration.
+ base::Time initial_time_;
+ base::Time end_time_;
+ scoped_ptr<IndexIterator> iterator_;
+ void** iter_buffer_;
+
+ DISALLOW_COPY_AND_ASSIGN(WorkItem);
+};
+
+} // namespace disk_cache
+
+#endif // NET_DISK_CACHE_V3_BACKEND_WORK_ITEM_H_
Property changes on: net\disk_cache\v3\backend_work_item.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « net/disk_cache/v3/backend_impl_v3.cc ('k') | net/disk_cache/v3/backend_work_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698