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