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

Side by Side Diff: chrome/browser/chromeos/drive/file_system_interface.h

Issue 19596003: Remove CloseFile from FileSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_INTERFACE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_INTERFACE_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_INTERFACE_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_INTERFACE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 scoped_ptr<std::vector<SearchResultInfo> > result_paths)> SearchCallback; 91 scoped_ptr<std::vector<SearchResultInfo> > result_paths)> SearchCallback;
92 92
93 // Callback for SearchMetadata(). On success, |error| is FILE_ERROR_OK, and 93 // Callback for SearchMetadata(). On success, |error| is FILE_ERROR_OK, and
94 // |result| contains the search result. 94 // |result| contains the search result.
95 typedef base::Callback<void( 95 typedef base::Callback<void(
96 FileError error, 96 FileError error,
97 scoped_ptr<MetadataSearchResultVector> result)> SearchMetadataCallback; 97 scoped_ptr<MetadataSearchResultVector> result)> SearchMetadataCallback;
98 98
99 // Used to open files from the file system. |file_path| is the path on the local 99 // Used to open files from the file system. |file_path| is the path on the local
100 // file system for the opened file. 100 // file system for the opened file.
101 // If |close_callback| is not null, it must be called when the
102 // modification to the cache is done. Otherwise, Drive file system does not
103 // pick up the file for uploading.
104 // |close_callback| must not be called more than once.
101 typedef base::Callback<void(FileError error, 105 typedef base::Callback<void(FileError error,
102 const base::FilePath& file_path)> OpenFileCallback; 106 const base::FilePath& file_path,
107 const base::Closure& close_callback)>
108 OpenFileCallback;
103 109
104 // Used to get available space for the account from Drive. 110 // Used to get available space for the account from Drive.
105 typedef base::Callback<void(FileError error, 111 typedef base::Callback<void(FileError error,
106 int64 bytes_total, 112 int64 bytes_total,
107 int64 bytes_used)> GetAvailableSpaceCallback; 113 int64 bytes_used)> GetAvailableSpaceCallback;
108 114
109 // Used to get filesystem metadata. 115 // Used to get filesystem metadata.
110 typedef base::Callback<void(const FileSystemMetadata&)> 116 typedef base::Callback<void(const FileSystemMetadata&)>
111 GetFilesystemMetadataCallback; 117 GetFilesystemMetadataCallback;
112 118
119 // Used to mark cached files mounted.
120 typedef base::Callback<void(FileError error,
121 const base::FilePath& file_path)>
122 MarkMountedCallback;
123
113 // The mode of opening a file. 124 // The mode of opening a file.
114 enum OpenMode { 125 enum OpenMode {
115 // Open the file if exists. If not, failed. 126 // Open the file if exists. If not, failed.
116 OPEN_FILE, 127 OPEN_FILE,
117 128
118 // Create a new file if not exists, and then open it. If exists, failed. 129 // Create a new file if not exists, and then open it. If exists, failed.
119 CREATE_FILE, 130 CREATE_FILE,
120 131
121 // Open the file if exists. If not, create a new file and then open it. 132 // Open the file if exists. If not, create a new file and then open it.
122 OPEN_OR_CREATE_FILE, 133 OPEN_OR_CREATE_FILE,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 virtual void TransferFileFromLocalToRemote( 197 virtual void TransferFileFromLocalToRemote(
187 const base::FilePath& local_src_file_path, 198 const base::FilePath& local_src_file_path,
188 const base::FilePath& remote_dest_file_path, 199 const base::FilePath& remote_dest_file_path,
189 const FileOperationCallback& callback) = 0; 200 const FileOperationCallback& callback) = 0;
190 201
191 // Retrieves a file at the virtual path |file_path| on the Drive file system 202 // Retrieves a file at the virtual path |file_path| on the Drive file system
192 // onto the cache, and mark it dirty. The local path to the cache file is 203 // onto the cache, and mark it dirty. The local path to the cache file is
193 // returned to |callback|. After opening the file, both read and write 204 // returned to |callback|. After opening the file, both read and write
194 // on the file can be done with normal local file operations. 205 // on the file can be done with normal local file operations.
195 // 206 //
196 // |CloseFile| must be called when the modification to the cache is done.
197 // Otherwise, Drive file system does not pick up the file for uploading.
198 //
199 // |callback| must not be null. 207 // |callback| must not be null.
200 virtual void OpenFile(const base::FilePath& file_path, 208 virtual void OpenFile(const base::FilePath& file_path,
201 OpenMode open_mode, 209 OpenMode open_mode,
202 const OpenFileCallback& callback) = 0; 210 const OpenFileCallback& callback) = 0;
203 211
204 // Closes a file at the virtual path |file_path| on the Drive file system,
205 // which is opened via OpenFile(). It commits the dirty flag on the cache.
206 //
207 // |callback| must not be null.
208 virtual void CloseFile(const base::FilePath& file_path,
209 const FileOperationCallback& callback) = 0;
210
211 // Copies |src_file_path| to |dest_file_path| on the file system. 212 // Copies |src_file_path| to |dest_file_path| on the file system.
212 // |src_file_path| can be a hosted document (see limitations below). 213 // |src_file_path| can be a hosted document (see limitations below).
213 // |dest_file_path| is expected to be of the same type of |src_file_path| 214 // |dest_file_path| is expected to be of the same type of |src_file_path|
214 // (i.e. if |src_file_path| is a file, |dest_file_path| will be created as 215 // (i.e. if |src_file_path| is a file, |dest_file_path| will be created as
215 // a file). 216 // a file).
216 // 217 //
217 // This method also has the following assumptions/limitations that may be 218 // This method also has the following assumptions/limitations that may be
218 // relaxed or addressed later: 219 // relaxed or addressed later:
219 // - |src_file_path| cannot be a regular file (i.e. non-hosted document) 220 // - |src_file_path| cannot be a regular file (i.e. non-hosted document)
220 // or a directory. 221 // or a directory.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 384
384 // Returns miscellaneous metadata of the file system like the largest 385 // Returns miscellaneous metadata of the file system like the largest
385 // timestamp. Used in chrome:drive-internals. |callback| must not be null. 386 // timestamp. Used in chrome:drive-internals. |callback| must not be null.
386 virtual void GetMetadata( 387 virtual void GetMetadata(
387 const GetFilesystemMetadataCallback& callback) = 0; 388 const GetFilesystemMetadataCallback& callback) = 0;
388 389
389 // Marks the cached file as mounted, and runs |callback| upon completion. 390 // Marks the cached file as mounted, and runs |callback| upon completion.
390 // If succeeded, the cached file path will be passed to the |callback|. 391 // If succeeded, the cached file path will be passed to the |callback|.
391 // |callback| must not be null. 392 // |callback| must not be null.
392 virtual void MarkCacheFileAsMounted(const base::FilePath& drive_file_path, 393 virtual void MarkCacheFileAsMounted(const base::FilePath& drive_file_path,
393 const OpenFileCallback& callback) = 0; 394 const MarkMountedCallback& callback) = 0;
394 395
395 // Marks the cached file as unmounted, and runs |callback| upon completion. 396 // Marks the cached file as unmounted, and runs |callback| upon completion.
396 // Note that this method expects that the |cached_file_path| is the path 397 // Note that this method expects that the |cached_file_path| is the path
397 // returned by MarkCacheFileAsMounted(). 398 // returned by MarkCacheFileAsMounted().
398 // |callback| must not be null. 399 // |callback| must not be null.
399 virtual void MarkCacheFileAsUnmounted( 400 virtual void MarkCacheFileAsUnmounted(
400 const base::FilePath& cache_file_path, 401 const base::FilePath& cache_file_path,
401 const FileOperationCallback& callback) = 0; 402 const FileOperationCallback& callback) = 0;
402 403
403 // Gets the cache entry for file corresponding to |resource_id| and |md5| 404 // Gets the cache entry for file corresponding to |resource_id| and |md5|
404 // and runs |callback| with true and the found entry if the entry exists 405 // and runs |callback| with true and the found entry if the entry exists
405 // in the cache map. Otherwise, runs |callback| with false. 406 // in the cache map. Otherwise, runs |callback| with false.
406 // |md5| can be empty if only matching |resource_id| is desired. 407 // |md5| can be empty if only matching |resource_id| is desired.
407 // |callback| must not be null. 408 // |callback| must not be null.
408 virtual void GetCacheEntryByResourceId( 409 virtual void GetCacheEntryByResourceId(
409 const std::string& resource_id, 410 const std::string& resource_id,
410 const std::string& md5, 411 const std::string& md5,
411 const GetCacheEntryCallback& callback) = 0; 412 const GetCacheEntryCallback& callback) = 0;
412 413
413 // Reloads the resource metadata from the server. 414 // Reloads the resource metadata from the server.
414 virtual void Reload() = 0; 415 virtual void Reload() = 0;
415 }; 416 };
416 417
417 } // namespace drive 418 } // namespace drive
418 419
419 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_INTERFACE_H_ 420 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_INTERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698