Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / sync_file_system / syncable_file_system_util.h
blobd54217536832af8bb525af417aa8a32f3c0214e8
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "base/files/file_path.h"
12 #include "storage/browser/fileapi/file_system_url.h"
14 namespace storage {
15 class FileSystemContext;
16 class FileSystemURL;
19 namespace tracked_objects {
20 class Location;
23 namespace sync_file_system {
25 // Registers a syncable filesystem.
26 void RegisterSyncableFileSystem();
28 // Revokes the syncable filesystem.
29 void RevokeSyncableFileSystem();
31 // Returns the root URI of the syncable filesystem for |origin|.
32 GURL GetSyncableFileSystemRootURI(const GURL& origin);
34 // Creates a FileSystem URL for the |path| in a syncable filesystem for
35 // |origin|.
37 // Example: Assume following arguments are given:
38 // origin: 'http://www.example.com/',
39 // path: '/foo/bar',
40 // returns 'filesystem:http://www.example.com/external/syncfs/foo/bar'
41 storage::FileSystemURL CreateSyncableFileSystemURL(const GURL& origin,
42 const base::FilePath& path);
44 // Creates a special filesystem URL for synchronizing |syncable_url|.
45 storage::FileSystemURL CreateSyncableFileSystemURLForSync(
46 storage::FileSystemContext* file_system_context,
47 const storage::FileSystemURL& syncable_url);
49 // Serializes a given FileSystemURL |url| and sets the serialized string to
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
52 // path will be normalized depending on its platform.
54 // Example: Assume a following FileSystemURL object is given:
55 // origin() returns 'http://www.example.com/',
56 // type() returns the kFileSystemTypeSyncable,
57 // filesystem_id() returns 'syncfs',
58 // path() returns '/foo/bar',
59 // this URL will be serialized to
60 // (on Windows)
61 // 'filesystem:http://www.example.com/external/syncfs/foo\\bar'
62 // (on others)
63 // 'filesystem:http://www.example.com/external/syncfs/foo/bar'
64 bool SerializeSyncableFileSystemURL(const storage::FileSystemURL& url,
65 std::string* serialized_url);
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
69 // not represent a syncable filesystem, returns false.
71 // NOTE: On any platform other than Windows, this function assumes that
72 // |serialized_url| does not contain '\\'. If it contains '\\' on such
73 // platforms, '\\' may be replaced with '/' (It would not be an expected
74 // behavior).
76 // See the comment of SerializeSyncableFileSystemURL() for more details.
77 bool DeserializeSyncableFileSystemURL(const std::string& serialized_url,
78 storage::FileSystemURL* url);
80 // Returns SyncFileSystem sub-directory path.
81 base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir);
83 // Posts |callback| to the current thread.
84 void RunSoon(const tracked_objects::Location& from_here,
85 const base::Closure& callback);
87 base::Closure NoopClosure();
89 } // namespace sync_file_system
91 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNCABLE_FILE_SYSTEM_UTIL_H_