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_FILE_SYSTEM_PATH_MANAGER_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ |
7 | 7 |
8 #include <map> | |
9 | |
10 #include "base/callback.h" | 8 #include "base/callback.h" |
11 #include "base/file_path.h" | 9 #include "base/file_path.h" |
12 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
13 #include "webkit/fileapi/file_system_types.h" | 11 #include "webkit/fileapi/file_system_types.h" |
14 | 12 |
15 class GURL; | 13 class GURL; |
16 | 14 |
17 namespace base { | 15 namespace base { |
18 class MessageLoopProxy; | 16 class MessageLoopProxy; |
19 } | 17 } |
20 | 18 |
21 namespace fileapi { | 19 namespace fileapi { |
22 | 20 |
| 21 // An interface to construct or crack sandboxed filesystem paths. |
| 22 // Currently each sandboxed filesystem path looks like: |
| 23 // |
| 24 // <profile_dir>/FileSystem/<origin_identifier>/<type>/chrome-<unique>/... |
| 25 // |
| 26 // where <type> is either one of "Temporary" or "Persistent". |
23 class FileSystemPathManager { | 27 class FileSystemPathManager { |
24 public: | 28 public: |
25 FileSystemPathManager(scoped_refptr<base::MessageLoopProxy> file_message_loop, | 29 FileSystemPathManager(scoped_refptr<base::MessageLoopProxy> file_message_loop, |
26 const FilePath& profile_path, | 30 const FilePath& profile_path, |
27 bool is_incognito, | 31 bool is_incognito, |
28 bool allow_file_access_from_files); | 32 bool allow_file_access_from_files); |
29 ~FileSystemPathManager(); | 33 ~FileSystemPathManager(); |
30 | 34 |
31 // Callback for GetFileSystemRootPath. | 35 // Callback for GetFileSystemRootPath. |
32 // If the request is accepted and the root filesystem for the origin exists | 36 // If the request is accepted and the root filesystem for the origin exists |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // The FileSystem directory name. | 71 // The FileSystem directory name. |
68 static const FilePath::CharType kFileSystemDirectory[]; | 72 static const FilePath::CharType kFileSystemDirectory[]; |
69 | 73 |
70 static const char kPersistentName[]; | 74 static const char kPersistentName[]; |
71 static const char kTemporaryName[]; | 75 static const char kTemporaryName[]; |
72 | 76 |
73 const FilePath& base_path() const { | 77 const FilePath& base_path() const { |
74 return base_path_; | 78 return base_path_; |
75 } | 79 } |
76 | 80 |
| 81 // Returns the filesystem name string for the given |origin_url| and |type|. |
| 82 static std::string GetFileSystemName(const GURL& url, |
| 83 fileapi::FileSystemType type); |
| 84 |
77 // Returns the storage identifier string for the given |url|. | 85 // Returns the storage identifier string for the given |url|. |
78 static std::string GetStorageIdentifierFromURL(const GURL& url); | 86 static std::string GetStorageIdentifierFromURL(const GURL& url); |
79 | 87 |
| 88 // Gets a base directory path of the sandboxed filesystem that is |
| 89 // specified by |origin_url| and |type|. |
| 90 // |base_path| must be pointing the FileSystem's data directory |
| 91 // under the profile directory, i.e. <profile_dir>/kFileSystemDirectory. |
| 92 // Returns an empty path if any of the given parameters are invalid. |
| 93 // Returned directory path does not contain 'unique' part, therefore |
| 94 // it is not an actural root path for the filesystem. |
| 95 static FilePath GetFileSystemBaseDirectoryForOriginAndType( |
| 96 const FilePath& base_path, |
| 97 const GURL& origin_url, |
| 98 fileapi::FileSystemType type); |
| 99 |
80 private: | 100 private: |
81 class GetFileSystemRootPathTask; | 101 class GetFileSystemRootPathTask; |
82 | 102 |
83 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 103 scoped_refptr<base::MessageLoopProxy> file_message_loop_; |
84 | 104 |
85 const FilePath base_path_; | 105 const FilePath base_path_; |
86 const bool is_incognito_; | 106 const bool is_incognito_; |
87 const bool allow_file_access_from_files_; | 107 const bool allow_file_access_from_files_; |
88 | 108 |
89 DISALLOW_COPY_AND_ASSIGN(FileSystemPathManager); | 109 DISALLOW_COPY_AND_ASSIGN(FileSystemPathManager); |
90 }; | 110 }; |
91 | 111 |
92 } // namespace fileapi | 112 } // namespace fileapi |
93 | 113 |
94 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ | 114 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ |
OLD | NEW |