Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / net / tools / dump_cache / simple_cache_dumper.h
blobcc865a34b26c4723ea4d5fddc78fe9989091f065
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.
5 #ifndef NET_TOOLS_DUMP_CACHE_SIMPLE_CACHE_DUMPER_H_
6 #define NET_TOOLS_DUMP_CACHE_SIMPLE_CACHE_DUMPER_H_
8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread.h"
11 #include "net/base/completion_callback.h"
12 #include "net/disk_cache/disk_cache.h"
14 class DiskDumper;
16 namespace net {
18 class IOBufferWithSize;
20 // A class for dumping the contents of a disk cache to a series of text
21 // files. The files will contain the response headers, followed by the
22 // response body, as if the HTTP response were written directly to disk.
23 class SimpleCacheDumper {
24 public:
25 SimpleCacheDumper(base::FilePath input_path, base::FilePath output_path);
26 ~SimpleCacheDumper();
28 // Dumps the cache to disk. Returns OK if the operation was successful,
29 // and a net error code otherwise.
30 int Run();
32 private:
33 enum State {
34 STATE_NONE,
35 STATE_CREATE_CACHE,
36 STATE_CREATE_CACHE_COMPLETE,
37 STATE_OPEN_ENTRY,
38 STATE_OPEN_ENTRY_COMPLETE,
39 STATE_CREATE_ENTRY,
40 STATE_CREATE_ENTRY_COMPLETE,
41 STATE_READ_HEADERS,
42 STATE_READ_HEADERS_COMPLETE,
43 STATE_WRITE_HEADERS,
44 STATE_WRITE_HEADERS_COMPLETE,
45 STATE_READ_BODY,
46 STATE_READ_BODY_COMPLETE,
47 STATE_WRITE_BODY,
48 STATE_WRITE_BODY_COMPLETE,
49 STATE_DONE,
52 int DoLoop(int rv);
54 int DoCreateCache();
55 int DoCreateCacheComplete(int rv);
56 int DoOpenEntry();
57 int DoOpenEntryComplete(int rv);
58 int DoCreateEntry();
59 int DoCreateEntryComplete(int rv);
60 int DoReadHeaders();
61 int DoReadHeadersComplete(int rv);
62 int DoWriteHeaders();
63 int DoWriteHeadersComplete(int rv);
64 int DoReadBody();
65 int DoReadBodyComplete(int rv);
66 int DoWriteBody();
67 int DoWriteBodyComplete(int rv);
68 int DoDone();
70 void OnIOComplete(int rv);
72 State state_;
73 base::FilePath input_path_;
74 base::FilePath output_path_;
75 scoped_ptr<disk_cache::Backend> cache_;
76 scoped_ptr<DiskDumper> writer_;
77 base::Thread* cache_thread_;
78 scoped_ptr<disk_cache::Backend::Iterator> iter_;
79 disk_cache::Entry* src_entry_;
80 disk_cache::Entry* dst_entry_;
81 CompletionCallback io_callback_;
82 scoped_refptr<IOBufferWithSize> buf_;
83 int rv_;
85 DISALLOW_COPY_AND_ASSIGN(SimpleCacheDumper);
88 } // namespace net
90 #endif // NET_TOOLS_DUMP_CACHE_SIMPLE_CACHE_DUMPER_H_