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

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

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 years, 4 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
« no previous file with comments | « webkit/common/fileapi/file_system_util.h ('k') | webkit/common/quota/quota_status_code.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/fileapi/file_system_util.h" 5 #include "webkit/common/fileapi/file_system_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "net/base/escape.h" 14 #include "net/base/escape.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 #include "webkit/common/database/database_identifier.h" 17 #include "webkit/common/database/database_identifier.h"
18 18
19 namespace fileapi { 19 namespace storage {
20 20
21 const char kPersistentDir[] = "/persistent"; 21 const char kPersistentDir[] = "/persistent";
22 const char kTemporaryDir[] = "/temporary"; 22 const char kTemporaryDir[] = "/temporary";
23 const char kIsolatedDir[] = "/isolated"; 23 const char kIsolatedDir[] = "/isolated";
24 const char kExternalDir[] = "/external"; 24 const char kExternalDir[] = "/external";
25 const char kTestDir[] = "/test"; 25 const char kTestDir[] = "/test";
26 26
27 const base::FilePath::CharType VirtualPath::kRoot[] = FILE_PATH_LITERAL("/"); 27 const base::FilePath::CharType VirtualPath::kRoot[] = FILE_PATH_LITERAL("/");
28 const base::FilePath::CharType VirtualPath::kSeparator = FILE_PATH_LITERAL('/'); 28 const base::FilePath::CharType VirtualPath::kSeparator = FILE_PATH_LITERAL('/');
29 29
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return GURL(url + "/"); 230 return GURL(url + "/");
231 // Internal types are always pointed via isolated or external URLs. 231 // Internal types are always pointed via isolated or external URLs.
232 default: 232 default:
233 NOTREACHED(); 233 NOTREACHED();
234 } 234 }
235 NOTREACHED(); 235 NOTREACHED();
236 return GURL(); 236 return GURL();
237 } 237 }
238 238
239 std::string GetFileSystemName(const GURL& origin_url, FileSystemType type) { 239 std::string GetFileSystemName(const GURL& origin_url, FileSystemType type) {
240 std::string origin_identifier = 240 std::string origin_identifier = storage::GetIdentifierFromOrigin(origin_url);
241 webkit_database::GetIdentifierFromOrigin(origin_url);
242 std::string type_string = GetFileSystemTypeString(type); 241 std::string type_string = GetFileSystemTypeString(type);
243 DCHECK(!type_string.empty()); 242 DCHECK(!type_string.empty());
244 return origin_identifier + ":" + type_string; 243 return origin_identifier + ":" + type_string;
245 } 244 }
246 245
247 FileSystemType QuotaStorageTypeToFileSystemType( 246 FileSystemType QuotaStorageTypeToFileSystemType(
248 quota::StorageType storage_type) { 247 storage::StorageType storage_type) {
249 switch (storage_type) { 248 switch (storage_type) {
250 case quota::kStorageTypeTemporary: 249 case storage::kStorageTypeTemporary:
251 return kFileSystemTypeTemporary; 250 return kFileSystemTypeTemporary;
252 case quota::kStorageTypePersistent: 251 case storage::kStorageTypePersistent:
253 return kFileSystemTypePersistent; 252 return kFileSystemTypePersistent;
254 case quota::kStorageTypeSyncable: 253 case storage::kStorageTypeSyncable:
255 return kFileSystemTypeSyncable; 254 return kFileSystemTypeSyncable;
256 case quota::kStorageTypeQuotaNotManaged: 255 case storage::kStorageTypeQuotaNotManaged:
257 case quota::kStorageTypeUnknown: 256 case storage::kStorageTypeUnknown:
258 return kFileSystemTypeUnknown; 257 return kFileSystemTypeUnknown;
259 } 258 }
260 return kFileSystemTypeUnknown; 259 return kFileSystemTypeUnknown;
261 } 260 }
262 261
263 quota::StorageType FileSystemTypeToQuotaStorageType(FileSystemType type) { 262 storage::StorageType FileSystemTypeToQuotaStorageType(FileSystemType type) {
264 switch (type) { 263 switch (type) {
265 case kFileSystemTypeTemporary: 264 case kFileSystemTypeTemporary:
266 return quota::kStorageTypeTemporary; 265 return storage::kStorageTypeTemporary;
267 case kFileSystemTypePersistent: 266 case kFileSystemTypePersistent:
268 return quota::kStorageTypePersistent; 267 return storage::kStorageTypePersistent;
269 case kFileSystemTypeSyncable: 268 case kFileSystemTypeSyncable:
270 case kFileSystemTypeSyncableForInternalSync: 269 case kFileSystemTypeSyncableForInternalSync:
271 return quota::kStorageTypeSyncable; 270 return storage::kStorageTypeSyncable;
272 case kFileSystemTypePluginPrivate: 271 case kFileSystemTypePluginPrivate:
273 return quota::kStorageTypeQuotaNotManaged; 272 return storage::kStorageTypeQuotaNotManaged;
274 default: 273 default:
275 return quota::kStorageTypeUnknown; 274 return storage::kStorageTypeUnknown;
276 } 275 }
277 } 276 }
278 277
279 std::string GetFileSystemTypeString(FileSystemType type) { 278 std::string GetFileSystemTypeString(FileSystemType type) {
280 switch (type) { 279 switch (type) {
281 case kFileSystemTypeTemporary: 280 case kFileSystemTypeTemporary:
282 return "Temporary"; 281 return "Temporary";
283 case kFileSystemTypePersistent: 282 case kFileSystemTypePersistent:
284 return "Persistent"; 283 return "Persistent";
285 case kFileSystemTypeIsolated: 284 case kFileSystemTypeIsolated:
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (type_string == "External") { 395 if (type_string == "External") {
397 *type = blink::WebFileSystemTypeExternal; 396 *type = blink::WebFileSystemTypeExternal;
398 return true; 397 return true;
399 } 398 }
400 NOTREACHED(); 399 NOTREACHED();
401 return false; 400 return false;
402 } 401 }
403 402
404 std::string GetIsolatedFileSystemName(const GURL& origin_url, 403 std::string GetIsolatedFileSystemName(const GURL& origin_url,
405 const std::string& filesystem_id) { 404 const std::string& filesystem_id) {
406 std::string name(fileapi::GetFileSystemName( 405 std::string name(
407 origin_url, fileapi::kFileSystemTypeIsolated)); 406 storage::GetFileSystemName(origin_url, storage::kFileSystemTypeIsolated));
408 name.append("_"); 407 name.append("_");
409 name.append(filesystem_id); 408 name.append(filesystem_id);
410 return name; 409 return name;
411 } 410 }
412 411
413 bool CrackIsolatedFileSystemName(const std::string& filesystem_name, 412 bool CrackIsolatedFileSystemName(const std::string& filesystem_name,
414 std::string* filesystem_id) { 413 std::string* filesystem_id) {
415 DCHECK(filesystem_id); 414 DCHECK(filesystem_id);
416 415
417 // |filesystem_name| is of the form {origin}:isolated_{filesystem_id}. 416 // |filesystem_name| is of the form {origin}:isolated_{filesystem_id}.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 case net::ERR_CONNECTION_ABORTED: 501 case net::ERR_CONNECTION_ABORTED:
503 return base::File::FILE_ERROR_ABORT; 502 return base::File::FILE_ERROR_ABORT;
504 case net::ERR_ADDRESS_INVALID: 503 case net::ERR_ADDRESS_INVALID:
505 case net::ERR_INVALID_URL: 504 case net::ERR_INVALID_URL:
506 return base::File::FILE_ERROR_INVALID_URL; 505 return base::File::FILE_ERROR_INVALID_URL;
507 default: 506 default:
508 return base::File::FILE_ERROR_FAILED; 507 return base::File::FILE_ERROR_FAILED;
509 } 508 }
510 } 509 }
511 510
512 } // namespace fileapi 511 } // namespace storage
OLDNEW
« no previous file with comments | « webkit/common/fileapi/file_system_util.h ('k') | webkit/common/quota/quota_status_code.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698