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

Unified Diff: net/tools/dump_cache/simple_cache_dumper.h

Issue 11299239: Adding a simple class for dumping the contents of a cache. Use this new class in dump_cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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/tools/dump_cache/dump_files.cc ('k') | net/tools/dump_cache/simple_cache_dumper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/dump_cache/simple_cache_dumper.h
diff --git a/net/tools/dump_cache/simple_cache_dumper.h b/net/tools/dump_cache/simple_cache_dumper.h
new file mode 100644
index 0000000000000000000000000000000000000000..4a76529ccff0dfcb8b6729c64cb9f1e6f6ef008b
--- /dev/null
+++ b/net/tools/dump_cache/simple_cache_dumper.h
@@ -0,0 +1,94 @@
+// 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_TOOLS_DUMP_CACHE_SIMPLE_CACHE_DUMPER_H_
+#define NET_TOOLS_DUMP_CACHE_SIMPLE_CACHE_DUMPER_H_
+
+#include "base/file_path.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread.h"
+#include "net/base/completion_callback.h"
+
+class DiskDumper;
+
+namespace disk_cache {
+class Backend;
+class Entry;
+} // namespace disk_cache
+
+namespace net {
+
+class IOBufferWithSize;
+
+// A class for dumping the contents of a disk cache to a series of text
+// files. The files will contain the response headers, followed by the
+// response body, as if the HTTP response were written directly to disk.
+class SimpleCacheDumper {
+ public:
+ SimpleCacheDumper(FilePath input_path, FilePath output_path);
+ ~SimpleCacheDumper();
+
+ // Dumps the cache to disk. Returns OK if the operation was successful,
+ // and a net error code otherwise.
+ int Run();
+
+ private:
+ enum State {
+ STATE_NONE,
+ STATE_CREATE_CACHE,
+ STATE_CREATE_CACHE_COMPLETE,
+ STATE_OPEN_ENTRY,
+ STATE_OPEN_ENTRY_COMPLETE,
+ STATE_CREATE_ENTRY,
+ STATE_CREATE_ENTRY_COMPLETE,
+ STATE_READ_HEADERS,
+ STATE_READ_HEADERS_COMPLETE,
+ STATE_WRITE_HEADERS,
+ STATE_WRITE_HEADERS_COMPLETE,
+ STATE_READ_BODY,
+ STATE_READ_BODY_COMPLETE,
+ STATE_WRITE_BODY,
+ STATE_WRITE_BODY_COMPLETE,
+ STATE_DONE,
+ };
+
+ int DoLoop(int rv);
+
+ int DoCreateCache();
+ int DoCreateCacheComplete(int rv);
+ int DoOpenEntry();
+ int DoOpenEntryComplete(int rv);
+ int DoCreateEntry();
+ int DoCreateEntryComplete(int rv);
+ int DoReadHeaders();
+ int DoReadHeadersComplete(int rv);
+ int DoWriteHeaders();
+ int DoWriteHeadersComplete(int rv);
+ int DoReadBody();
+ int DoReadBodyComplete(int rv);
+ int DoWriteBody();
+ int DoWriteBodyComplete(int rv);
+ int DoDone();
+
+ void OnIOComplete(int rv);
+
+ State state_;
+ FilePath input_path_;
+ FilePath output_path_;
+ disk_cache::Backend* cache_;
+ scoped_ptr<DiskDumper> writer_;
+ base::Thread* cache_thread_;
+ void* iter_;
+ disk_cache::Entry* src_entry_;
+ disk_cache::Entry* dst_entry_;
+ CompletionCallback io_callback_;
+ scoped_refptr<IOBufferWithSize> buf_;
+ int rv_;
+
+ DISALLOW_COPY_AND_ASSIGN(SimpleCacheDumper);
+};
+
+} // namespace net
+
+#endif // NET_TOOLS_DUMP_CACHE_SIMPLE_CACHE_DUMPER_H_
« no previous file with comments | « net/tools/dump_cache/dump_files.cc ('k') | net/tools/dump_cache/simple_cache_dumper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698