Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: webkit/fileapi/syncable/syncable_file_system_util.cc

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test on Win Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 return ExternalMountPoints::GetSystemInstance()->CreateCrackedFileSystemURL(
38 kFileSystemTypeExternal, 38 origin,
39 FilePath::FromUTF8Unsafe(service_name).Append(path)); 39 kFileSystemTypeExternal,
40 FilePath::FromUTF8Unsafe(service_name).Append(path));
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 FileSystemURL deserialized =
59 if (!deserialized_url.is_valid() || 60 ExternalMountPoints::GetSystemInstance()->CrackURL(GURL(serialized_url));
60 deserialized_url.type() != kFileSystemTypeSyncable) 61 if (!deserialized.is_valid() ||
62 deserialized.type() != kFileSystemTypeSyncable) {
61 return false; 63 return false;
64 }
62 65
63 *url = deserialized_url; 66 *url = deserialized;
64 return true; 67 return true;
65 } 68 }
66 69
67 LocalFileSystemOperation* 70 LocalFileSystemOperation*
68 CreateFileSystemOperationForSync(FileSystemContext* file_system_context) { 71 CreateFileSystemOperationForSync(FileSystemContext* file_system_context) {
69 DCHECK(file_system_context); 72 DCHECK(file_system_context);
70 return file_system_context->sandbox_provider()-> 73 return file_system_context->sandbox_provider()->
71 CreateFileSystemOperationForSync(file_system_context); 74 CreateFileSystemOperationForSync(file_system_context);
72 } 75 }
73 76
74 } // namespace fileapi 77 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698