| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_SUPPORT_SIMPLE_FILE_SYSTEM_H_ | |
| 6 #define WEBKIT_SUPPORT_SIMPLE_FILE_SYSTEM_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/files/scoped_temp_dir.h" | |
| 11 #include "base/id_map.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "third_party/WebKit/public/platform/WebFileSystem.h" | |
| 14 #include "third_party/WebKit/public/platform/WebFileSystemType.h" | |
| 15 #include "webkit/browser/fileapi/file_system_context.h" | |
| 16 #include "webkit/browser/fileapi/file_system_operation.h" | |
| 17 #include "webkit/common/fileapi/file_system_types.h" | |
| 18 | |
| 19 namespace WebKit { | |
| 20 class WebFileSystemCallbacks; | |
| 21 class WebFrame; | |
| 22 class WebURL; | |
| 23 } | |
| 24 | |
| 25 namespace fileapi { | |
| 26 class FileSystemContext; | |
| 27 class FileSystemURL; | |
| 28 } | |
| 29 | |
| 30 namespace webkit_blob { | |
| 31 class BlobStorageController; | |
| 32 } | |
| 33 | |
| 34 class SimpleFileSystem | |
| 35 : public WebKit::WebFileSystem, | |
| 36 public base::SupportsWeakPtr<SimpleFileSystem> { | |
| 37 public: | |
| 38 SimpleFileSystem(); | |
| 39 virtual ~SimpleFileSystem(); | |
| 40 | |
| 41 void OpenFileSystem(WebKit::WebFrame* frame, | |
| 42 WebKit::WebFileSystemType type, | |
| 43 long long size, | |
| 44 bool create, | |
| 45 WebKit::WebFileSystemCallbacks* callbacks); | |
| 46 void DeleteFileSystem(WebKit::WebFrame* frame, | |
| 47 WebKit::WebFileSystemType type, | |
| 48 WebKit::WebFileSystemCallbacks* callbacks); | |
| 49 | |
| 50 fileapi::FileSystemContext* file_system_context() { | |
| 51 return file_system_context_.get(); | |
| 52 } | |
| 53 | |
| 54 // WebKit::WebFileSystem implementation. | |
| 55 virtual void move( | |
| 56 const WebKit::WebURL& src_path, | |
| 57 const WebKit::WebURL& dest_path, | |
| 58 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 59 virtual void copy( | |
| 60 const WebKit::WebURL& src_path, | |
| 61 const WebKit::WebURL& dest_path, | |
| 62 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 63 virtual void remove( | |
| 64 const WebKit::WebURL& path, | |
| 65 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 66 virtual void removeRecursively( | |
| 67 const WebKit::WebURL& path, | |
| 68 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 69 virtual void readMetadata( | |
| 70 const WebKit::WebURL& path, | |
| 71 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 72 virtual void createFile( | |
| 73 const WebKit::WebURL& path, | |
| 74 bool exclusive, | |
| 75 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 76 virtual void createDirectory( | |
| 77 const WebKit::WebURL& path, | |
| 78 bool exclusive, | |
| 79 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 80 virtual void fileExists( | |
| 81 const WebKit::WebURL& path, | |
| 82 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 83 virtual void directoryExists( | |
| 84 const WebKit::WebURL& path, | |
| 85 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 86 virtual void readDirectory( | |
| 87 const WebKit::WebURL& path, | |
| 88 WebKit::WebFileSystemCallbacks*) OVERRIDE; | |
| 89 virtual WebKit::WebFileWriter* createFileWriter( | |
| 90 const WebKit::WebURL& path, WebKit::WebFileWriterClient*) OVERRIDE; | |
| 91 virtual void createSnapshotFileAndReadMetadata( | |
| 92 const WebKit::WebURL& path, | |
| 93 WebKit::WebFileSystemCallbacks* callbacks); | |
| 94 | |
| 95 static void InitializeOnIOThread( | |
| 96 webkit_blob::BlobStorageController* blob_storage_controller); | |
| 97 static void CleanupOnIOThread(); | |
| 98 | |
| 99 private: | |
| 100 // Helpers. | |
| 101 bool HasFilePermission(const fileapi::FileSystemURL& url, int permissions); | |
| 102 | |
| 103 // Callback Handlers | |
| 104 fileapi::FileSystemOperation::StatusCallback FinishHandler( | |
| 105 WebKit::WebFileSystemCallbacks* callbacks); | |
| 106 fileapi::FileSystemOperation::GetMetadataCallback GetMetadataHandler( | |
| 107 WebKit::WebFileSystemCallbacks* callbacks); | |
| 108 fileapi::FileSystemOperation::ReadDirectoryCallback | |
| 109 ReadDirectoryHandler(WebKit::WebFileSystemCallbacks* callbacks); | |
| 110 fileapi::FileSystemContext::OpenFileSystemCallback OpenFileSystemHandler( | |
| 111 WebKit::WebFileSystemCallbacks* callbacks); | |
| 112 fileapi::FileSystemContext::DeleteFileSystemCallback DeleteFileSystemHandler( | |
| 113 WebKit::WebFileSystemCallbacks* callbacks); | |
| 114 fileapi::FileSystemOperation::SnapshotFileCallback | |
| 115 SnapshotFileHandler(WebKit::WebFileSystemCallbacks* callbacks); | |
| 116 fileapi::FileSystemOperation::SnapshotFileCallback | |
| 117 SnapshotFileHandler_Deprecated( | |
| 118 const GURL& blob_url, | |
| 119 WebKit::WebFileSystemCallbacks* callbacks); | |
| 120 void DidFinish(WebKit::WebFileSystemCallbacks* callbacks, | |
| 121 base::PlatformFileError result); | |
| 122 void DidGetMetadata(WebKit::WebFileSystemCallbacks* callbacks, | |
| 123 base::PlatformFileError result, | |
| 124 const base::PlatformFileInfo& info); | |
| 125 void DidReadDirectory( | |
| 126 WebKit::WebFileSystemCallbacks* callbacks, | |
| 127 base::PlatformFileError result, | |
| 128 const std::vector<fileapi::DirectoryEntry>& entries, | |
| 129 bool has_more); | |
| 130 void DidOpenFileSystem(WebKit::WebFileSystemCallbacks* callbacks, | |
| 131 base::PlatformFileError result, | |
| 132 const std::string& name, const GURL& root); | |
| 133 void DidDeleteFileSystem(WebKit::WebFileSystemCallbacks* callbacks, | |
| 134 base::PlatformFileError result); | |
| 135 void DidCreateSnapshotFile( | |
| 136 WebKit::WebFileSystemCallbacks* callbacks, | |
| 137 base::PlatformFileError result, | |
| 138 const base::PlatformFileInfo& info, | |
| 139 const base::FilePath& platform_path, | |
| 140 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); | |
| 141 void DidCreateSnapshotFile_Deprecated( | |
| 142 const GURL& blob_url, | |
| 143 WebKit::WebFileSystemCallbacks* callbacks, | |
| 144 base::PlatformFileError result, | |
| 145 const base::PlatformFileInfo& info, | |
| 146 const base::FilePath& platform_path, | |
| 147 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); | |
| 148 | |
| 149 // A temporary directory for FileSystem API. | |
| 150 base::ScopedTempDir file_system_dir_; | |
| 151 | |
| 152 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | |
| 153 | |
| 154 DISALLOW_COPY_AND_ASSIGN(SimpleFileSystem); | |
| 155 }; | |
| 156 | |
| 157 #endif // WEBKIT_SUPPORT_SIMPLE_FILE_SYSTEM_H_ | |
| OLD | NEW |