| 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 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/files/file.h" | 11 #include "base/files/file.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "webkit/browser/fileapi/async_file_util.h" | 15 #include "webkit/browser/fileapi/async_file_util.h" |
| 15 | 16 |
| 16 class EventRouter; | 17 class EventRouter; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class Time; | 20 class Time; |
| 20 } // namespace base | 21 } // namespace base |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 // method in ProvidedFileSystemInterface. | 34 // method in ProvidedFileSystemInterface. |
| 34 struct EntryMetadata { | 35 struct EntryMetadata { |
| 35 EntryMetadata(); | 36 EntryMetadata(); |
| 36 ~EntryMetadata(); | 37 ~EntryMetadata(); |
| 37 | 38 |
| 38 bool is_directory; | 39 bool is_directory; |
| 39 std::string name; | 40 std::string name; |
| 40 int64 size; | 41 int64 size; |
| 41 base::Time modification_time; | 42 base::Time modification_time; |
| 42 std::string mime_type; | 43 std::string mime_type; |
| 44 std::string thumbnail; |
| 45 |
| 46 private: |
| 47 DISALLOW_COPY_AND_ASSIGN(EntryMetadata); |
| 43 }; | 48 }; |
| 44 | 49 |
| 45 // Interface for a provided file system. Acts as a proxy between providers | 50 // Interface for a provided file system. Acts as a proxy between providers |
| 46 // and clients. All of the request methods return an abort callback in order to | 51 // and clients. All of the request methods return an abort callback in order to |
| 47 // terminate it while running. They must be called on the same thread as the | 52 // terminate it while running. They must be called on the same thread as the |
| 48 // request methods. The cancellation callback may be null if the operation | 53 // request methods. The cancellation callback may be null if the operation |
| 49 // fails synchronously. | 54 // fails synchronously. |
| 50 class ProvidedFileSystemInterface { | 55 class ProvidedFileSystemInterface { |
| 51 public: | 56 public: |
| 57 // Mode of opening a file. Used by OpenFile(). |
| 58 enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE }; |
| 59 |
| 60 // Extra fields to be fetched with metadata. |
| 61 enum MetadataField { |
| 62 METADATA_FIELD_DEFAULT = 0, |
| 63 METADATA_FIELD_THUMBNAIL = 1 << 0 |
| 64 }; |
| 65 |
| 52 typedef base::Callback<void(int file_handle, base::File::Error result)> | 66 typedef base::Callback<void(int file_handle, base::File::Error result)> |
| 53 OpenFileCallback; | 67 OpenFileCallback; |
| 54 | 68 |
| 55 typedef base::Callback< | 69 typedef base::Callback< |
| 56 void(int chunk_length, bool has_more, base::File::Error result)> | 70 void(int chunk_length, bool has_more, base::File::Error result)> |
| 57 ReadChunkReceivedCallback; | 71 ReadChunkReceivedCallback; |
| 58 | 72 |
| 59 typedef base::Callback<void(const EntryMetadata& entry_metadata, | 73 typedef base::Callback<void(scoped_ptr<EntryMetadata> entry_metadata, |
| 60 base::File::Error result)> GetMetadataCallback; | 74 base::File::Error result)> GetMetadataCallback; |
| 61 | 75 |
| 62 typedef base::Callback<void( | 76 typedef base::Callback<void( |
| 63 const storage::AsyncFileUtil::StatusCallback& callback)> AbortCallback; | 77 const storage::AsyncFileUtil::StatusCallback& callback)> AbortCallback; |
| 64 | 78 |
| 65 // Mode of opening a file. Used by OpenFile(). | 79 // Mask of fields requested from the GetMetadata() call. |
| 66 enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE }; | 80 typedef int MetadataFieldMask; |
| 67 | 81 |
| 68 virtual ~ProvidedFileSystemInterface() {} | 82 virtual ~ProvidedFileSystemInterface() {} |
| 69 | 83 |
| 70 // Requests unmounting of the file system. The callback is called when the | 84 // Requests unmounting of the file system. The callback is called when the |
| 71 // request is accepted or rejected, with an error code. | 85 // request is accepted or rejected, with an error code. |
| 72 virtual AbortCallback RequestUnmount( | 86 virtual AbortCallback RequestUnmount( |
| 73 const storage::AsyncFileUtil::StatusCallback& callback) = 0; | 87 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
| 74 | 88 |
| 75 // Requests metadata of the passed |entry_path|. It can be either a file | 89 // Requests metadata of the passed |entry_path|. It can be either a file |
| 76 // or a directory. | 90 // or a directory. All |fields| will be returned if supported. Note, that |
| 91 // default fields are always returned. |
| 77 virtual AbortCallback GetMetadata(const base::FilePath& entry_path, | 92 virtual AbortCallback GetMetadata(const base::FilePath& entry_path, |
| 93 MetadataFieldMask fields, |
| 78 const GetMetadataCallback& callback) = 0; | 94 const GetMetadataCallback& callback) = 0; |
| 79 | 95 |
| 80 // Requests enumerating entries from the passed |directory_path|. The callback | 96 // Requests enumerating entries from the passed |directory_path|. The callback |
| 81 // can be called multiple times until |has_more| is set to false. | 97 // can be called multiple times until |has_more| is set to false. |
| 82 virtual AbortCallback ReadDirectory( | 98 virtual AbortCallback ReadDirectory( |
| 83 const base::FilePath& directory_path, | 99 const base::FilePath& directory_path, |
| 84 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) = 0; | 100 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) = 0; |
| 85 | 101 |
| 86 // Requests opening a file at |file_path|. If the file doesn't exist, then the | 102 // Requests opening a file at |file_path|. If the file doesn't exist, then the |
| 87 // operation will fail. | 103 // operation will fail. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 virtual RequestManager* GetRequestManager() = 0; | 178 virtual RequestManager* GetRequestManager() = 0; |
| 163 | 179 |
| 164 // Returns a weak pointer to this object. | 180 // Returns a weak pointer to this object. |
| 165 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() = 0; | 181 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() = 0; |
| 166 }; | 182 }; |
| 167 | 183 |
| 168 } // namespace file_system_provider | 184 } // namespace file_system_provider |
| 169 } // namespace chromeos | 185 } // namespace chromeos |
| 170 | 186 |
| 171 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INT
ERFACE_H_ | 187 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INT
ERFACE_H_ |
| OLD | NEW |