| 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/browser/fileapi/obfuscated_file_util.h" | 5 #include "webkit/browser/fileapi/obfuscated_file_util.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 | 640 |
| 641 PlatformFileError ObfuscatedFileUtil::CopyInForeignFile( | 641 PlatformFileError ObfuscatedFileUtil::CopyInForeignFile( |
| 642 FileSystemOperationContext* context, | 642 FileSystemOperationContext* context, |
| 643 const base::FilePath& src_file_path, | 643 const base::FilePath& src_file_path, |
| 644 const FileSystemURL& dest_url) { | 644 const FileSystemURL& dest_url) { |
| 645 SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true); | 645 SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true); |
| 646 if (!db) | 646 if (!db) |
| 647 return base::PLATFORM_FILE_ERROR_FAILED; | 647 return base::PLATFORM_FILE_ERROR_FAILED; |
| 648 | 648 |
| 649 base::PlatformFileInfo src_platform_file_info; | 649 base::PlatformFileInfo src_platform_file_info; |
| 650 if (!file_util::GetFileInfo(src_file_path, &src_platform_file_info)) | 650 if (!base::GetFileInfo(src_file_path, &src_platform_file_info)) |
| 651 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 651 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 652 | 652 |
| 653 FileId dest_file_id; | 653 FileId dest_file_id; |
| 654 bool overwrite = db->GetFileWithPath(dest_url.path(), | 654 bool overwrite = db->GetFileWithPath(dest_url.path(), |
| 655 &dest_file_id); | 655 &dest_file_id); |
| 656 | 656 |
| 657 FileInfo dest_file_info; | 657 FileInfo dest_file_info; |
| 658 base::PlatformFileInfo dest_platform_file_info; // overwrite case only | 658 base::PlatformFileInfo dest_platform_file_info; // overwrite case only |
| 659 if (overwrite) { | 659 if (overwrite) { |
| 660 base::FilePath dest_local_path; | 660 base::FilePath dest_local_path; |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 *platform_file_path = base::FilePath(); | 1021 *platform_file_path = base::FilePath(); |
| 1022 // We don't fill in ctime or atime. | 1022 // We don't fill in ctime or atime. |
| 1023 return base::PLATFORM_FILE_OK; | 1023 return base::PLATFORM_FILE_OK; |
| 1024 } | 1024 } |
| 1025 if (local_info->data_path.empty()) | 1025 if (local_info->data_path.empty()) |
| 1026 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | 1026 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; |
| 1027 base::FilePath local_path = DataPathToLocalPath(url, local_info->data_path); | 1027 base::FilePath local_path = DataPathToLocalPath(url, local_info->data_path); |
| 1028 base::PlatformFileError error = NativeFileUtil::GetFileInfo( | 1028 base::PlatformFileError error = NativeFileUtil::GetFileInfo( |
| 1029 local_path, file_info); | 1029 local_path, file_info); |
| 1030 // We should not follow symbolic links in sandboxed file system. | 1030 // We should not follow symbolic links in sandboxed file system. |
| 1031 if (file_util::IsLink(local_path)) { | 1031 if (base::IsLink(local_path)) { |
| 1032 LOG(WARNING) << "Found a symbolic file."; | 1032 LOG(WARNING) << "Found a symbolic file."; |
| 1033 error = base::PLATFORM_FILE_ERROR_NOT_FOUND; | 1033 error = base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 1034 } | 1034 } |
| 1035 if (error == base::PLATFORM_FILE_OK) { | 1035 if (error == base::PLATFORM_FILE_OK) { |
| 1036 *platform_file_path = local_path; | 1036 *platform_file_path = local_path; |
| 1037 } else if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) { | 1037 } else if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) { |
| 1038 LOG(WARNING) << "Lost a backing file."; | 1038 LOG(WARNING) << "Lost a backing file."; |
| 1039 InvalidateUsageCache(context, url.origin(), url.type()); | 1039 InvalidateUsageCache(context, url.origin(), url.type()); |
| 1040 if (!db->RemoveFileInfo(file_id)) | 1040 if (!db->RemoveFileInfo(file_id)) |
| 1041 return base::PLATFORM_FILE_ERROR_FAILED; | 1041 return base::PLATFORM_FILE_ERROR_FAILED; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 } | 1403 } |
| 1404 return error; | 1404 return error; |
| 1405 } | 1405 } |
| 1406 | 1406 |
| 1407 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1407 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
| 1408 return special_storage_policy_.get() && | 1408 return special_storage_policy_.get() && |
| 1409 special_storage_policy_->HasIsolatedStorage(origin); | 1409 special_storage_policy_->HasIsolatedStorage(origin); |
| 1410 } | 1410 } |
| 1411 | 1411 |
| 1412 } // namespace fileapi | 1412 } // namespace fileapi |
| OLD | NEW |