OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_OPERATION_H_ |
6 #define WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_OPERATION_H_ |
7 | 7 |
8 #include "base/scoped_callback_factory.h" | 8 #include "base/scoped_callback_factory.h" |
9 #include "webkit/fileapi/file_system_operation.h" | 9 #include "webkit/fileapi/file_system_operation.h" |
10 #include "webkit/fileapi/file_system_types.h" | 10 #include "webkit/fileapi/file_system_types.h" |
11 | 11 |
12 namespace fileapi { | 12 namespace fileapi { |
13 | 13 |
14 class SandboxedFileSystemContext; | 14 class SandboxedFileSystemContext; |
15 | 15 |
16 // This class provides a 'sandboxed' access to the underlying file system, | 16 // This class provides a 'sandboxed' access to the underlying file system, |
17 // that is: | 17 // that is: |
18 // 1. provides OpenFileSystem method that returns a (hidden) root path | 18 // 1. provides OpenFileSystem method that returns a (hidden) root path |
19 // that is given by |file_system_context|. | 19 // that is given by |file_system_context|. |
20 // 2. enforces quota and file names/paths restrictions on each operation | 20 // 2. enforces quota and file names/paths restrictions on each operation |
21 // via |file_system_context|. | 21 // via |file_system_context|. |
22 class SandboxedFileSystemOperation : public FileSystemOperation { | 22 class SandboxedFileSystemOperation : public FileSystemOperation { |
23 public: | 23 public: |
24 // This class doesn't hold a reference or ownership of |file_system_context|. | 24 SandboxedFileSystemOperation( |
25 // It is the caller's responsibility to keep the pointer alive *until* | 25 FileSystemCallbackDispatcher* dispatcher, |
26 // it calls any of the operation methods. The |file_system_context| won't be | 26 scoped_refptr<base::MessageLoopProxy> proxy, |
27 // used in the callback path and can be deleted after the operation is | 27 scoped_refptr<SandboxedFileSystemContext> file_system_context); |
28 // made (e.g. after one of CreateFile, CreateDirectory, Copy, etc is called). | |
29 SandboxedFileSystemOperation(FileSystemCallbackDispatcher* dispatcher, | |
30 scoped_refptr<base::MessageLoopProxy> proxy, | |
31 SandboxedFileSystemContext* file_system_context); | |
32 virtual ~SandboxedFileSystemOperation(); | 28 virtual ~SandboxedFileSystemOperation(); |
33 | 29 |
34 void OpenFileSystem(const GURL& origin_url, | 30 void OpenFileSystem(const GURL& origin_url, |
35 fileapi::FileSystemType type, | 31 fileapi::FileSystemType type, |
36 bool create); | 32 bool create); |
37 | 33 |
38 // FileSystemOperation's methods. | 34 // FileSystemOperation's methods. |
39 virtual void CreateFile(const FilePath& path, | 35 virtual void CreateFile(const FilePath& path, |
40 bool exclusive); | 36 bool exclusive); |
41 virtual void CreateDirectory(const FilePath& path, | 37 virtual void CreateDirectory(const FilePath& path, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // In either case it returns false after firing DidFail. | 83 // In either case it returns false after firing DidFail. |
88 // If |create| flag is true this also checks if the |path| contains | 84 // If |create| flag is true this also checks if the |path| contains |
89 // any restricted names and chars. If it does, the call fires dispatcher's | 85 // any restricted names and chars. If it does, the call fires dispatcher's |
90 // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. | 86 // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. |
91 // (Note: this doesn't delete this when it calls DidFail and returns false; | 87 // (Note: this doesn't delete this when it calls DidFail and returns false; |
92 // it's the caller's responsibility.) | 88 // it's the caller's responsibility.) |
93 bool VerifyFileSystemPathForWrite(const FilePath& path, | 89 bool VerifyFileSystemPathForWrite(const FilePath& path, |
94 bool create, | 90 bool create, |
95 int64 growth); | 91 int64 growth); |
96 | 92 |
97 // Not owned. See the comment at the constructor. | 93 scoped_refptr<SandboxedFileSystemContext> file_system_context_; |
98 SandboxedFileSystemContext* file_system_context_; | |
99 | 94 |
100 base::ScopedCallbackFactory<SandboxedFileSystemOperation> callback_factory_; | 95 base::ScopedCallbackFactory<SandboxedFileSystemOperation> callback_factory_; |
101 | 96 |
102 DISALLOW_COPY_AND_ASSIGN(SandboxedFileSystemOperation); | 97 DISALLOW_COPY_AND_ASSIGN(SandboxedFileSystemOperation); |
103 }; | 98 }; |
104 | 99 |
105 } // namespace fileapi | 100 } // namespace fileapi |
106 | 101 |
107 #endif // WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_OPERATION_H_ | 102 #endif // WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_OPERATION_H_ |
OLD | NEW |