| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 5 #ifndef WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
| 6 #define WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 6 #define WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "webkit/fileapi/file_system_url.h" | 11 #include "webkit/fileapi/file_system_url.h" |
| 12 #include "webkit/fileapi/fileapi_export.h" | 12 #include "webkit/storage/webkit_storage_export.h" |
| 13 | 13 |
| 14 namespace fileapi { | 14 namespace fileapi { |
| 15 | 15 |
| 16 // Registers a syncable filesystem with the given |service_name|. | 16 // Registers a syncable filesystem with the given |service_name|. |
| 17 FILEAPI_EXPORT bool RegisterSyncableFileSystem(const std::string& service_name); | 17 WEBKIT_STORAGE_EXPORT bool RegisterSyncableFileSystem( |
| 18 const std::string& service_name); |
| 18 | 19 |
| 19 // Revokes the syncable filesystem that was registered with |service_name|. | 20 // Revokes the syncable filesystem that was registered with |service_name|. |
| 20 FILEAPI_EXPORT bool RevokeSyncableFileSystem(const std::string& service_name); | 21 WEBKIT_STORAGE_EXPORT bool RevokeSyncableFileSystem( |
| 22 const std::string& service_name); |
| 21 | 23 |
| 22 // Returns the root URI of the syncable filesystem that can be specified by a | 24 // Returns the root URI of the syncable filesystem that can be specified by a |
| 23 // pair of |origin| and |service_name|. | 25 // pair of |origin| and |service_name|. |
| 24 FILEAPI_EXPORT GURL GetSyncableFileSystemRootURI( | 26 WEBKIT_STORAGE_EXPORT GURL GetSyncableFileSystemRootURI( |
| 25 const GURL& origin, const std::string& service_name); | 27 const GURL& origin, const std::string& service_name); |
| 26 | 28 |
| 27 // Creates a FileSystem URL for the |path| in a syncable filesystem | 29 // Creates a FileSystem URL for the |path| in a syncable filesystem |
| 28 // identifiable by a pair of |origin| and |service_name|. | 30 // identifiable by a pair of |origin| and |service_name|. |
| 29 // | 31 // |
| 30 // Example: Assume following arguments are given: | 32 // Example: Assume following arguments are given: |
| 31 // origin: 'http://www.example.com/', | 33 // origin: 'http://www.example.com/', |
| 32 // service_name: 'service_name', | 34 // service_name: 'service_name', |
| 33 // path: '/foo/bar', | 35 // path: '/foo/bar', |
| 34 // returns 'filesystem:http://www.example.com/external/service_name/foo/bar' | 36 // returns 'filesystem:http://www.example.com/external/service_name/foo/bar' |
| 35 FILEAPI_EXPORT FileSystemURL CreateSyncableFileSystemURL( | 37 WEBKIT_STORAGE_EXPORT FileSystemURL CreateSyncableFileSystemURL( |
| 36 const GURL& origin, const std::string& service_name, const FilePath& path); | 38 const GURL& origin, const std::string& service_name, const FilePath& path); |
| 37 | 39 |
| 38 // Serializes a given FileSystemURL |url| and sets the serialized string to | 40 // Serializes a given FileSystemURL |url| and sets the serialized string to |
| 39 // |serialized_url|. If the URL does not represent a syncable filesystem, | 41 // |serialized_url|. If the URL does not represent a syncable filesystem, |
| 40 // |serialized_url| is not filled in, and returns false. Separators of the | 42 // |serialized_url| is not filled in, and returns false. Separators of the |
| 41 // path will be normalized depending on its platform. | 43 // path will be normalized depending on its platform. |
| 42 // | 44 // |
| 43 // Example: Assume a following FileSystemURL object is given: | 45 // Example: Assume a following FileSystemURL object is given: |
| 44 // origin() returns 'http://www.example.com/', | 46 // origin() returns 'http://www.example.com/', |
| 45 // type() returns the kFileSystemTypeSyncable, | 47 // type() returns the kFileSystemTypeSyncable, |
| 46 // filesystem_id() returns 'service_name', | 48 // filesystem_id() returns 'service_name', |
| 47 // path() returns '/foo/bar', | 49 // path() returns '/foo/bar', |
| 48 // this URL will be serialized to | 50 // this URL will be serialized to |
| 49 // (on Windows) | 51 // (on Windows) |
| 50 // 'filesystem:http://www.example.com/external/service_name/foo\\bar' | 52 // 'filesystem:http://www.example.com/external/service_name/foo\\bar' |
| 51 // (on others) | 53 // (on others) |
| 52 // 'filesystem:http://www.example.com/external/service_name/foo/bar' | 54 // 'filesystem:http://www.example.com/external/service_name/foo/bar' |
| 53 FILEAPI_EXPORT bool SerializeSyncableFileSystemURL( | 55 WEBKIT_STORAGE_EXPORT bool SerializeSyncableFileSystemURL( |
| 54 const FileSystemURL& url, std::string* serialized_url); | 56 const FileSystemURL& url, std::string* serialized_url); |
| 55 | 57 |
| 56 // Deserializes a serialized FileSystem URL string |serialized_url| and sets the | 58 // Deserializes a serialized FileSystem URL string |serialized_url| and sets the |
| 57 // deserialized value to |url|. If the reconstructed object is invalid or does | 59 // deserialized value to |url|. If the reconstructed object is invalid or does |
| 58 // not represent a syncable filesystem, returns false. | 60 // not represent a syncable filesystem, returns false. |
| 59 // | 61 // |
| 60 // NOTE: On any platform other than Windows, this function assumes that | 62 // NOTE: On any platform other than Windows, this function assumes that |
| 61 // |serialized_url| does not contain '\\'. If it contains '\\' on such | 63 // |serialized_url| does not contain '\\'. If it contains '\\' on such |
| 62 // platforms, '\\' may be replaced with '/' (It would not be an expected | 64 // platforms, '\\' may be replaced with '/' (It would not be an expected |
| 63 // behavior). | 65 // behavior). |
| 64 // | 66 // |
| 65 // See the comment of SerializeSyncableFileSystemURL() for more details. | 67 // See the comment of SerializeSyncableFileSystemURL() for more details. |
| 66 FILEAPI_EXPORT bool DeserializeSyncableFileSystemURL( | 68 WEBKIT_STORAGE_EXPORT bool DeserializeSyncableFileSystemURL( |
| 67 const std::string& serialized_url, FileSystemURL* url); | 69 const std::string& serialized_url, FileSystemURL* url); |
| 68 | 70 |
| 69 } // namespace fileapi | 71 } // namespace fileapi |
| 70 | 72 |
| 71 #endif // WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 73 #endif // WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
| OLD | NEW |