Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 BASE_FILES_FILE_PROXY_H_ | 5 #ifndef BASE_FILES_FILE_PROXY_H_ |
| 6 #define BASE_FILES_FILE_PROXY_H_ | 6 #define BASE_FILES_FILE_PROXY_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 bool CreateTemporary(uint32 additional_file_flags, | 81 bool CreateTemporary(uint32 additional_file_flags, |
| 82 const CreateTemporaryCallback& callback); | 82 const CreateTemporaryCallback& callback); |
| 83 | 83 |
| 84 // Returns true if the underlying |file_| is valid. | 84 // Returns true if the underlying |file_| is valid. |
| 85 bool IsValid() const; | 85 bool IsValid() const; |
| 86 | 86 |
| 87 // Returns true if a new file was created (or an old one truncated to zero | 87 // Returns true if a new file was created (or an old one truncated to zero |
| 88 // length to simulate a new file), and false otherwise. | 88 // length to simulate a new file), and false otherwise. |
| 89 bool created() const { return file_.created(); } | 89 bool created() const { return file_.created(); } |
| 90 | 90 |
| 91 // This object should not have a valid file_ when this method is called. | |
| 92 void SetFile(File file); | |
|
bbudge
2014/05/14 16:11:58
It seems logical to put this with the create funct
rvargas (doing something else)
2014/05/14 19:47:26
The only methods in between Create and this one ar
| |
| 93 | |
| 91 File TakeFile(); | 94 File TakeFile(); |
| 92 | 95 |
| 96 PlatformFile GetPlatformFile() const; | |
| 97 | |
| 93 // Proxies File::Close. The callback can be null. | 98 // Proxies File::Close. The callback can be null. |
| 94 // This returns false if task posting to |task_runner| has failed. | 99 // This returns false if task posting to |task_runner| has failed. |
| 95 bool Close(const StatusCallback& callback); | 100 bool Close(const StatusCallback& callback); |
| 96 | 101 |
| 97 // Proxies File::GetInfo. The callback can't be null. | 102 // Proxies File::GetInfo. The callback can't be null. |
| 98 // This returns false if task posting to |task_runner| has failed. | 103 // This returns false if task posting to |task_runner| has failed. |
| 99 bool GetInfo(const GetFileInfoCallback& callback); | 104 bool GetInfo(const GetFileInfoCallback& callback); |
| 100 | 105 |
| 101 // Proxies File::Read. The callback can't be null. | 106 // Proxies File::Read. The callback can't be null. |
| 102 // This returns false if |bytes_to_read| is less than zero, or | 107 // This returns false if |bytes_to_read| is less than zero, or |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 120 // Proxies File::SetLength. The callback can be null. | 125 // Proxies File::SetLength. The callback can be null. |
| 121 // This returns false if task posting to |task_runner| has failed. | 126 // This returns false if task posting to |task_runner| has failed. |
| 122 bool SetLength(int64 length, const StatusCallback& callback); | 127 bool SetLength(int64 length, const StatusCallback& callback); |
| 123 | 128 |
| 124 // Proxies File::Flush. The callback can be null. | 129 // Proxies File::Flush. The callback can be null. |
| 125 // This returns false if task posting to |task_runner| has failed. | 130 // This returns false if task posting to |task_runner| has failed. |
| 126 bool Flush(const StatusCallback& callback); | 131 bool Flush(const StatusCallback& callback); |
| 127 | 132 |
| 128 private: | 133 private: |
| 129 friend class FileHelper; | 134 friend class FileHelper; |
| 130 void SetFile(File file); | |
| 131 TaskRunner* task_runner() { return task_runner_.get(); } | 135 TaskRunner* task_runner() { return task_runner_.get(); } |
| 132 | 136 |
| 133 scoped_refptr<TaskRunner> task_runner_; | 137 scoped_refptr<TaskRunner> task_runner_; |
| 134 File file_; | 138 File file_; |
| 135 DISALLOW_COPY_AND_ASSIGN(FileProxy); | 139 DISALLOW_COPY_AND_ASSIGN(FileProxy); |
| 136 }; | 140 }; |
| 137 | 141 |
| 138 } // namespace base | 142 } // namespace base |
| 139 | 143 |
| 140 #endif // BASE_FILES_FILE_PROXY_H_ | 144 #endif // BASE_FILES_FILE_PROXY_H_ |
| OLD | NEW |