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

Side by Side Diff: webkit/fileapi/file_system_util.cc

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup around ValidateFileSystemRoot Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_system_util.h" 5 #include "webkit/fileapi/file_system_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #if defined(OS_WIN) 89 #if defined(OS_WIN)
90 *file_path = FilePath(base::SysUTF8ToWide(path)). 90 *file_path = FilePath(base::SysUTF8ToWide(path)).
91 NormalizeWindowsPathSeparators().StripTrailingSeparators(); 91 NormalizeWindowsPathSeparators().StripTrailingSeparators();
92 #elif defined(OS_POSIX) 92 #elif defined(OS_POSIX)
93 *file_path = FilePath(path).StripTrailingSeparators(); 93 *file_path = FilePath(path).StripTrailingSeparators();
94 #endif 94 #endif
95 95
96 return true; 96 return true;
97 } 97 }
98 98
99 GURL GetFileSystemRootURI( 99 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) {
100 const GURL& origin_url, fileapi::FileSystemType type) {
101 std::string path("filesystem:"); 100 std::string path("filesystem:");
102 path += origin_url.spec(); 101 path += origin_url.spec();
103 switch (type) { 102 switch (type) {
104 case kFileSystemTypeTemporary: 103 case kFileSystemTypeTemporary:
105 path += (kTemporaryDir + 1); // We don't want the leading slash. 104 path += (kTemporaryDir + 1); // We don't want the leading slash.
106 break; 105 break;
107 case kFileSystemTypePersistent: 106 case kFileSystemTypePersistent:
108 path += (kPersistentDir + 1); // We don't want the leading slash. 107 path += (kPersistentDir + 1); // We don't want the leading slash.
109 break; 108 break;
110 case kFileSystemTypeExternal: 109 case kFileSystemTypeExternal:
111 path += (kExternalDir + 1); // We don't want the leading slash. 110 path += (kExternalDir + 1); // We don't want the leading slash.
112 break; 111 break;
113 default: 112 default:
114 NOTREACHED(); 113 NOTREACHED();
115 return GURL(); 114 return GURL();
116 } 115 }
117 return GURL(path); 116 return GURL(path);
118 } 117 }
119 118
119 std::string GetFileSystemName(const GURL& origin_url, FileSystemType type) {
120 std::string origin_identifier = GetOriginIdentifierFromURL(origin_url);
121 std::string type_string = GetFileSystemTypeString(type);
122 DCHECK(!type_string.empty());
123 return origin_identifier + ":" + type_string;
124 }
125
120 FileSystemType QuotaStorageTypeToFileSystemType( 126 FileSystemType QuotaStorageTypeToFileSystemType(
121 quota::StorageType storage_type) { 127 quota::StorageType storage_type) {
122 switch (storage_type) { 128 switch (storage_type) {
123 case quota::kStorageTypeTemporary: 129 case quota::kStorageTypeTemporary:
124 return kFileSystemTypeTemporary; 130 return kFileSystemTypeTemporary;
125 case quota::kStorageTypePersistent: 131 case quota::kStorageTypePersistent:
126 return kFileSystemTypePersistent; 132 return kFileSystemTypePersistent;
127 default: 133 default:
128 return kFileSystemTypeUnknown; 134 return kFileSystemTypeUnknown;
129 } 135 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return fileapi::kPersistentName; 176 return fileapi::kPersistentName;
171 case kFileSystemTypeExternal: 177 case kFileSystemTypeExternal:
172 return fileapi::kExternalName; 178 return fileapi::kExternalName;
173 case kFileSystemTypeUnknown: 179 case kFileSystemTypeUnknown:
174 default: 180 default:
175 return std::string(); 181 return std::string();
176 } 182 }
177 } 183 }
178 184
179 } // namespace fileapi 185 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698