Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: net/disk_cache/block_files.h

Issue 274012: Convert BlockFiles to use FilePath instead of wstring. (Closed)
Patch Set: rebase Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // See net/disk_cache/disk_cache.h for the public interface. 5 // See net/disk_cache/disk_cache.h for the public interface.
6 6
7 #ifndef NET_DISK_CACHE_BLOCK_FILES_H__ 7 #ifndef NET_DISK_CACHE_BLOCK_FILES_H__
8 #define NET_DISK_CACHE_BLOCK_FILES_H__ 8 #define NET_DISK_CACHE_BLOCK_FILES_H__
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/file_path.h"
12 #include "net/disk_cache/addr.h" 13 #include "net/disk_cache/addr.h"
13 #include "net/disk_cache/mapped_file.h" 14 #include "net/disk_cache/mapped_file.h"
14 #include "testing/gtest/include/gtest/gtest_prod.h" 15 #include "testing/gtest/include/gtest/gtest_prod.h"
15 16
16 namespace disk_cache { 17 namespace disk_cache {
17 18
18 class EntryImpl; 19 class EntryImpl;
19 20
20 // This class handles the set of block-files open by the disk cache. 21 // This class handles the set of block-files open by the disk cache.
21 class BlockFiles { 22 class BlockFiles {
22 public: 23 public:
23 explicit BlockFiles(const std::wstring& path) 24 explicit BlockFiles(const FilePath& path)
24 : init_(false), zero_buffer_(NULL), path_(path) {} 25 : init_(false), zero_buffer_(NULL), path_(path) {}
25 ~BlockFiles(); 26 ~BlockFiles();
26 27
27 // Performs the object initialization. create_files indicates if the backing 28 // Performs the object initialization. create_files indicates if the backing
28 // files should be created or just open. 29 // files should be created or just open.
29 bool Init(bool create_files); 30 bool Init(bool create_files);
30 31
31 // Returns the file that stores a given address. 32 // Returns the file that stores a given address.
32 MappedFile* GetFile(Addr address); 33 MappedFile* GetFile(Addr address);
33 34
(...skipping 28 matching lines...) Expand all
62 // Creates an empty block file and returns its index. 63 // Creates an empty block file and returns its index.
63 int CreateNextBlockFile(FileType block_type); 64 int CreateNextBlockFile(FileType block_type);
64 65
65 // Removes a chained block file that is now empty. 66 // Removes a chained block file that is now empty.
66 void RemoveEmptyFile(FileType block_type); 67 void RemoveEmptyFile(FileType block_type);
67 68
68 // Restores the header of a potentially inconsistent file. 69 // Restores the header of a potentially inconsistent file.
69 bool FixBlockFileHeader(MappedFile* file); 70 bool FixBlockFileHeader(MappedFile* file);
70 71
71 // Returns the filename for a given file index. 72 // Returns the filename for a given file index.
72 std::wstring Name(int index); 73 FilePath Name(int index);
73 74
74 bool init_; 75 bool init_;
75 char* zero_buffer_; // Buffer to speed-up cleaning deleted entries. 76 char* zero_buffer_; // Buffer to speed-up cleaning deleted entries.
76 std::wstring path_; // Path to the backing folder. 77 FilePath path_; // Path to the backing folder.
77 std::vector<MappedFile*> block_files_; // The actual files. 78 std::vector<MappedFile*> block_files_; // The actual files.
78 79
79 FRIEND_TEST(DiskCacheTest, BlockFiles_ZeroSizeFile); 80 FRIEND_TEST(DiskCacheTest, BlockFiles_ZeroSizeFile);
80 FRIEND_TEST(DiskCacheTest, BlockFiles_InvalidFile); 81 FRIEND_TEST(DiskCacheTest, BlockFiles_InvalidFile);
81 82
82 DISALLOW_EVIL_CONSTRUCTORS(BlockFiles); 83 DISALLOW_EVIL_CONSTRUCTORS(BlockFiles);
83 }; 84 };
84 85
85 } // namespace disk_cache 86 } // namespace disk_cache
86 87
87 #endif // NET_DISK_CACHE_BLOCK_FILES_H__ 88 #endif // NET_DISK_CACHE_BLOCK_FILES_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698