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 CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "webkit/browser/fileapi/file_system_url.h" | 12 #include "storage/browser/fileapi/file_system_url.h" |
13 | 13 |
14 namespace fileapi { | 14 namespace storage { |
15 class FileSystemContext; | 15 class FileSystemContext; |
16 class FileSystemURL; | 16 class FileSystemURL; |
17 } | 17 } |
18 | 18 |
19 namespace tracked_objects { | 19 namespace tracked_objects { |
20 class Location; | 20 class Location; |
21 } | 21 } |
22 | 22 |
23 namespace sync_file_system { | 23 namespace sync_file_system { |
24 | 24 |
25 // Registers a syncable filesystem. | 25 // Registers a syncable filesystem. |
26 void RegisterSyncableFileSystem(); | 26 void RegisterSyncableFileSystem(); |
27 | 27 |
28 // Revokes the syncable filesystem. | 28 // Revokes the syncable filesystem. |
29 void RevokeSyncableFileSystem(); | 29 void RevokeSyncableFileSystem(); |
30 | 30 |
31 // Returns the root URI of the syncable filesystem for |origin|. | 31 // Returns the root URI of the syncable filesystem for |origin|. |
32 GURL GetSyncableFileSystemRootURI(const GURL& origin); | 32 GURL GetSyncableFileSystemRootURI(const GURL& origin); |
33 | 33 |
34 // Creates a FileSystem URL for the |path| in a syncable filesystem for | 34 // Creates a FileSystem URL for the |path| in a syncable filesystem for |
35 // |origin|. | 35 // |origin|. |
36 // | 36 // |
37 // Example: Assume following arguments are given: | 37 // Example: Assume following arguments are given: |
38 // origin: 'http://www.example.com/', | 38 // origin: 'http://www.example.com/', |
39 // path: '/foo/bar', | 39 // path: '/foo/bar', |
40 // returns 'filesystem:http://www.example.com/external/syncfs/foo/bar' | 40 // returns 'filesystem:http://www.example.com/external/syncfs/foo/bar' |
41 fileapi::FileSystemURL | 41 storage::FileSystemURL CreateSyncableFileSystemURL(const GURL& origin, |
42 CreateSyncableFileSystemURL(const GURL& origin, const base::FilePath& path); | 42 const base::FilePath& path); |
43 | 43 |
44 // Creates a special filesystem URL for synchronizing |syncable_url|. | 44 // Creates a special filesystem URL for synchronizing |syncable_url|. |
45 fileapi::FileSystemURL CreateSyncableFileSystemURLForSync( | 45 storage::FileSystemURL CreateSyncableFileSystemURLForSync( |
46 fileapi::FileSystemContext* file_system_context, | 46 storage::FileSystemContext* file_system_context, |
47 const fileapi::FileSystemURL& syncable_url); | 47 const storage::FileSystemURL& syncable_url); |
48 | 48 |
49 // Serializes a given FileSystemURL |url| and sets the serialized string to | 49 // Serializes a given FileSystemURL |url| and sets the serialized string to |
50 // |serialized_url|. If the URL does not represent a syncable filesystem, | 50 // |serialized_url|. If the URL does not represent a syncable filesystem, |
51 // |serialized_url| is not filled in, and returns false. Separators of the | 51 // |serialized_url| is not filled in, and returns false. Separators of the |
52 // path will be normalized depending on its platform. | 52 // path will be normalized depending on its platform. |
53 // | 53 // |
54 // Example: Assume a following FileSystemURL object is given: | 54 // Example: Assume a following FileSystemURL object is given: |
55 // origin() returns 'http://www.example.com/', | 55 // origin() returns 'http://www.example.com/', |
56 // type() returns the kFileSystemTypeSyncable, | 56 // type() returns the kFileSystemTypeSyncable, |
57 // filesystem_id() returns 'syncfs', | 57 // filesystem_id() returns 'syncfs', |
58 // path() returns '/foo/bar', | 58 // path() returns '/foo/bar', |
59 // this URL will be serialized to | 59 // this URL will be serialized to |
60 // (on Windows) | 60 // (on Windows) |
61 // 'filesystem:http://www.example.com/external/syncfs/foo\\bar' | 61 // 'filesystem:http://www.example.com/external/syncfs/foo\\bar' |
62 // (on others) | 62 // (on others) |
63 // 'filesystem:http://www.example.com/external/syncfs/foo/bar' | 63 // 'filesystem:http://www.example.com/external/syncfs/foo/bar' |
64 bool SerializeSyncableFileSystemURL( | 64 bool SerializeSyncableFileSystemURL(const storage::FileSystemURL& url, |
65 const fileapi::FileSystemURL& url, std::string* serialized_url); | 65 std::string* serialized_url); |
66 | 66 |
67 // Deserializes a serialized FileSystem URL string |serialized_url| and sets the | 67 // Deserializes a serialized FileSystem URL string |serialized_url| and sets the |
68 // deserialized value to |url|. If the reconstructed object is invalid or does | 68 // deserialized value to |url|. If the reconstructed object is invalid or does |
69 // not represent a syncable filesystem, returns false. | 69 // not represent a syncable filesystem, returns false. |
70 // | 70 // |
71 // NOTE: On any platform other than Windows, this function assumes that | 71 // NOTE: On any platform other than Windows, this function assumes that |
72 // |serialized_url| does not contain '\\'. If it contains '\\' on such | 72 // |serialized_url| does not contain '\\'. If it contains '\\' on such |
73 // platforms, '\\' may be replaced with '/' (It would not be an expected | 73 // platforms, '\\' may be replaced with '/' (It would not be an expected |
74 // behavior). | 74 // behavior). |
75 // | 75 // |
76 // See the comment of SerializeSyncableFileSystemURL() for more details. | 76 // See the comment of SerializeSyncableFileSystemURL() for more details. |
77 bool DeserializeSyncableFileSystemURL( | 77 bool DeserializeSyncableFileSystemURL(const std::string& serialized_url, |
78 const std::string& serialized_url, fileapi::FileSystemURL* url); | 78 storage::FileSystemURL* url); |
79 | 79 |
80 // Returns true if V2 is enabled. | 80 // Returns true if V2 is enabled. |
81 bool IsV2Enabled(); | 81 bool IsV2Enabled(); |
82 | 82 |
83 // Returns true if the given |origin| is supposed to run in V2 mode. | 83 // Returns true if the given |origin| is supposed to run in V2 mode. |
84 bool IsV2EnabledForOrigin(const GURL& origin); | 84 bool IsV2EnabledForOrigin(const GURL& origin); |
85 | 85 |
86 // Returns SyncFileSystem sub-directory path. | 86 // Returns SyncFileSystem sub-directory path. |
87 base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir); | 87 base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir); |
88 | 88 |
(...skipping 11 matching lines...) Expand all Loading... |
100 | 100 |
101 // Posts |callback| to the current thread. | 101 // Posts |callback| to the current thread. |
102 void RunSoon(const tracked_objects::Location& from_here, | 102 void RunSoon(const tracked_objects::Location& from_here, |
103 const base::Closure& callback); | 103 const base::Closure& callback); |
104 | 104 |
105 base::Closure NoopClosure(); | 105 base::Closure NoopClosure(); |
106 | 106 |
107 } // namespace sync_file_system | 107 } // namespace sync_file_system |
108 | 108 |
109 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_ | 109 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_ |
OLD | NEW |