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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h

Issue 287673004: [fsp] First part of support for reading files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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 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 CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF ACE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF ACE_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF ACE_H_ 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF ACE_H_
7 7
8 #include "base/callback.h"
9 #include "base/files/file.h"
10 #include "base/files/file_path.h"
8 #include "webkit/browser/fileapi/async_file_util.h" 11 #include "webkit/browser/fileapi/async_file_util.h"
9 12
10 class EventRouter; 13 class EventRouter;
11 14
12 namespace base { 15 namespace net {
13 class FilePath; 16 class IOBuffer;
14 } // namespace base 17 } // namespace net
15 18
16 namespace chromeos { 19 namespace chromeos {
17 namespace file_system_provider { 20 namespace file_system_provider {
18 21
19 class ProvidedFileSystemInfo; 22 class ProvidedFileSystemInfo;
20 class RequestManager; 23 class RequestManager;
21 24
22 // Interface for a provided file system. Acts as a proxy between providers 25 // Interface for a provided file system. Acts as a proxy between providers
23 // and clients. 26 // and clients.
24 // TODO(mtomasz): Add more methods once implemented. 27 // TODO(mtomasz): Add more methods once implemented.
25 class ProvidedFileSystemInterface { 28 class ProvidedFileSystemInterface {
26 public: 29 public:
27 typedef base::Callback<void(int file_handle, base::File::Error result)> 30 typedef base::Callback<void(int file_handle, base::File::Error result)>
28 OpenFileCallback; 31 OpenFileCallback;
29 32
33 typedef base::Callback<
34 void(int chunk_length, bool has_next, base::File::Error result)>
35 ReadChunkReceivedCallback;
36
30 // Mode of opening a file. Used by OpenFile(). 37 // Mode of opening a file. Used by OpenFile().
31 enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE }; 38 enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE };
32 39
33 virtual ~ProvidedFileSystemInterface() {} 40 virtual ~ProvidedFileSystemInterface() {}
34 41
35 // Requests unmounting of the file system. The callback is called when the 42 // Requests unmounting of the file system. The callback is called when the
36 // request is accepted or rejected, with an error code. 43 // request is accepted or rejected, with an error code.
37 virtual void RequestUnmount( 44 virtual void RequestUnmount(
38 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; 45 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
39 46
40 // Requests metadata of the passed |entry_path|. It can be either a file 47 // Requests metadata of the passed |entry_path|. It can be either a file
41 // or a directory. 48 // or a directory.
42 virtual void GetMetadata( 49 virtual void GetMetadata(
43 const base::FilePath& entry_path, 50 const base::FilePath& entry_path,
44 const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) = 0; 51 const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) = 0;
45 52
46 // Requests enumerating entries from the passed |directory_path|. The callback 53 // Requests enumerating entries from the passed |directory_path|. The callback
47 // can be called multiple times until either an error is returned or the 54 // can be called multiple times until |has_more| is set to false.
48 // has_more field is set to false.
49 virtual void ReadDirectory( 55 virtual void ReadDirectory(
50 const base::FilePath& directory_path, 56 const base::FilePath& directory_path,
51 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) = 0; 57 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) = 0;
52 58
53 // Requests opening a file at |file_path|. If |create| is set to true, it will 59 // Requests opening a file at |file_path|. If |create| is set to true, it will
54 // create a file and return success in case it didn't exist. 60 // create a file and return success in case it didn't exist.
55 virtual void OpenFile(const base::FilePath& file_path, 61 virtual void OpenFile(const base::FilePath& file_path,
56 OpenFileMode mode, 62 OpenFileMode mode,
57 bool create, 63 bool create,
58 const OpenFileCallback& callback) = 0; 64 const OpenFileCallback& callback) = 0;
59 65
60 // Requests closing a file, previously opened with OpenFile() as a file with 66 // Requests closing a file, previously opened with OpenFile() as a file with
61 // |file_handle|. For either succes or error |callback| must be called. 67 // |file_handle|. For either succes or error |callback| must be called.
62 virtual void CloseFile( 68 virtual void CloseFile(
63 int file_handle, 69 int file_handle,
64 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; 70 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
65 71
72 // Requests reading a file previously opened with |file_handle|. The callback
73 // can be called multiple times until |has_more| is set to false. On success
74 // it should return |length| bytes starting from |offset| in total. It can
75 // return less only in case EOF is encountered.
76 virtual void ReadFile(int file_handle,
77 net::IOBuffer* buffer,
78 int64 offset,
79 int length,
80 const ReadChunkReceivedCallback& callback) = 0;
81
66 // Returns a provided file system info for this file system. 82 // Returns a provided file system info for this file system.
67 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const = 0; 83 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const = 0;
68 84
69 // Returns a request manager for the file system. 85 // Returns a request manager for the file system.
70 virtual RequestManager* GetRequestManager() = 0; 86 virtual RequestManager* GetRequestManager() = 0;
71 }; 87 };
72 88
73 } // namespace file_system_provider 89 } // namespace file_system_provider
74 } // namespace chromeos 90 } // namespace chromeos
75 91
76 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INT ERFACE_H_ 92 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INT ERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698