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 #include "webkit/fileapi/syncable/syncable_file_system_util.h" | 5 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
6 | 6 |
7 #include "webkit/fileapi/external_mount_points.h" | 7 #include "webkit/fileapi/external_mount_points.h" |
8 #include "webkit/fileapi/file_observers.h" | 8 #include "webkit/fileapi/file_observers.h" |
9 #include "webkit/fileapi/file_system_context.h" | 9 #include "webkit/fileapi/file_system_context.h" |
10 #include "webkit/fileapi/file_system_util.h" | 10 #include "webkit/fileapi/file_system_util.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 const GURL url = GetFileSystemRootURI(origin, kFileSystemTypeExternal); | 27 const GURL url = GetFileSystemRootURI(origin, kFileSystemTypeExternal); |
28 const std::string path = service_name + "/"; | 28 const std::string path = service_name + "/"; |
29 url_canon::Replacements<char> replacements; | 29 url_canon::Replacements<char> replacements; |
30 replacements.SetPath(path.c_str(), url_parse::Component(0, path.length())); | 30 replacements.SetPath(path.c_str(), url_parse::Component(0, path.length())); |
31 return url.ReplaceComponents(replacements); | 31 return url.ReplaceComponents(replacements); |
32 } | 32 } |
33 | 33 |
34 FileSystemURL CreateSyncableFileSystemURL(const GURL& origin, | 34 FileSystemURL CreateSyncableFileSystemURL(const GURL& origin, |
35 const std::string& service_name, | 35 const std::string& service_name, |
36 const FilePath& path) { | 36 const FilePath& path) { |
37 return FileSystemURL(origin, | 37 FileSystemURL url(origin, |
38 kFileSystemTypeExternal, | 38 kFileSystemTypeExternal, |
39 FilePath::FromUTF8Unsafe(service_name).Append(path)); | 39 FilePath::FromUTF8Unsafe(service_name).Append(path)); |
| 40 return ExternalMountPoints::GetSystemInstance()->CrackURL(url); |
40 } | 41 } |
41 | 42 |
42 bool SerializeSyncableFileSystemURL(const FileSystemURL& url, | 43 bool SerializeSyncableFileSystemURL(const FileSystemURL& url, |
43 std::string* serialized_url) { | 44 std::string* serialized_url) { |
44 if (!url.is_valid() || url.type() != kFileSystemTypeSyncable) | 45 if (!url.is_valid() || url.type() != kFileSystemTypeSyncable) |
45 return false; | 46 return false; |
46 *serialized_url = | 47 *serialized_url = |
47 GetSyncableFileSystemRootURI(url.origin(), url.filesystem_id()).spec() + | 48 GetSyncableFileSystemRootURI(url.origin(), url.filesystem_id()).spec() + |
48 url.path().AsUTF8Unsafe(); | 49 url.path().AsUTF8Unsafe(); |
49 return true; | 50 return true; |
50 } | 51 } |
51 | 52 |
52 bool DeserializeSyncableFileSystemURL( | 53 bool DeserializeSyncableFileSystemURL( |
53 const std::string& serialized_url, FileSystemURL* url) { | 54 const std::string& serialized_url, FileSystemURL* url) { |
54 #if !defined(FILE_PATH_USES_WIN_SEPARATORS) | 55 #if !defined(FILE_PATH_USES_WIN_SEPARATORS) |
55 DCHECK(serialized_url.find('\\') == std::string::npos); | 56 DCHECK(serialized_url.find('\\') == std::string::npos); |
56 #endif // FILE_PATH_USES_WIN_SEPARATORS | 57 #endif // FILE_PATH_USES_WIN_SEPARATORS |
57 | 58 |
58 const FileSystemURL deserialized_url = FileSystemURL(GURL(serialized_url)); | 59 *url = ExternalMountPoints::GetSystemInstance()->CrackURL( |
59 if (!deserialized_url.is_valid() || | 60 FileSystemURL(GURL(serialized_url))); |
60 deserialized_url.type() != kFileSystemTypeSyncable) | 61 if (!url->is_valid() || url->type() != kFileSystemTypeSyncable) |
61 return false; | 62 return false; |
62 | |
63 *url = deserialized_url; | |
64 return true; | 63 return true; |
65 } | 64 } |
66 | 65 |
67 LocalFileSystemOperation* | 66 LocalFileSystemOperation* |
68 CreateFileSystemOperationForSync(FileSystemContext* file_system_context) { | 67 CreateFileSystemOperationForSync(FileSystemContext* file_system_context) { |
69 DCHECK(file_system_context); | 68 DCHECK(file_system_context); |
70 return file_system_context->sandbox_provider()-> | 69 return file_system_context->sandbox_provider()-> |
71 CreateFileSystemOperationForSync(file_system_context); | 70 CreateFileSystemOperationForSync(file_system_context); |
72 } | 71 } |
73 | 72 |
74 } // namespace fileapi | 73 } // namespace fileapi |
OLD | NEW |