| 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 // 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_export.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() {} | |
| 23 | |
| 24 // 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 |
| 25 // negative if an error occurred. | 23 // negative if an error occurred. |
| 26 virtual void OnFileIOComplete(int bytes_copied) = 0; | 24 virtual void OnFileIOComplete(int bytes_copied) = 0; |
| 25 |
| 26 protected: |
| 27 virtual ~FileIOCallback() {} |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 // Simple wrapper around a file that allows asynchronous operations. | 30 // Simple wrapper around a file that allows asynchronous operations. |
| 30 class NET_EXPORT_PRIVATE File : public base::RefCounted<File> { | 31 class NET_EXPORT_PRIVATE File : public base::RefCounted<File> { |
| 31 friend class base::RefCounted<File>; | 32 friend class base::RefCounted<File>; |
| 32 public: | 33 public: |
| 33 File(); | 34 File(); |
| 34 // mixed_mode set to true enables regular synchronous operations for the file. | 35 // mixed_mode set to true enables regular synchronous operations for the file. |
| 35 explicit File(bool mixed_mode); | 36 explicit File(bool mixed_mode); |
| 36 | 37 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 bool mixed_; | 85 bool mixed_; |
| 85 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. | 86 base::PlatformFile platform_file_; // Regular, asynchronous IO handle. |
| 86 base::PlatformFile sync_platform_file_; // Synchronous IO handle. | 87 base::PlatformFile sync_platform_file_; // Synchronous IO handle. |
| 87 | 88 |
| 88 DISALLOW_COPY_AND_ASSIGN(File); | 89 DISALLOW_COPY_AND_ASSIGN(File); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 } // namespace disk_cache | 92 } // namespace disk_cache |
| 92 | 93 |
| 93 #endif // NET_DISK_CACHE_FILE_H_ | 94 #endif // NET_DISK_CACHE_FILE_H_ |
| OLD | NEW |