OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ | 5 #ifndef NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ |
6 #define NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ | 6 #define NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Close the current entry. | 40 // Close the current entry. |
41 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 41 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, |
42 base::Time last_modified) = 0; | 42 base::Time last_modified) = 0; |
43 }; | 43 }; |
44 | 44 |
45 // Writes data to a cache. | 45 // Writes data to a cache. |
46 class CacheDumper : public CacheDumpWriter { | 46 class CacheDumper : public CacheDumpWriter { |
47 public: | 47 public: |
48 explicit CacheDumper(disk_cache::Backend* cache); | 48 explicit CacheDumper(disk_cache::Backend* cache); |
49 | 49 |
50 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, | 50 int CreateEntry(const std::string& key, |
51 const net::CompletionCallback& callback) override; | 51 disk_cache::Entry** entry, |
52 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, | 52 const net::CompletionCallback& callback) override; |
53 net::IOBuffer* buf, int buf_len, | 53 int WriteEntry(disk_cache::Entry* entry, |
54 const net::CompletionCallback& callback) override; | 54 int stream, |
55 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 55 int offset, |
56 base::Time last_modified) override; | 56 net::IOBuffer* buf, |
| 57 int buf_len, |
| 58 const net::CompletionCallback& callback) override; |
| 59 void CloseEntry(disk_cache::Entry* entry, |
| 60 base::Time last_used, |
| 61 base::Time last_modified) override; |
57 | 62 |
58 private: | 63 private: |
59 disk_cache::Backend* cache_; | 64 disk_cache::Backend* cache_; |
60 }; | 65 }; |
61 | 66 |
62 // Writes data to a disk. | 67 // Writes data to a disk. |
63 class DiskDumper : public CacheDumpWriter { | 68 class DiskDumper : public CacheDumpWriter { |
64 public: | 69 public: |
65 explicit DiskDumper(const base::FilePath& path); | 70 explicit DiskDumper(const base::FilePath& path); |
66 | 71 |
67 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, | 72 int CreateEntry(const std::string& key, |
68 const net::CompletionCallback& callback) override; | 73 disk_cache::Entry** entry, |
69 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, | 74 const net::CompletionCallback& callback) override; |
70 net::IOBuffer* buf, int buf_len, | 75 int WriteEntry(disk_cache::Entry* entry, |
71 const net::CompletionCallback& callback) override; | 76 int stream, |
72 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 77 int offset, |
73 base::Time last_modified) override; | 78 net::IOBuffer* buf, |
| 79 int buf_len, |
| 80 const net::CompletionCallback& callback) override; |
| 81 void CloseEntry(disk_cache::Entry* entry, |
| 82 base::Time last_used, |
| 83 base::Time last_modified) override; |
74 | 84 |
75 private: | 85 private: |
76 base::FilePath path_; | 86 base::FilePath path_; |
77 // This is a bit of a hack. As we get a CreateEntry, we coin the current | 87 // This is a bit of a hack. As we get a CreateEntry, we coin the current |
78 // entry_path_ where we write that entry to disk. Subsequent calls to | 88 // entry_path_ where we write that entry to disk. Subsequent calls to |
79 // WriteEntry() utilize this path for writing to disk. | 89 // WriteEntry() utilize this path for writing to disk. |
80 base::FilePath entry_path_; | 90 base::FilePath entry_path_; |
81 std::string entry_url_; | 91 std::string entry_url_; |
82 #ifdef WIN32_LARGE_FILENAME_SUPPORT | 92 #ifdef WIN32_LARGE_FILENAME_SUPPORT |
83 HANDLE entry_; | 93 HANDLE entry_; |
84 #else | 94 #else |
85 FILE* entry_; | 95 FILE* entry_; |
86 #endif | 96 #endif |
87 }; | 97 }; |
88 | 98 |
89 #endif // NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ | 99 #endif // NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ |
OLD | NEW |