| 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/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 const net::CompletionCallback& callback) = 0; | 39 const net::CompletionCallback& callback) = 0; |
| 40 | 40 |
| 41 // Close the current entry. | 41 // Close the current entry. |
| 42 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 42 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, |
| 43 base::Time last_modified) = 0; | 43 base::Time last_modified) = 0; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Writes data to a cache. | 46 // Writes data to a cache. |
| 47 class CacheDumper : public CacheDumpWriter { | 47 class CacheDumper : public CacheDumpWriter { |
| 48 public: | 48 public: |
| 49 explicit CacheDumper(disk_cache::Backend* cache) : cache_(cache) {} | 49 explicit CacheDumper(disk_cache::Backend* cache); |
| 50 | 50 |
| 51 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, | 51 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, |
| 52 const net::CompletionCallback& callback); | 52 const net::CompletionCallback& callback) OVERRIDE; |
| 53 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, | 53 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, |
| 54 net::IOBuffer* buf, int buf_len, | 54 net::IOBuffer* buf, int buf_len, |
| 55 const net::CompletionCallback& callback); | 55 const net::CompletionCallback& callback) OVERRIDE; |
| 56 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 56 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, |
| 57 base::Time last_modified); | 57 base::Time last_modified) OVERRIDE; |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 disk_cache::Backend* cache_; | 60 disk_cache::Backend* cache_; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // Writes data to a disk. | 63 // Writes data to a disk. |
| 64 class DiskDumper : public CacheDumpWriter { | 64 class DiskDumper : public CacheDumpWriter { |
| 65 public: | 65 public: |
| 66 explicit DiskDumper(const FilePath& path) : path_(path), entry_(NULL) { | 66 explicit DiskDumper(const FilePath& path); |
| 67 file_util::CreateDirectory(path); | 67 |
| 68 } | |
| 69 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, | 68 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, |
| 70 const net::CompletionCallback& callback); | 69 const net::CompletionCallback& callback) OVERRIDE; |
| 71 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, | 70 virtual int WriteEntry(disk_cache::Entry* entry, int stream, int offset, |
| 72 net::IOBuffer* buf, int buf_len, | 71 net::IOBuffer* buf, int buf_len, |
| 73 const net::CompletionCallback& callback); | 72 const net::CompletionCallback& callback) OVERRIDE; |
| 74 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 73 virtual void CloseEntry(disk_cache::Entry* entry, base::Time last_used, |
| 75 base::Time last_modified); | 74 base::Time last_modified) OVERRIDE; |
| 76 | 75 |
| 77 private: | 76 private: |
| 78 FilePath path_; | 77 FilePath path_; |
| 79 // This is a bit of a hack. As we get a CreateEntry, we coin the current | 78 // This is a bit of a hack. As we get a CreateEntry, we coin the current |
| 80 // entry_path_ where we write that entry to disk. Subsequent calls to | 79 // entry_path_ where we write that entry to disk. Subsequent calls to |
| 81 // WriteEntry() utilize this path for writing to disk. | 80 // WriteEntry() utilize this path for writing to disk. |
| 82 FilePath entry_path_; | 81 FilePath entry_path_; |
| 83 std::string entry_url_; | 82 std::string entry_url_; |
| 84 #ifdef WIN32_LARGE_FILENAME_SUPPORT | 83 #ifdef WIN32_LARGE_FILENAME_SUPPORT |
| 85 HANDLE entry_; | 84 HANDLE entry_; |
| 86 #else | 85 #else |
| 87 FILE* entry_; | 86 FILE* entry_; |
| 88 #endif | 87 #endif |
| 89 }; | 88 }; |
| 90 | 89 |
| 91 #endif // NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ | 90 #endif // NET_TOOLS_DUMP_CACHE_CACHE_DUMPER_H_ |
| OLD | NEW |