OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "webkit/browser/fileapi/file_system_url.h" | 11 #include "webkit/browser/fileapi/file_system_url.h" |
12 #include "webkit/storage/webkit_storage_export.h" | 12 #include "webkit/browser/webkit_storage_browser_export.h" |
13 | 13 |
14 namespace fileapi { | 14 namespace fileapi { |
15 class FileSystemContext; | 15 class FileSystemContext; |
16 class FileSystemURL; | 16 class FileSystemURL; |
17 class LocalFileSystemOperation; | 17 class LocalFileSystemOperation; |
18 } | 18 } |
19 | 19 |
20 namespace sync_file_system { | 20 namespace sync_file_system { |
21 | 21 |
22 // Registers a syncable filesystem. | 22 // Registers a syncable filesystem. |
23 WEBKIT_STORAGE_EXPORT void RegisterSyncableFileSystem(); | 23 WEBKIT_STORAGE_BROWSER_EXPORT void RegisterSyncableFileSystem(); |
24 | 24 |
25 // Revokes the syncable filesystem. | 25 // Revokes the syncable filesystem. |
26 WEBKIT_STORAGE_EXPORT void RevokeSyncableFileSystem(); | 26 WEBKIT_STORAGE_BROWSER_EXPORT void RevokeSyncableFileSystem(); |
27 | 27 |
28 // Returns the root URI of the syncable filesystem for |origin|. | 28 // Returns the root URI of the syncable filesystem for |origin|. |
29 WEBKIT_STORAGE_EXPORT GURL GetSyncableFileSystemRootURI(const GURL& origin); | 29 WEBKIT_STORAGE_BROWSER_EXPORT GURL GetSyncableFileSystemRootURI( |
| 30 const GURL& origin); |
30 | 31 |
31 // Creates a FileSystem URL for the |path| in a syncable filesystem for | 32 // Creates a FileSystem URL for the |path| in a syncable filesystem for |
32 // |origin|. | 33 // |origin|. |
33 // | 34 // |
34 // Example: Assume following arguments are given: | 35 // Example: Assume following arguments are given: |
35 // origin: 'http://www.example.com/', | 36 // origin: 'http://www.example.com/', |
36 // path: '/foo/bar', | 37 // path: '/foo/bar', |
37 // returns 'filesystem:http://www.example.com/external/syncfs/foo/bar' | 38 // returns 'filesystem:http://www.example.com/external/syncfs/foo/bar' |
38 WEBKIT_STORAGE_EXPORT fileapi::FileSystemURL CreateSyncableFileSystemURL( | 39 WEBKIT_STORAGE_BROWSER_EXPORT fileapi::FileSystemURL |
39 const GURL& origin, const base::FilePath& path); | 40 CreateSyncableFileSystemURL(const GURL& origin, const base::FilePath& path); |
40 | 41 |
41 // Creates a special filesystem URL for synchronizing |syncable_url|. | 42 // Creates a special filesystem URL for synchronizing |syncable_url|. |
42 WEBKIT_STORAGE_EXPORT fileapi::FileSystemURL CreateSyncableFileSystemURLForSync( | 43 WEBKIT_STORAGE_BROWSER_EXPORT fileapi::FileSystemURL |
| 44 CreateSyncableFileSystemURLForSync( |
43 fileapi::FileSystemContext* file_system_context, | 45 fileapi::FileSystemContext* file_system_context, |
44 const fileapi::FileSystemURL& syncable_url); | 46 const fileapi::FileSystemURL& syncable_url); |
45 | 47 |
46 // Serializes a given FileSystemURL |url| and sets the serialized string to | 48 // Serializes a given FileSystemURL |url| and sets the serialized string to |
47 // |serialized_url|. If the URL does not represent a syncable filesystem, | 49 // |serialized_url|. If the URL does not represent a syncable filesystem, |
48 // |serialized_url| is not filled in, and returns false. Separators of the | 50 // |serialized_url| is not filled in, and returns false. Separators of the |
49 // path will be normalized depending on its platform. | 51 // path will be normalized depending on its platform. |
50 // | 52 // |
51 // Example: Assume a following FileSystemURL object is given: | 53 // Example: Assume a following FileSystemURL object is given: |
52 // origin() returns 'http://www.example.com/', | 54 // origin() returns 'http://www.example.com/', |
53 // type() returns the kFileSystemTypeSyncable, | 55 // type() returns the kFileSystemTypeSyncable, |
54 // filesystem_id() returns 'syncfs', | 56 // filesystem_id() returns 'syncfs', |
55 // path() returns '/foo/bar', | 57 // path() returns '/foo/bar', |
56 // this URL will be serialized to | 58 // this URL will be serialized to |
57 // (on Windows) | 59 // (on Windows) |
58 // 'filesystem:http://www.example.com/external/syncfs/foo\\bar' | 60 // 'filesystem:http://www.example.com/external/syncfs/foo\\bar' |
59 // (on others) | 61 // (on others) |
60 // 'filesystem:http://www.example.com/external/syncfs/foo/bar' | 62 // 'filesystem:http://www.example.com/external/syncfs/foo/bar' |
61 WEBKIT_STORAGE_EXPORT bool SerializeSyncableFileSystemURL( | 63 WEBKIT_STORAGE_BROWSER_EXPORT bool SerializeSyncableFileSystemURL( |
62 const fileapi::FileSystemURL& url, std::string* serialized_url); | 64 const fileapi::FileSystemURL& url, std::string* serialized_url); |
63 | 65 |
64 // Deserializes a serialized FileSystem URL string |serialized_url| and sets the | 66 // Deserializes a serialized FileSystem URL string |serialized_url| and sets the |
65 // deserialized value to |url|. If the reconstructed object is invalid or does | 67 // deserialized value to |url|. If the reconstructed object is invalid or does |
66 // not represent a syncable filesystem, returns false. | 68 // not represent a syncable filesystem, returns false. |
67 // | 69 // |
68 // NOTE: On any platform other than Windows, this function assumes that | 70 // NOTE: On any platform other than Windows, this function assumes that |
69 // |serialized_url| does not contain '\\'. If it contains '\\' on such | 71 // |serialized_url| does not contain '\\'. If it contains '\\' on such |
70 // platforms, '\\' may be replaced with '/' (It would not be an expected | 72 // platforms, '\\' may be replaced with '/' (It would not be an expected |
71 // behavior). | 73 // behavior). |
72 // | 74 // |
73 // See the comment of SerializeSyncableFileSystemURL() for more details. | 75 // See the comment of SerializeSyncableFileSystemURL() for more details. |
74 WEBKIT_STORAGE_EXPORT bool DeserializeSyncableFileSystemURL( | 76 WEBKIT_STORAGE_BROWSER_EXPORT bool DeserializeSyncableFileSystemURL( |
75 const std::string& serialized_url, fileapi::FileSystemURL* url); | 77 const std::string& serialized_url, fileapi::FileSystemURL* url); |
76 | 78 |
77 // Enables or disables directory operations in Sync FileSystem API. | 79 // Enables or disables directory operations in Sync FileSystem API. |
78 // TODO(nhiroki): This method should be used only for testing and should go | 80 // TODO(nhiroki): This method should be used only for testing and should go |
79 // away when we fully support directory operations. (http://crbug.com/161442) | 81 // away when we fully support directory operations. (http://crbug.com/161442) |
80 WEBKIT_STORAGE_EXPORT void SetEnableSyncFSDirectoryOperation(bool flag); | 82 WEBKIT_STORAGE_BROWSER_EXPORT void SetEnableSyncFSDirectoryOperation(bool flag); |
81 | 83 |
82 // Returns true if we allow directory operations in Sync FileSystem API. | 84 // Returns true if we allow directory operations in Sync FileSystem API. |
83 // It is disabled by default but can be overridden by a command-line switch | 85 // It is disabled by default but can be overridden by a command-line switch |
84 // (--enable-syncfs-directory-operations) or by calling | 86 // (--enable-syncfs-directory-operations) or by calling |
85 // SetEnableSyncFSDirectoryOperation(). | 87 // SetEnableSyncFSDirectoryOperation(). |
86 // TODO(nhiroki): This method should be used only for testing and should go | 88 // TODO(nhiroki): This method should be used only for testing and should go |
87 // away when we fully support directory operations. (http://crbug.com/161442) | 89 // away when we fully support directory operations. (http://crbug.com/161442) |
88 WEBKIT_STORAGE_EXPORT bool IsSyncFSDirectoryOperationEnabled(); | 90 WEBKIT_STORAGE_BROWSER_EXPORT bool IsSyncFSDirectoryOperationEnabled(); |
89 | 91 |
90 } // namespace sync_file_system | 92 } // namespace sync_file_system |
91 | 93 |
92 #endif // WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 94 #endif // WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
OLD | NEW |