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/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" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 DCHECK(filesystem_id); | 415 DCHECK(filesystem_id); |
416 | 416 |
417 // |filesystem_name| is of the form {origin}:isolated_{filesystem_id}. | 417 // |filesystem_name| is of the form {origin}:isolated_{filesystem_id}. |
418 std::string start_token(":"); | 418 std::string start_token(":"); |
419 start_token = start_token.append( | 419 start_token = start_token.append( |
420 GetFileSystemTypeString(kFileSystemTypeIsolated)).append("_"); | 420 GetFileSystemTypeString(kFileSystemTypeIsolated)).append("_"); |
421 // WebKit uses different case in its constant for isolated file system | 421 // WebKit uses different case in its constant for isolated file system |
422 // names, so we do a case insensitive compare by converting both strings | 422 // names, so we do a case insensitive compare by converting both strings |
423 // to uppercase. | 423 // to uppercase. |
424 // TODO(benwells): Remove this when WebKit uses the same constant. | 424 // TODO(benwells): Remove this when WebKit uses the same constant. |
425 start_token = base::StringToUpperASCII(start_token); | 425 start_token = StringToUpperASCII(start_token); |
426 std::string filesystem_name_upper = base::StringToUpperASCII(filesystem_name); | 426 std::string filesystem_name_upper = StringToUpperASCII(filesystem_name); |
427 size_t pos = filesystem_name_upper.find(start_token); | 427 size_t pos = filesystem_name_upper.find(start_token); |
428 if (pos == std::string::npos) | 428 if (pos == std::string::npos) |
429 return false; | 429 return false; |
430 if (pos == 0) | 430 if (pos == 0) |
431 return false; | 431 return false; |
432 | 432 |
433 *filesystem_id = filesystem_name.substr(pos + start_token.length(), | 433 *filesystem_id = filesystem_name.substr(pos + start_token.length(), |
434 std::string::npos); | 434 std::string::npos); |
435 if (filesystem_id->empty()) | 435 if (filesystem_id->empty()) |
436 return false; | 436 return false; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 return base::File::FILE_ERROR_ABORT; | 503 return base::File::FILE_ERROR_ABORT; |
504 case net::ERR_ADDRESS_INVALID: | 504 case net::ERR_ADDRESS_INVALID: |
505 case net::ERR_INVALID_URL: | 505 case net::ERR_INVALID_URL: |
506 return base::File::FILE_ERROR_INVALID_URL; | 506 return base::File::FILE_ERROR_INVALID_URL; |
507 default: | 507 default: |
508 return base::File::FILE_ERROR_FAILED; | 508 return base::File::FILE_ERROR_FAILED; |
509 } | 509 } |
510 } | 510 } |
511 | 511 |
512 } // namespace fileapi | 512 } // namespace fileapi |
OLD | NEW |