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

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

Issue 270066: Step 2 in porting disk cache to using FilePath. (Closed)
Patch Set: deprecated 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
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/disk_cache/file_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 of the cache. 5 // See net/disk_cache/disk_cache.h for the public interface of the cache.
6 6
7 #ifndef NET_DISK_CACHE_FILE_H_ 7 #ifndef NET_DISK_CACHE_FILE_H_
8 #define NET_DISK_CACHE_FILE_H_ 8 #define NET_DISK_CACHE_FILE_H_
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
14 14
15 class FilePath;
16
15 namespace disk_cache { 17 namespace disk_cache {
16 18
17 // This interface is used to support asynchronous ReadData and WriteData calls. 19 // This interface is used to support asynchronous ReadData and WriteData calls.
18 class FileIOCallback { 20 class FileIOCallback {
19 public: 21 public:
20 // Notified of the actual number of bytes read or written. This value is 22 // Notified of the actual number of bytes read or written. This value is
21 // negative if an error occurred. 23 // negative if an error occurred.
22 virtual void OnFileIOComplete(int bytes_copied) = 0; 24 virtual void OnFileIOComplete(int bytes_copied) = 0;
23 25
24 virtual ~FileIOCallback() {} 26 virtual ~FileIOCallback() {}
25 }; 27 };
26 28
27 // Simple wrapper around a file that allows asynchronous operations. 29 // Simple wrapper around a file that allows asynchronous operations.
28 class File : public base::RefCounted<File> { 30 class File : public base::RefCounted<File> {
29 friend class base::RefCounted<File>; 31 friend class base::RefCounted<File>;
30 public: 32 public:
31 File() : init_(false), mixed_(false) {} 33 File() : init_(false), mixed_(false) {}
32 // mixed_mode set to true enables regular synchronous operations for the file. 34 // mixed_mode set to true enables regular synchronous operations for the file.
33 explicit File(bool mixed_mode) : init_(false), mixed_(mixed_mode) {} 35 explicit File(bool mixed_mode) : init_(false), mixed_(mixed_mode) {}
34 36
35 // Initializes the object to use the passed in file instead of opening it with 37 // Initializes the object to use the passed in file instead of opening it with
36 // the Init() call. No asynchronous operations can be performed with this 38 // the Init() call. No asynchronous operations can be performed with this
37 // object. 39 // object.
38 explicit File(base::PlatformFile file); 40 explicit File(base::PlatformFile file);
39 41
40 // Initializes the object to point to a given file. The file must aready exist 42 // Initializes the object to point to a given file. The file must aready exist
41 // on disk, and allow shared read and write. 43 // on disk, and allow shared read and write.
42 bool Init(const std::wstring& name); 44 bool Init(const FilePath& name);
43 45
44 // Returns the handle or file descriptor. 46 // Returns the handle or file descriptor.
45 base::PlatformFile platform_file() const; 47 base::PlatformFile platform_file() const;
46 48
47 // Returns true if the file was opened properly. 49 // Returns true if the file was opened properly.
48 bool IsValid() const; 50 bool IsValid() const;
49 51
50 // Performs synchronous IO. 52 // Performs synchronous IO.
51 bool Read(void* buffer, size_t buffer_len, size_t offset); 53 bool Read(void* buffer, size_t buffer_len, size_t offset);
52 bool Write(const void* buffer, size_t buffer_len, size_t offset); 54 bool Write(const void* buffer, size_t buffer_len, size_t offset);
(...skipping 30 matching lines...) Expand all
83 bool mixed_; 85 bool mixed_;
84 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. 86 base::PlatformFile platform_file_; // Regular, asynchronous IO handle.
85 base::PlatformFile sync_platform_file_; // Synchronous IO handle. 87 base::PlatformFile sync_platform_file_; // Synchronous IO handle.
86 88
87 DISALLOW_COPY_AND_ASSIGN(File); 89 DISALLOW_COPY_AND_ASSIGN(File);
88 }; 90 };
89 91
90 } // namespace disk_cache 92 } // namespace disk_cache
91 93
92 #endif // NET_DISK_CACHE_FILE_H_ 94 #endif // NET_DISK_CACHE_FILE_H_
OLDNEW
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/disk_cache/file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698