| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 // Creates an entry to be written. | 27 // Creates an entry to be written. |
| 28 // On success, populates the |entry|. | 28 // On success, populates the |entry|. |
| 29 // Returns a net error code. | 29 // Returns a net error code. |
| 30 virtual int CreateEntry(const std::string& key, | 30 virtual int CreateEntry(const std::string& key, |
| 31 disk_cache::Entry** entry, | 31 disk_cache::Entry** entry, |
| 32 const net::CompletionCallback& callback) = 0; | 32 const net::CompletionCallback& callback) = 0; |
| 33 | 33 |
| 34 // Write to the current entry. | 34 // Write to the current entry. |
| 35 // Returns a net error code. | 35 // Returns a net error code. |
| 36 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, | 36 virtual int WriteEntry(disk_cache::Entry* entry, |
| 37 net::IOBuffer* buf, int buf_len, | 37 int stream, |
| 38 int offset, |
| 39 net::IOBuffer* buf, |
| 40 int buf_len, |
| 38 const net::CompletionCallback& callback) = 0; | 41 const net::CompletionCallback& callback) = 0; |
| 39 | 42 |
| 40 // Close the current entry. | 43 // Close the current entry. |
| 41 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 44 virtual void CloseEntry(disk_cache::Entry* entry, |
| 45 base::Time last_used, |
| 42 base::Time last_modified) = 0; | 46 base::Time last_modified) = 0; |
| 43 }; | 47 }; |
| 44 | 48 |
| 45 // Writes data to a cache. | 49 // Writes data to a cache. |
| 46 class CacheDumper : public CacheDumpWriter { | 50 class CacheDumper : public CacheDumpWriter { |
| 47 public: | 51 public: |
| 48 explicit CacheDumper(disk_cache::Backend* cache); | 52 explicit CacheDumper(disk_cache::Backend* cache); |
| 49 | 53 |
| 50 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, | 54 virtual int CreateEntry(const std::string& key, |
| 55 disk_cache::Entry** entry, |
| 51 const net::CompletionCallback& callback) OVERRIDE; | 56 const net::CompletionCallback& callback) OVERRIDE; |
| 52 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, | 57 virtual int WriteEntry(disk_cache::Entry* entry, |
| 53 net::IOBuffer* buf, int buf_len, | 58 int stream, |
| 59 int offset, |
| 60 net::IOBuffer* buf, |
| 61 int buf_len, |
| 54 const net::CompletionCallback& callback) OVERRIDE; | 62 const net::CompletionCallback& callback) OVERRIDE; |
| 55 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 63 virtual void CloseEntry(disk_cache::Entry* entry, |
| 64 base::Time last_used, |
| 56 base::Time last_modified) OVERRIDE; | 65 base::Time last_modified) OVERRIDE; |
| 57 | 66 |
| 58 private: | 67 private: |
| 59 disk_cache::Backend* cache_; | 68 disk_cache::Backend* cache_; |
| 60 }; | 69 }; |
| 61 | 70 |
| 62 // Writes data to a disk. | 71 // Writes data to a disk. |
| 63 class DiskDumper : public CacheDumpWriter { | 72 class DiskDumper : public CacheDumpWriter { |
| 64 public: | 73 public: |
| 65 explicit DiskDumper(const base::FilePath& path); | 74 explicit DiskDumper(const base::FilePath& path); |
| 66 | 75 |
| 67 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, | 76 virtual int CreateEntry(const std::string& key, |
| 77 disk_cache::Entry** entry, |
| 68 const net::CompletionCallback& callback) OVERRIDE; | 78 const net::CompletionCallback& callback) OVERRIDE; |
| 69 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, | 79 virtual int WriteEntry(disk_cache::Entry* entry, |
| 70 net::IOBuffer* buf, int buf_len, | 80 int stream, |
| 81 int offset, |
| 82 net::IOBuffer* buf, |
| 83 int buf_len, |
| 71 const net::CompletionCallback& callback) OVERRIDE; | 84 const net::CompletionCallback& callback) OVERRIDE; |
| 72 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 85 virtual void CloseEntry(disk_cache::Entry* entry, |
| 86 base::Time last_used, |
| 73 base::Time last_modified) OVERRIDE; | 87 base::Time last_modified) OVERRIDE; |
| 74 | 88 |
| 75 private: | 89 private: |
| 76 base::FilePath path_; | 90 base::FilePath path_; |
| 77 // This is a bit of a hack. As we get a CreateEntry, we coin the current | 91 // 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 | 92 // entry_path_ where we write that entry to disk. Subsequent calls to |
| 79 // WriteEntry() utilize this path for writing to disk. | 93 // WriteEntry() utilize this path for writing to disk. |
| 80 base::FilePath entry_path_; | 94 base::FilePath entry_path_; |
| 81 std::string entry_url_; | 95 std::string entry_url_; |
| 82 #ifdef WIN32_LARGE_FILENAME_SUPPORT | 96 #ifdef WIN32_LARGE_FILENAME_SUPPORT |
| 83 HANDLE entry_; | 97 HANDLE entry_; |
| 84 #else | 98 #else |
| 85 FILE* entry_; | 99 FILE* entry_; |
| 86 #endif | 100 #endif |
| 87 }; | 101 }; |
| 88 | 102 |
| 89 #endif // NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ | 103 #endif // NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ |
| OLD | NEW |