OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 9 #pragma once |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "net/base/net_api.h" | 13 #include "net/base/net_export.h" |
14 | 14 |
15 class FilePath; | 15 class FilePath; |
16 | 16 |
17 namespace disk_cache { | 17 namespace disk_cache { |
18 | 18 |
19 // This interface is used to support asynchronous ReadData and WriteData calls. | 19 // This interface is used to support asynchronous ReadData and WriteData calls. |
20 class FileIOCallback { | 20 class FileIOCallback { |
21 public: | 21 public: |
22 virtual ~FileIOCallback() {} | 22 virtual ~FileIOCallback() {} |
23 | 23 |
24 // Notified of the actual number of bytes read or written. This value is | 24 // Notified of the actual number of bytes read or written. This value is |
25 // negative if an error occurred. | 25 // negative if an error occurred. |
26 virtual void OnFileIOComplete(int bytes_copied) = 0; | 26 virtual void OnFileIOComplete(int bytes_copied) = 0; |
27 }; | 27 }; |
28 | 28 |
29 // Simple wrapper around a file that allows asynchronous operations. | 29 // Simple wrapper around a file that allows asynchronous operations. |
30 class NET_TEST File : public base::RefCounted<File> { | 30 class NET_EXPORT_PRIVATE File : public base::RefCounted<File> { |
31 friend class base::RefCounted<File>; | 31 friend class base::RefCounted<File>; |
32 public: | 32 public: |
33 File(); | 33 File(); |
34 // 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. |
35 explicit File(bool mixed_mode); | 35 explicit File(bool mixed_mode); |
36 | 36 |
37 // 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 |
38 // the Init() call. No asynchronous operations can be performed with this | 38 // the Init() call. No asynchronous operations can be performed with this |
39 // object. | 39 // object. |
40 explicit File(base::PlatformFile file); | 40 explicit File(base::PlatformFile file); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 bool mixed_; | 81 bool mixed_; |
82 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. | 82 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. |
83 base::PlatformFile sync_platform_file_; // Synchronous IO handle. | 83 base::PlatformFile sync_platform_file_; // Synchronous IO handle. |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(File); | 85 DISALLOW_COPY_AND_ASSIGN(File); |
86 }; | 86 }; |
87 | 87 |
88 } // namespace disk_cache | 88 } // namespace disk_cache |
89 | 89 |
90 #endif // NET_DISK_CACHE_FILE_H_ | 90 #endif // NET_DISK_CACHE_FILE_H_ |
OLD | NEW |